Skip to content

Commit

Permalink
explanation on functions used for point coordinates before using star…
Browse files Browse the repository at this point in the history
…s extract
  • Loading branch information
elafam committed Jan 26, 2024
1 parent c2b02ec commit 03f48d3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions wsim-gldas-vis.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,13 @@ df_wsim_gldas_1mo <-as.data.frame(wsim_gldas_1mo, xy = TRUE)
ggplot2::ggplot(data = df_wsim_gldas_1mo) +
ggplot2::geom_raster(ggplot2::aes(x = x, y = y, fill = deficit)) +
ggplot2::scale_color_gradientn(
colors = c('darkred', 'red', 'darkorange', 'orange', 'gold', 'yellow', 'white')) +
#ggplot2::scale_color_gradientn(
#colors = c('darkred', 'red', 'darkorange', 'orange', 'gold', 'yellow', 'white')) +
scale_fill_viridis_c() +
theme_void() +
theme(
legend.position = "bottom"
)
ggplot2::facet_wrap(time ~ .)
Expand All @@ -219,11 +224,10 @@ Visualize an individual cell with particular extreme or maybe volatile values. U
Create a vector with the point location.

```{r}
# coordinates for Austin, Texas
# vector of coordinates for Austin, Texas
coords <- c(-97.7431, 30.2672)
# create a stars object with point coordinates where
# st_sfc(), st_points(), st_crs(),st_dimensions()
# create a stars object with point coordinates where 'sf::st_sfc()' is used to create a geometry list column and add a coordinate reference system. 'sf::st_points()' is within that function to turn the coords vector into a point. 'stars:: st_crs()' and 'stars::st_dimensions()' respectively retrieves the coordinate reference system and the dimensions of wsim_gldas_1mo to ensure that the final values in point_stars is the same reference system and shape.
point_stars <- sf::st_sfc(st_point(coords), crs = stars::st_crs(wsim_gldas_1mo),
dim = names(stars::st_dimensions(wsim_gldas_1mo)))
Expand Down

0 comments on commit 03f48d3

Please sign in to comment.