# \donttest{
# Before using the basemap_dem function, make sure the required data files are available.
# The required files are: "gebco_2024_China.tif" and "China_mask.gpkg".
# You can use check_geodata() to download them from GitHub if they are not available locally.
# Check and download the required data files if they are missing
check_geodata(files = c("gebco_2024_China.tif", "China_mask.gpkg"))
# Define the CRS for China (EPSG:4326 is a common global geographic coordinate system)
china_proj <- "+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs"
# Example 1: Display full rectangular area around China using built-in DEM data
ggplot() +
basemap_dem(within_china = FALSE) +
tidyterra::scale_fill_hypso_tint_c(
palette = "gmt_globe",
breaks = c(-10000, -5000, 0, 2000, 5000, 8000)
) +
theme_minimal()
# Example 2: Display only China's DEM and boundaries using built-in DEM data
ggplot() +
basemap_dem(crs = china_proj, within_china = TRUE) +
geom_boundary_cn(crs = china_proj) +
tidyterra::scale_fill_hypso_c(
palette = "dem_print",
breaks = c(0, 2000, 4000, 6000),
limits = c(0, 7000)
) +
labs(fill = "Elevation (m)") +
theme_minimal()
# }
Run the code above in your browser using DataLab