-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
256 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
neo_kcc <- function(){ | ||
kcc <- "C:/Rprojects/neonet/doc/data/clim/koeppen_7k.tif" | ||
kcc_geo <- terra::rast(kcc) | ||
# colors | ||
colors <- terra::coltab(kcc_geo)[[1]] # Get the color table for the first (or only) layer | ||
cat_df <- levels(kcc_geo)[[1]] # Get the levels/categories for the first (or only) layer | ||
final_df$hexColour <- rgb(final_df$colour.red, final_df$colour.green, final_df$colour.blue, maxColorValue = 255) | ||
color_vector <- setNames(final_df$hexColour, final_df$code) | ||
# kcc_geo <- raster::raster(kcc) | ||
raster_df <- as.data.frame(kcc_geo, xy = TRUE) | ||
bbox <- st_bbox(df.c14) | ||
ggplot2::ggplot() + | ||
ggplot2::geom_raster(data = raster_df, aes(x = x, y = y, fill = factor(code))) + | ||
ggplot2::geom_sf(data = df.c14, color = "black", size = 0.5) + # Add the sf object, assuming df.c14 is ready | ||
ggplot2::coord_sf() + # Use coordinate system from sf object | ||
ggplot2::scale_fill_manual(values = color_vector) + # Map fill colors using color_vector | ||
ggplot2::labs(fill = "Climate Code") + # Optional: add a legend title | ||
ggplot2::coord_sf(xlim = c(bbox$xmin, bbox$xmax), ylim = c(bbox$ymin, bbox$ymax)) | ||
} | ||
|
||
ggplot() + | ||
ggplot2::geom_raster(data = raster_df, aes(x = x, y = y, fill = factor(code))) + | ||
ggplot2::scale_fill_manual(values = color_vector) + # Map fill colors using color_vector | ||
ggplot2::geom_sf(data = df.c14, color = "red", size = 0.5) + # Add the sf object | ||
ggplot2::coord_sf() + # Use coordinate system from sf object | ||
ggplot2::labs(fill = "Climate Code") + # Optional: add a legend title | ||
ggplot2::coord_sf(xlim = c(bbox$xmin, bbox$xmax), ylim = c(bbox$ymin, bbox$ymax)) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"","x" | ||
"1",TRUE |
Oops, something went wrong.