diff --git a/docs/articles/Adding_Basic_Map.html b/docs/articles/Adding_Basic_Map.html index 6badca2..883c9f4 100644 --- a/docs/articles/Adding_Basic_Map.html +++ b/docs/articles/Adding_Basic_Map.html @@ -65,10 +65,19 @@

Adding_Basic_Map

-library(ggmapcn)
+library(ggmapcn)
 #> Loading required package: ggplot2
-

Basic Map Plot +

Introduction +

+

The ggmapcn package provides various tools for visualizing geographic +data in China and beyond. This vignette demonstrates the basic and +advanced usage of geom_mapcn() and +geom_world() for plotting administrative boundaries and +combining geographic data.

+
+
+

Example 1: Basic Map of China

To plot a map of China with province boundaries, use the geom_mapcn() function. The map uses the Azimuthal Equal @@ -80,7 +89,7 @@

Basic Map PlotBasic Map

-

Example +

Example 2: Adding Buffer Zones and Coastlines

Here’s a comprehensive example demonstrating how to plot province boundaries, buffer zones, and coastlines on the same map:

@@ -91,7 +100,79 @@

Example geom_mapcn(fill = "white") + geom_boundary_cn() + theme_bw()

-

Map of China

+

Map of China

+ +
+

Example 3: Overlaying China on a World Map +

+

The geom_world() function allows you to visualize global +data, while geom_mapcn() overlays China for detailed +analysis.

+
+# Define projections
+china_proj <- "+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs"
+
+# Combine world map as a background and China map as overlay
+ggplot() +
+  # World map as background
+  geom_world(fill = "gray90", color = "gray70", linewidth = 0.2) +
+  coord_proj(
+    crs = "+proj=merc",
+    xlim = c(-180, 180),
+    ylim = c(-90, 90)
+  ) +
+  # Overlay China map
+  geom_mapcn(
+    fill = "lightblue",
+    color = "black",
+    linewidth = 0.5
+  ) +
+  geom_boundary_cn(color = "red", linewidth = 0.6) +
+  theme_minimal()
+#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
+#> Coordinate system already present. Adding new coordinate system, which will
+#> replace the existing one.
+#> Warning: Duplicated aesthetics after name standardisation: colour and linewidth
+#> Duplicated aesthetics after name standardisation: colour and linewidth
+#> Duplicated aesthetics after name standardisation: colour and linewidth
+#> Duplicated aesthetics after name standardisation: colour and linewidth
+#> Duplicated aesthetics after name standardisation: colour and linewidth
+

Map of world

+
+
+

Example 4: Filtering China and Its Neighbors +

+

This example demonstrates filtering for China and its neighboring +countries, highlighting China in red.

+
+# Define neighboring countries
+china_neighbors <- c("CHN", "AFG", "BTN", "MMR", "LAO", "NPL", "PRK", "KOR",
+                     "KAZ", "KGZ", "MNG", "IND", "BGD", "TJK", "PAK", "LKA", "VNM")
+
+# Plot world map with filtered countries
+ggplot() +
+  geom_world(fill = "gray90", color = "gray70", linewidth = 0.2) +
+  geom_world(
+    filter = china_neighbors,
+    filter_attribute = "SOC",
+    fill = "lightblue",
+    color = "black",
+    linewidth = 0.5
+  ) +
+  geom_world(
+    filter = "CHN",
+    filter_attribute = "SOC",
+    fill = "red",
+    color = "black",
+    linewidth = 0.8
+  ) +
+  coord_proj(
+    crs = "+proj=merc",
+    xlim = c(60, 140),
+    ylim = c(-10, 60)
+  ) +
+  theme_minimal()
+

Map of China

diff --git a/docs/articles/Adding_Basic_Map_files/figure-html/example5-1.png b/docs/articles/Adding_Basic_Map_files/figure-html/example2-1.png similarity index 100% rename from docs/articles/Adding_Basic_Map_files/figure-html/example5-1.png rename to docs/articles/Adding_Basic_Map_files/figure-html/example2-1.png diff --git a/docs/articles/Adding_Basic_Map_files/figure-html/example3-1.png b/docs/articles/Adding_Basic_Map_files/figure-html/example3-1.png new file mode 100644 index 0000000..f2d0c03 Binary files /dev/null and b/docs/articles/Adding_Basic_Map_files/figure-html/example3-1.png differ diff --git a/docs/articles/Adding_Basic_Map_files/figure-html/example4-1.png b/docs/articles/Adding_Basic_Map_files/figure-html/example4-1.png new file mode 100644 index 0000000..5a686d9 Binary files /dev/null and b/docs/articles/Adding_Basic_Map_files/figure-html/example4-1.png differ diff --git a/docs/articles/Adding_Spatial_Data.html b/docs/articles/Adding_Spatial_Data.html index 81d941b..ef71e82 100644 --- a/docs/articles/Adding_Spatial_Data.html +++ b/docs/articles/Adding_Spatial_Data.html @@ -65,7 +65,7 @@

Adding_Spatial_Data

-library(ggmapcn)
+library(ggmapcn)
 #> Loading required package: ggplot2
 # Define Azimuthal Equidistant projection centered on China
 china_proj <- "+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs"
@@ -139,6 +139,29 @@

basemap_dem: Eleva #> 'svc' to get all geometries #> <SpatRaster> resampled to 1000968 cells.

Elevation Map of China

+ +
+

coord_proj: Transforming Limits for Custom Projections +

+

The coord_proj function is a wrapper around coord_sf +that allows you to specify map limits (xlim, ylim) in longitude and +latitude (WGS84 CRS) and automatically transforms them into the +specified CRS for accurate projections.

+

Here, the Azimuthal Equidistant projection centered on China is +applied, with transformed map limits specified in longitude and +latitude.

+
+# World map with Azimuthal Equidistant projection centered on China
+ggplot() +
+  geom_world(fill = "lightblue") +
+  coord_proj(
+    crs = china_proj,
+    xlim = c(60, 140),
+    ylim = c(10, 50)
+  ) +
+  theme_minimal()
+#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
+

clip region

diff --git a/docs/articles/Adding_Spatial_Data_files/figure-html/clip region-1.png b/docs/articles/Adding_Spatial_Data_files/figure-html/clip region-1.png new file mode 100644 index 0000000..fe351b1 Binary files /dev/null and b/docs/articles/Adding_Spatial_Data_files/figure-html/clip region-1.png differ diff --git a/docs/index.html b/docs/index.html index b7d2234..28b37da 100644 --- a/docs/index.html +++ b/docs/index.html @@ -61,7 +61,7 @@

Installation

-

You can install the development version of ggmapcn from GitHub with devtools:

+

Install the development version of ggmapcn from GitHub with:

 # install.packages("devtools")
 devtools::install_github("Rimagination/ggmapcn", force = TRUE)
@@ -70,38 +70,33 @@

InstallationUsage

-

Load the Package +

Plotting a Map of China

+

To plot a map of China with province boundaries, use geom_mapcn():

-
-
-

Basic Map Plot -

-

To plot a map of China with province boundaries, use the geom_mapcn() function. The map uses the Azimuthal Equal Distance projection by default.

-
-ggplot() +
+library(ggmapcn)
+
+ggplot() +
   geom_mapcn() +
-  theme_minimal()
-#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
-

Basic Map

+ theme_minimal()
+

Province Map

Custom Projection and Styling

If you want to try the Albers projection, you can customize it.

-
+
 ggplot() +
   geom_mapcn(crs = "+proj=aea +lat_1=25 +lat_2=47 +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs", color = "black", fill = "white", size = 0.7) +
   theme_minimal()
-

Basic Map

+

Basic Map

Adding Mainland Borders and Coastlines

Use geom_boundary_cn() to add mainland borders and coastlines to the map. You can set colors and line widths for both the mainland and coastline boundaries:

-
+
 ggplot() +
   geom_mapcn(fill = NA) +
   geom_boundary_cn(
@@ -111,36 +106,25 @@ 

Adding Mainland Borders and Coas coastline_size = 0.5 ) + theme_minimal()

-

Map with Boundary

+

Map with Boundary

Adding Buffer Zones

The geom_buffer_cn() function adds buffer zones around China’s borders. You can specify buffer distances, colors, and projections. The example below shows buffer zones with varying distances:

-
+
 ggplot() +
   geom_buffer_cn(mainland_dist = 40000) +
   geom_buffer_cn(mainland_dist = 20000, fill = "#BBB3D8") +
+  geom_mapcn(fill = "white") +
+  geom_boundary_cn() +
   theme_minimal()
-

Buffer

+

Map of China

Data Source

-

The data used in this package is sourced from Tianditu, providing province-level boundary information. This data has been processed into GeoJSON format and is integrated into the package for easy access. You’ll still need to render README.Rmd regularly, to keep README.md up-to-date. devtools::build_readme() is handy for this.

-
-
-

Example -

-

Here’s a comprehensive example demonstrating how to plot province boundaries, buffer zones, and coastlines on the same map:

-
-ggplot() +
-  geom_buffer_cn(mainland_dist = 40000) +
-  geom_buffer_cn(mainland_dist = 20000, fill = "#BBB3D8") +
-  geom_mapcn(fill = "white") +
-  geom_boundary_cn() +
-  theme_minimal()
-

Map of China

+

The data used in this package is sourced from Tianditu (https://cloudcenter.tianditu.gov.cn/administrativeDivision/), a reliable provider of province-, city-, and county-level boundary information in China. This administrative division data has been processed into GeoJSON format for seamless integration into the package, enabling easy access and visualization.

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 644af6c..43a1b09 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -4,7 +4,7 @@ pkgdown_sha: ~ articles: Adding_Basic_Map: Adding_Basic_Map.html Adding_Spatial_Data: Adding_Spatial_Data.html -last_built: 2024-11-24T12:11Z +last_built: 2024-11-24T17:16Z urls: reference: https://rimagination.github.io/ggmapcn/reference article: https://rimagination.github.io/ggmapcn/articles diff --git a/docs/reference/coord_proj-1.png b/docs/reference/coord_proj-1.png new file mode 100644 index 0000000..89b3012 Binary files /dev/null and b/docs/reference/coord_proj-1.png differ diff --git a/docs/reference/coord_proj-2.png b/docs/reference/coord_proj-2.png new file mode 100644 index 0000000..e62e872 Binary files /dev/null and b/docs/reference/coord_proj-2.png differ diff --git a/docs/reference/coord_proj.html b/docs/reference/coord_proj.html new file mode 100644 index 0000000..34ccbe1 --- /dev/null +++ b/docs/reference/coord_proj.html @@ -0,0 +1,156 @@ + +Coordinate System with Transformed Limits for Custom Projections — coord_proj • ggmapcn + Skip to contents + + +
+
+
+ +
+

coord_proj is a wrapper around ggplot2::coord_sf(). +It simplifies specifying map limits (xlim, ylim) in longitude and latitude (WGS84 CRS) +and automatically transforms them into the specified CRS for accurate projections.

+

This function extends the functionality of coord_sf() to seamlessly handle user-specified +geographic boundaries in any projection, ensuring accurate mapping.

+
+ +
+

Usage

+
coord_proj(
+  crs = NULL,
+  xlim = NULL,
+  ylim = NULL,
+  expand = TRUE,
+  default_crs = "EPSG:4326",
+  ...
+)
+
+ +
+

Arguments

+ + +
crs
+

A character string specifying the coordinate reference system (CRS) for the projection +(e.g., "EPSG:4326" or custom projections like "+proj=merc").

+ + +
xlim
+

Longitude range (in degrees) to display, as a numeric vector of length 2.

+ + +
ylim
+

Latitude range (in degrees) to display, as a numeric vector of length 2.

+ + +
expand
+

Logical, whether to expand the plot limits. Default is TRUE.

+ + +
default_crs
+

A character string specifying the CRS of the input xlim and ylim. +Default is "EPSG:4326".

+ + +
...
+

Additional arguments passed to ggplot2::coord_sf().

+ +
+
+

Value

+

A ggplot2 coord_sf object with the transformed limits.

+
+
+

See also

+ +
+ +
+

Examples

+

+# World map with default projection and limits
+ggplot() +
+  geom_world() +
+  coord_proj(
+    crs = "+proj=longlat +datum=WGS84",
+    xlim = c(-180, 180),
+    ylim = c(-90, 90),
+    expand=FALSE
+  ) +
+  theme_minimal()
+#> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
+
+
+# Focused view with Azimuthal Equidistant projection
+china_proj <- "+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs"
+ggplot() +
+  geom_world(fill = "lightblue") +
+  coord_proj(
+    crs = china_proj,
+    xlim = c(60, 140),
+    ylim = c(-10, 50)
+  ) +
+  theme_minimal()
+
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/figures/README-example1-1.png b/docs/reference/figures/README-example1-1.png new file mode 100644 index 0000000..e1f64a1 Binary files /dev/null and b/docs/reference/figures/README-example1-1.png differ diff --git a/docs/reference/figures/README-example2-1.png b/docs/reference/figures/README-example2-1.png index 147a145..67802e1 100644 Binary files a/docs/reference/figures/README-example2-1.png and b/docs/reference/figures/README-example2-1.png differ diff --git a/docs/reference/figures/README-example3-1.png b/docs/reference/figures/README-example3-1.png index 67802e1..6270953 100644 Binary files a/docs/reference/figures/README-example3-1.png and b/docs/reference/figures/README-example3-1.png differ diff --git a/docs/reference/figures/README-example4-1.png b/docs/reference/figures/README-example4-1.png index abb96c7..d157e59 100644 Binary files a/docs/reference/figures/README-example4-1.png and b/docs/reference/figures/README-example4-1.png differ diff --git a/docs/reference/geom_mapcn-4.png b/docs/reference/geom_mapcn-4.png deleted file mode 100644 index 738448c..0000000 Binary files a/docs/reference/geom_mapcn-4.png and /dev/null differ diff --git a/docs/reference/index.html b/docs/reference/index.html index 0a71bec..a204347 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -60,6 +60,12 @@

All functionscoord_proj() + + +
Coordinate System with Transformed Limits for Custom Projections
+
+ geom_boundary_cn()
diff --git a/docs/search.json b/docs/search.json index 22476ed..5d933b7 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Basic_Map.html","id":"basic-map-plot","dir":"Articles","previous_headings":"","what":"Basic Map Plot","title":"Adding_Basic_Map","text":"plot map China province boundaries, use geom_mapcn() function. map uses Azimuthal Equal Distance projection default.","code":"ggplot() + geom_mapcn() + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Basic_Map.html","id":"example","dir":"Articles","previous_headings":"","what":"Example","title":"Adding_Basic_Map","text":"’s comprehensive example demonstrating plot province boundaries, buffer zones, coastlines map:","code":"ggplot() + geom_buffer_cn(mainland_dist = 40000) + geom_buffer_cn(mainland_dist = 20000, fill = \"#BBB3D8\") + geom_mapcn(fill = \"white\") + geom_boundary_cn() + theme_bw()"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Adding_Spatial_Data","text":"vignette introduces two functions ggmapcn package: geom_loc geom_vege_raster. functions extend capabilities package spatial data visualization.","code":""},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"geom_loc-adding-spatial-point-data-layer-with-color-by-grouping","dir":"Articles","previous_headings":"","what":"geom_loc: Adding Spatial Point Data Layer with Color by Grouping","title":"Adding_Spatial_Data","text":"geom_loc function allows add spatial point data ggplot, supporting sf tabular data frames, color mapping based grouping variable.","code":"# Create a ggplot with spatial points colored by 'Category' set.seed(123) data_sim <- data.frame( Longitude = runif(100, 80, 120), Latitude = runif(100, 28, 40), Category = sample(c(\"Type A\", \"Type B\", \"Type C\"), 100, replace = TRUE) ) ggplot() + geom_boundary_cn() + geom_loc( data = data_sim, lon = \"Longitude\", lat = \"Latitude\", mapping = aes(color = Category), size = 1, alpha = 0.7 ) + theme_bw()"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"basemap_vege-vegetation-map-of-china-layer-for-ggplot2","dir":"Articles","previous_headings":"","what":"basemap_vege: Vegetation Map of China Layer for ggplot2","title":"Adding_Spatial_Data","text":"basemap_vege function adds vegetation raster map China color-coded vegetation types ggplot.","code":"# Add vegetation raster of China to a ggplot ggplot() + basemap_vege() + guides(fill = guide_none()) + theme_bw() #> resampled to 1000776 cells. #> Warning: Removed 715308 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"basemap_dem-elevation-map-of-china-layer-for-ggplot2","dir":"Articles","previous_headings":"","what":"basemap_dem: Elevation Map of China Layer for ggplot2","title":"Adding_Spatial_Data","text":"basemap_dem function adds digital elevation model (DEM) raster map China layer ggplot2.","code":"# Apply Azimuthal Equidistant projection centered on China 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() + theme(legend.position = \"bottom\") #> Warning: [vect] returning polygons ignoring additional geometry types. Use #> 'svc' to get all geometries #> resampled to 1000968 cells."},{"path":"https://rimagination.github.io/ggmapcn/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Liang Ren. Author, maintainer.","code":""},{"path":"https://rimagination.github.io/ggmapcn/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Ren L (2024). ggmapcn: Customizable China Map Visualizations. R package version 0.0.2, https://rimagination.github.io/ggmapcn.","code":"@Manual{, title = {ggmapcn: Customizable China Map Visualizations}, author = {Liang Ren}, year = {2024}, note = {R package version 0.0.2}, url = {https://rimagination.github.io/ggmapcn}, }"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"ggmapcn","dir":"","previous_headings":"","what":"Customizable China Map Visualizations","title":"Customizable China Map Visualizations","text":"ggmapcn ggplot2 extension package visualizing China’s map customizable projections styling. package includes province-level map data supports adding mainland borders, coastlines, buffer areas, making easy create geographic visualizations China.","code":""},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Customizable China Map Visualizations","text":"can install development version ggmapcn GitHub devtools:","code":"# install.packages(\"devtools\") devtools::install_github(\"Rimagination/ggmapcn\", force = TRUE)"},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"load-the-package","dir":"","previous_headings":"","what":"Load the Package","title":"Customizable China Map Visualizations","text":"","code":"library(ggplot2) library(ggmapcn)"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"basic-map-plot","dir":"","previous_headings":"","what":"Basic Map Plot","title":"Customizable China Map Visualizations","text":"plot map China province boundaries, use geom_mapcn() function. map uses Azimuthal Equal Distance projection default.","code":"ggplot() + geom_mapcn() + theme_minimal() #> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"custom-projection-and-styling","dir":"","previous_headings":"","what":"Custom Projection and Styling","title":"Customizable China Map Visualizations","text":"want try Albers projection, can customize .","code":"ggplot() + geom_mapcn(crs = \"+proj=aea +lat_1=25 +lat_2=47 +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs\", color = \"black\", fill = \"white\", size = 0.7) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"adding-mainland-borders-and-coastlines","dir":"","previous_headings":"","what":"Adding Mainland Borders and Coastlines","title":"Customizable China Map Visualizations","text":"Use geom_boundary_cn() add mainland borders coastlines map. can set colors line widths mainland coastline boundaries:","code":"ggplot() + geom_mapcn(fill = NA) + geom_boundary_cn( mainland_color = \"black\", mainland_size = 0.5, coastline_color = \"skyblue\", coastline_size = 0.5 ) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"adding-buffer-zones","dir":"","previous_headings":"","what":"Adding Buffer Zones","title":"Customizable China Map Visualizations","text":"geom_buffer_cn() function adds buffer zones around China’s borders. can specify buffer distances, colors, projections. example shows buffer zones varying distances:","code":"ggplot() + geom_buffer_cn(mainland_dist = 40000) + geom_buffer_cn(mainland_dist = 20000, fill = \"#BBB3D8\") + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"data-source","dir":"","previous_headings":"","what":"Data Source","title":"Customizable China Map Visualizations","text":"data used package sourced Tianditu, providing province-level boundary information. data processed GeoJSON format integrated package easy access. ’ll still need render README.Rmd regularly, keep README.md --date. devtools::build_readme() handy .","code":""},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Customizable China Map Visualizations","text":"’s comprehensive example demonstrating plot province boundaries, buffer zones, coastlines map:","code":"ggplot() + geom_buffer_cn(mainland_dist = 40000) + geom_buffer_cn(mainland_dist = 20000, fill = \"#BBB3D8\") + geom_mapcn(fill = \"white\") + geom_boundary_cn() + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":null,"dir":"Reference","previous_headings":"","what":"Elevation Map of China Layer for ggplot2 — basemap_dem","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"basemap_dem adds digital elevation model (DEM) raster map China layer ggplot2. function ensures output map remains rectangular, regardless chosen projection. supports displaying DEM either within China's boundary larger rectangular area around China.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"","code":"basemap_dem( crs = NULL, within_china = FALSE, maxcell = 1e+06, na.rm = FALSE, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"crs Coordinate reference system (CRS) projection. Defaults CRS DEM data. Users can specify CRS strings (e.g., \"EPSG:4326\" custom projections). within_china Logical. TRUE, displays DEM within China's boundary. FALSE, displays DEM larger rectangular area around China. Default FALSE. maxcell Maximum number cells rendering (improve performance). Defaults 1e6. na.rm Logical. TRUE, removes missing values. Default FALSE. ... Additional parameters passed geom_spatraster.","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"","code":"# Define Azimuthal Equidistant projection centered on China china_proj <- \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\" # Example 1: Display full rectangular area around China 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() #> resampled to 1001810 cells. # Example 2: Display only China's DEM and boundaries 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() #> Warning: [vect] returning polygons ignoring additional geometry types. Use 'svc' to get all geometries #> resampled to 1000968 cells."},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":null,"dir":"Reference","previous_headings":"","what":"Vegetation Map of China Layer for ggplot2 — basemap_vege","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"Adds vegetation raster map China ggplot2 plot, color-coded vegetation types.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"","code":"basemap_vege( color_table = NULL, crs = NULL, maxcell = 1e+06, use_coltab = TRUE, na.rm = FALSE, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"color_table data frame containing vegetation types corresponding colors. columns \"code\" (raster values), \"type\" (vegetation names), \"col\" (hex color codes). NULL, default color table based standard vegetation classifications China used. crs character string specifying coordinate reference system projection. NULL, default projection \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\" applied. maxcell integer indicating maximum number cells rendering improve performance. Defaults 1e6. use_coltab logical value indicating whether use color table raster values. Default TRUE. na.rm logical value indicating whether remove missing values. Default FALSE. ... Additional parameters passed geom_spatraster.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"ggplot2 layer object representing vegetation map China.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"Zhang X, Sun S, Yong S, et al. (2007). Vegetation map People's Republic China (1:1000000). Geology Publishing House, Beijing.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"","code":"if (FALSE) { # \\dontrun{ # Add vegetation raster of China to a ggplot ggplot() + basemap_vege() + theme_minimal() # Customize color table custom_colors <- data.frame( code = 0:11, type = c( \"Non-vegetated\", \"Needleleaf forest\", \"Needleleaf and broadleaf mixed forest\", \"Broadleaf forest\", \"Scrub\", \"Desert\", \"Steppe\", \"Grassland\", \"Meadow\", \"Swamp\", \"Alpine vegetation\", \"Cultivated vegetation\" ), col = c( \"#8D99B3\", \"#97B555\", \"#34BF36\", \"#9ACE30\", \"#2EC6C9\", \"#E5CE0E\", \"#5BB1ED\", \"#6494EF\", \"#7AB9CB\", \"#D97A80\", \"#B87701\", \"#FEB780\" ) ) ggplot() + basemap_vege(color_table = custom_colors) + labs(fill = \"Vegetation type group\") + theme_minimal() } # }"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Boundaries of China — geom_boundary_cn","title":"Plot Boundaries of China — geom_boundary_cn","text":"Draws various types boundaries China, including mainland boundaries, coastlines, ten-segment line, special administrative region (SAR) boundaries, undefined boundaries. boundary type can customized terms color, line width, line type. function also allows optional addition compass scale bar.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Boundaries of China — geom_boundary_cn","text":"","code":"geom_boundary_cn( crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", compass = FALSE, scale = FALSE, mainland_color = \"black\", mainland_size = 0.5, mainland_linetype = \"solid\", coastline_color = \"blue\", coastline_size = 0.3, coastline_linetype = \"solid\", ten_segment_line_color = \"black\", ten_segment_line_size = 0.5, ten_segment_line_linetype = \"solid\", SAR_boundary_color = \"grey\", SAR_boundary_size = 0.5, SAR_boundary_linetype = \"dashed\", undefined_boundary_color = \"black\", undefined_boundary_size = 0.5, undefined_boundary_linetype = \"longdash\", ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Boundaries of China — geom_boundary_cn","text":"crs Character. Coordinate reference system (CRS) projection. Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". Users can specify CRS strings customize projection (e.g., \"+proj=merc\" Mercator). compass Logical. Whether display compass (north arrow). Default FALSE. set TRUE, default compass (north arrow) ggspatial::north_arrow_fancy_orienteering() added top-left corner. customize compass, use ggspatial::annotation_north_arrow() directly. scale Logical. Whether display scale bar. Default FALSE. set TRUE, default scale bar ggspatial::annotation_scale() added bottom-left corner. customize scale bar, use ggspatial::annotation_scale() directly. mainland_color Character. Color mainland boundary. Default \"black\". mainland_size Numeric. Line width mainland boundary. Default 0.5. mainland_linetype Character. Line type mainland boundary. Default \"solid\". coastline_color Character. Color coastline. Default \"blue\". coastline_size Numeric. Line width coastline. Default 0.3. coastline_linetype Character. Line type coastline. Default \"solid\". ten_segment_line_color Character. Color ten-segment line. Default \"black\". ten_segment_line_size Numeric. Line width ten-segment line. Default 0.5. ten_segment_line_linetype Character. Line type ten-segment line. Default \"solid\". SAR_boundary_color Character. Color SAR boundary. Default \"grey\". SAR_boundary_size Numeric. Line width SAR boundary. Default 0.5. SAR_boundary_linetype Character. Line type SAR boundary. Default \"dashed\". undefined_boundary_color Character. Color undefined boundary. Default \"lightgrey\". undefined_boundary_size Numeric. Line width undefined boundary. Default 0.5. undefined_boundary_linetype Character. Line type undefined boundary. Default \"longdash\". ... Additional parameters passed geom_sf.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Boundaries of China — geom_boundary_cn","text":"ggplot2 layer (list layers) displaying China's multi-segment boundaries specified styles, optionally including compass (north arrow) scale bar.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Boundaries of China — geom_boundary_cn","text":"","code":"if (FALSE) { # \\dontrun{ # Plot China's boundaries with default settings ggplot() + geom_boundary_cn() + theme_minimal() # Plot China's boundaries with a compass and scale bar ggplot() + geom_boundary_cn(compass = TRUE, scale = TRUE) + theme_minimal() # For customized compass or scale bar, use ggspatial directly: ggplot() + geom_boundary_cn() + ggspatial::annotation_north_arrow( location = \"br\", style = ggspatial::north_arrow_minimal() ) + ggspatial::annotation_scale( location = \"tr\", width_hint = 0.3 ) + theme_minimal() } # }"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"function creates ggplot2 layer displaying buffered areas around China's boundaries, including mainland boundary ten-segment line. Buffers user-defined distances generated around boundary, providing flexibility projection appearance.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"","code":"geom_buffer_cn( mainland_dist = 20000, ten_line_dist = NULL, crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", color = NA, fill = \"#D2D5EB\", ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"mainland_dist Numeric. buffer distance (meters) mainland boundary. ten_line_dist Numeric. buffer distance (meters) segment ten-segment line. specified, defaults value mainland_dist. crs Character. coordinate reference system (CRS) projection. Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". Users can specify CRS strings customize projection (e.g., \"+proj=merc\" Mercator). color Character. border color buffer area. Default NA (transparent). fill Character. fill color buffer area. Default \"#D2D5EB\". ... Additional parameters passed geom_sf.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"ggplot2 layer displaying buffered areas around China's boundaries, customizable buffer distances mainland boundary ten-segment line, using specified projection.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"","code":"if (FALSE) { # \\dontrun{ # Plot buffers with specified distances for mainland and ten-segment line ggplot() + geom_buffer_cn( mainland_dist = 10000, ten_line_dist = 5000 ) + theme_minimal() } # }"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":null,"dir":"Reference","previous_headings":"","what":"Visualize Spatial Point Data — geom_loc","title":"Visualize Spatial Point Data — geom_loc","text":"geom_loc wrapper around ggplot2::geom_sf() designed visualizing spatial point data. supports sf objects tabular data frames longitude latitude columns, automatically transforming specified coordinate reference system (CRS).","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Visualize Spatial Point Data — geom_loc","text":"","code":"geom_loc( data, lon = NULL, lat = NULL, crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", mapping = aes(), ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Visualize Spatial Point Data — geom_loc","text":"data data frame, tibble, sf object containing spatial point data. lon character string. name longitude column data (required data tabular). lat character string. name latitude column data (required data tabular). crs character string. target coordinate reference system (CRS) data. Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". mapping Aesthetic mappings created ggplot2::aes(), color size. ... Additional parameters passed ggplot2::geom_sf(), size, alpha, color.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Visualize Spatial Point Data — geom_loc","text":"ggplot2 layer visualizing spatial point data.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Visualize Spatial Point Data — geom_loc","text":"function simplifies process visualizing spatial data ggplot2 automatically handling CRS transformations providing interface sf tabular data. input tabular data frame, converted sf object using specified longitude latitude columns. See ggplot2::geom_sf() details additional parameters aesthetics.","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Visualize Spatial Point Data — geom_loc","text":"","code":"# Generate a random dataset with latitude and longitude set.seed(123) data_sim <- data.frame( Longitude = runif(100, 80, 120), Latitude = runif(100, 28, 40), Category = sample(c(\"Type A\", \"Type B\", \"Type C\"), 100, replace = TRUE) ) # Visualize the data with China's boundaries ggplot() + geom_boundary_cn() + geom_loc( data = data_sim, lon = \"Longitude\", lat = \"Latitude\", mapping = aes(color = Category), size = 1, alpha = 0.7 ) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot China Map with Customizable Options — geom_mapcn","title":"Plot China Map with Customizable Options — geom_mapcn","text":"geom_mapcn provides flexible interface visualizing China's administrative boundaries. Users can select administrative levels (province, city, county), apply custom projections, filter specific regions.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot China Map with Customizable Options — geom_mapcn","text":"","code":"geom_mapcn( data = NULL, admin_level = \"province\", crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", color = \"black\", fill = \"white\", linewidth = 0.5, filter_attribute = NULL, filter = NULL, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot China Map with Customizable Options — geom_mapcn","text":"data sf object containing China's map data. NULL, function loads package's default map. Users can select provincial, municipal, county-level maps using admin_level parameter. admin_level character string specifying administrative level map. Options \"province\" (default), \"city\", \"county\". corresponding GeoJSON files (China_sheng.geojson, China_shi.geojson, China_xian.geojson) must located package's extdata folder. crs Coordinate Reference System (CRS). Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". Users can specify CRS strings (e.g., \"EPSG:4326\"). color Border color. Default \"black\". fill Fill color. Default \"white\". linewidth Line width borders. Default 0.5. filter_attribute Column name filtering regions (e.g., \"name_en\"). filter Character vector values filter specific regions (e.g., c(\"Beijing\", \"Shanghai\")). ... Additional parameters passed geom_sf.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot China Map with Customizable Options — geom_mapcn","text":"ggplot2 layer visualizing China's administrative boundaries.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot China Map with Customizable Options — geom_mapcn","text":"","code":"# Plot provincial map ggplot() + geom_mapcn() + theme_minimal() # Filter specific provinces ggplot() + geom_mapcn(filter_attribute = \"name_en\", filter = c(\"Beijing\", \"Shanghai\"), fill = \"red\") + theme_minimal() # Use a Mercator projection ggplot() + geom_mapcn(crs = \"+proj=merc\", linewidth = 0.7) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot World Map with Customizable Options — geom_world","title":"Plot World Map with Customizable Options — geom_world","text":"geom_world wrapper around ggplot2::geom_sf() designed visualizing world maps added flexibility. allows custom projections, filtering specific countries regions, detailed aesthetic customizations borders fills.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot World Map with Customizable Options — geom_world","text":"","code":"geom_world( data = NULL, crs = \"+proj=longlat +datum=WGS84\", color = \"black\", fill = \"white\", linewidth = 0.5, filter_attribute = \"SOC\", filter = NULL, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot World Map with Customizable Options — geom_world","text":"data sf object containing world map data. NULL, function loads package's default world.geojson dataset. crs character string. target coordinate reference system (CRS) map projection. Defaults \"+proj=longlat +datum=WGS84\". color character string specifying border color administrative boundaries. Default \"black\". fill character string specifying fill color administrative areas. Default \"white\". linewidth numeric value specifying line width administrative boundaries. Default 0.5. filter_attribute character string specifying column name use filtering countries regions. Default \"SOC\", refers ISO 3166-1 alpha-3 country code default dataset. filter character vector specifying values filter specific countries regions. Default NULL. ... Additional parameters passed ggplot2::geom_sf(), size, alpha, lty.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot World Map with Customizable Options — geom_world","text":"ggplot2 layer world map visualization.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot World Map with Customizable Options — geom_world","text":"geom_world simplifies process creating world maps combining functionality geom_sf user-friendly options projections, filtering, custom styling. Key features include: Custom projections: Easily apply CRS map. Filtering attributes: Quickly focus specific countries regions. Flexible aesthetics: Customize fill, borders, transparency, visual properties.","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot World Map with Customizable Options — geom_world","text":"","code":"# Plot the default world map ggplot() + geom_world() + theme_minimal() # Apply Mercator projection ggplot() + geom_world(crs = \"+proj=merc\") + theme_minimal() # Filter specific countries (e.g., China and its neighbors) china_neighbors <- c(\"CHN\", \"AFG\", \"BTN\", \"MMR\", \"LAO\", \"NPL\", \"PRK\", \"KOR\", \"KAZ\", \"KGZ\", \"MNG\", \"IND\", \"BGD\", \"TJK\", \"PAK\", \"LKA\", \"VNM\") ggplot() + geom_world(filter = china_neighbors) + theme_minimal() # Background map + Highlight specific region ggplot() + geom_world(fill = \"gray80\", color = \"gray50\", alpha = 0.5) + geom_world(filter = c(\"CHN\"), fill = \"red\", color = \"black\", linewidth = 1.5) + theme_minimal() # Customize styles with transparency and bold borders ggplot() + geom_world(fill = \"lightblue\", color = \"darkblue\", linewidth = 1, alpha = 0.8) + theme_void()"},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"new-features-0-0-2","dir":"Changelog","previous_headings":"","what":"New Features","title":"ggmapcn 0.0.2","text":"Introduced basemap_dem() visualizing elevation data customizable projections. Introduced basemap_vege() visualizing vegetation data China customizable projections. Introduced geom_world() visualizing global administrative divisions.","code":""},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"bug-fixes-0-0-2","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"ggmapcn 0.0.2","text":"Replaced size linewidth align latest ggplot2 standards.","code":""},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"enhancements-0-0-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"ggmapcn 0.0.2","text":"Improved styling options various boundaries geom_boundary_cn().","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"initial-release-0-0-1","dir":"Changelog","previous_headings":"","what":"Initial Release","title":"ggmapcn 0.0.1","text":"Added basic functionality creating customized maps China. Integrated seamless support ggplot2. Included administrative boundary datasets provinces, cities, counties.","code":""}] +[{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Basic_Map.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Adding_Basic_Map","text":"ggmapcn package provides various tools visualizing geographic data China beyond. vignette demonstrates basic advanced usage geom_mapcn() geom_world() plotting administrative boundaries combining geographic data.","code":""},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Basic_Map.html","id":"example-1-basic-map-of-china","dir":"Articles","previous_headings":"","what":"Example 1: Basic Map of China","title":"Adding_Basic_Map","text":"plot map China province boundaries, use geom_mapcn() function. map uses Azimuthal Equal Distance projection default.","code":"ggplot() + geom_mapcn() + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Basic_Map.html","id":"example-2-adding-buffer-zones-and-coastlines","dir":"Articles","previous_headings":"","what":"Example 2: Adding Buffer Zones and Coastlines","title":"Adding_Basic_Map","text":"’s comprehensive example demonstrating plot province boundaries, buffer zones, coastlines map:","code":"ggplot() + geom_buffer_cn(mainland_dist = 40000) + geom_buffer_cn(mainland_dist = 20000, fill = \"#BBB3D8\") + geom_mapcn(fill = \"white\") + geom_boundary_cn() + theme_bw()"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Basic_Map.html","id":"example-3-overlaying-china-on-a-world-map","dir":"Articles","previous_headings":"","what":"Example 3: Overlaying China on a World Map","title":"Adding_Basic_Map","text":"geom_world() function allows visualize global data, geom_mapcn() overlays China detailed analysis.","code":"# Define projections china_proj <- \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\" # Combine world map as a background and China map as overlay ggplot() + # World map as background geom_world(fill = \"gray90\", color = \"gray70\", linewidth = 0.2) + coord_proj( crs = \"+proj=merc\", xlim = c(-180, 180), ylim = c(-90, 90) ) + # Overlay China map geom_mapcn( fill = \"lightblue\", color = \"black\", linewidth = 0.5 ) + geom_boundary_cn(color = \"red\", linewidth = 0.6) + theme_minimal() #> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE #> Coordinate system already present. Adding new coordinate system, which will #> replace the existing one. #> Warning: Duplicated aesthetics after name standardisation: colour and linewidth #> Duplicated aesthetics after name standardisation: colour and linewidth #> Duplicated aesthetics after name standardisation: colour and linewidth #> Duplicated aesthetics after name standardisation: colour and linewidth #> Duplicated aesthetics after name standardisation: colour and linewidth"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Basic_Map.html","id":"example-4-filtering-china-and-its-neighbors","dir":"Articles","previous_headings":"","what":"Example 4: Filtering China and Its Neighbors","title":"Adding_Basic_Map","text":"example demonstrates filtering China neighboring countries, highlighting China red.","code":"# Define neighboring countries china_neighbors <- c(\"CHN\", \"AFG\", \"BTN\", \"MMR\", \"LAO\", \"NPL\", \"PRK\", \"KOR\", \"KAZ\", \"KGZ\", \"MNG\", \"IND\", \"BGD\", \"TJK\", \"PAK\", \"LKA\", \"VNM\") # Plot world map with filtered countries ggplot() + geom_world(fill = \"gray90\", color = \"gray70\", linewidth = 0.2) + geom_world( filter = china_neighbors, filter_attribute = \"SOC\", fill = \"lightblue\", color = \"black\", linewidth = 0.5 ) + geom_world( filter = \"CHN\", filter_attribute = \"SOC\", fill = \"red\", color = \"black\", linewidth = 0.8 ) + coord_proj( crs = \"+proj=merc\", xlim = c(60, 140), ylim = c(-10, 60) ) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Adding_Spatial_Data","text":"vignette introduces two functions ggmapcn package: geom_loc geom_vege_raster. functions extend capabilities package spatial data visualization.","code":""},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"geom_loc-adding-spatial-point-data-layer-with-color-by-grouping","dir":"Articles","previous_headings":"","what":"geom_loc: Adding Spatial Point Data Layer with Color by Grouping","title":"Adding_Spatial_Data","text":"geom_loc function allows add spatial point data ggplot, supporting sf tabular data frames, color mapping based grouping variable.","code":"# Create a ggplot with spatial points colored by 'Category' set.seed(123) data_sim <- data.frame( Longitude = runif(100, 80, 120), Latitude = runif(100, 28, 40), Category = sample(c(\"Type A\", \"Type B\", \"Type C\"), 100, replace = TRUE) ) ggplot() + geom_boundary_cn() + geom_loc( data = data_sim, lon = \"Longitude\", lat = \"Latitude\", mapping = aes(color = Category), size = 1, alpha = 0.7 ) + theme_bw()"},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"basemap_vege-vegetation-map-of-china-layer-for-ggplot2","dir":"Articles","previous_headings":"","what":"basemap_vege: Vegetation Map of China Layer for ggplot2","title":"Adding_Spatial_Data","text":"basemap_vege function adds vegetation raster map China color-coded vegetation types ggplot.","code":"# Add vegetation raster of China to a ggplot ggplot() + basemap_vege() + guides(fill = guide_none()) + theme_bw() #> resampled to 1000776 cells. #> Warning: Removed 715308 rows containing missing values or values outside the scale range #> (`geom_raster()`)."},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"basemap_dem-elevation-map-of-china-layer-for-ggplot2","dir":"Articles","previous_headings":"","what":"basemap_dem: Elevation Map of China Layer for ggplot2","title":"Adding_Spatial_Data","text":"basemap_dem function adds digital elevation model (DEM) raster map China layer ggplot2.","code":"# Apply Azimuthal Equidistant projection centered on China 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() + theme(legend.position = \"bottom\") #> Warning: [vect] returning polygons ignoring additional geometry types. Use #> 'svc' to get all geometries #> resampled to 1000968 cells."},{"path":"https://rimagination.github.io/ggmapcn/articles/Adding_Spatial_Data.html","id":"coord_proj-transforming-limits-for-custom-projections","dir":"Articles","previous_headings":"","what":"coord_proj: Transforming Limits for Custom Projections","title":"Adding_Spatial_Data","text":"coord_proj function wrapper around coord_sf allows specify map limits (xlim, ylim) longitude latitude (WGS84 CRS) automatically transforms specified CRS accurate projections. , Azimuthal Equidistant projection centered China applied, transformed map limits specified longitude latitude.","code":"# World map with Azimuthal Equidistant projection centered on China ggplot() + geom_world(fill = \"lightblue\") + coord_proj( crs = china_proj, xlim = c(60, 140), ylim = c(10, 50) ) + theme_minimal() #> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE"},{"path":"https://rimagination.github.io/ggmapcn/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Liang Ren. Author, maintainer.","code":""},{"path":"https://rimagination.github.io/ggmapcn/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Ren L (2024). ggmapcn: Customizable China Map Visualizations. R package version 0.0.2, https://rimagination.github.io/ggmapcn.","code":"@Manual{, title = {ggmapcn: Customizable China Map Visualizations}, author = {Liang Ren}, year = {2024}, note = {R package version 0.0.2}, url = {https://rimagination.github.io/ggmapcn}, }"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"ggmapcn","dir":"","previous_headings":"","what":"Customizable China Map Visualizations","title":"Customizable China Map Visualizations","text":"ggmapcn ggplot2 extension package visualizing China’s map customizable projections styling. package includes province-level map data supports adding mainland borders, coastlines, buffer areas, making easy create geographic visualizations China.","code":""},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Customizable China Map Visualizations","text":"Install development version ggmapcn GitHub :","code":"# install.packages(\"devtools\") devtools::install_github(\"Rimagination/ggmapcn\", force = TRUE)"},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"plotting-a-map-of-china","dir":"","previous_headings":"","what":"Plotting a Map of China","title":"Customizable China Map Visualizations","text":"plot map China province boundaries, use geom_mapcn():","code":"library(ggplot2) library(ggmapcn) ggplot() + geom_mapcn() + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"custom-projection-and-styling","dir":"","previous_headings":"","what":"Custom Projection and Styling","title":"Customizable China Map Visualizations","text":"want try Albers projection, can customize .","code":"ggplot() + geom_mapcn(crs = \"+proj=aea +lat_1=25 +lat_2=47 +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs\", color = \"black\", fill = \"white\", size = 0.7) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"adding-mainland-borders-and-coastlines","dir":"","previous_headings":"","what":"Adding Mainland Borders and Coastlines","title":"Customizable China Map Visualizations","text":"Use geom_boundary_cn() add mainland borders coastlines map. can set colors line widths mainland coastline boundaries:","code":"ggplot() + geom_mapcn(fill = NA) + geom_boundary_cn( mainland_color = \"black\", mainland_size = 0.5, coastline_color = \"skyblue\", coastline_size = 0.5 ) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"adding-buffer-zones","dir":"","previous_headings":"","what":"Adding Buffer Zones","title":"Customizable China Map Visualizations","text":"geom_buffer_cn() function adds buffer zones around China’s borders. can specify buffer distances, colors, projections. example shows buffer zones varying distances:","code":"ggplot() + geom_buffer_cn(mainland_dist = 40000) + geom_buffer_cn(mainland_dist = 20000, fill = \"#BBB3D8\") + geom_mapcn(fill = \"white\") + geom_boundary_cn() + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/index.html","id":"data-source","dir":"","previous_headings":"","what":"Data Source","title":"Customizable China Map Visualizations","text":"data used package sourced Tianditu (https://cloudcenter.tianditu.gov.cn/administrativeDivision/), reliable provider province-, city-, county-level boundary information China. administrative division data processed GeoJSON format seamless integration package, enabling easy access visualization.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":null,"dir":"Reference","previous_headings":"","what":"Elevation Map of China Layer for ggplot2 — basemap_dem","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"basemap_dem adds digital elevation model (DEM) raster map China layer ggplot2. function ensures output map remains rectangular, regardless chosen projection. supports displaying DEM either within China's boundary larger rectangular area around China.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"","code":"basemap_dem( crs = NULL, within_china = FALSE, maxcell = 1e+06, na.rm = FALSE, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"crs Coordinate reference system (CRS) projection. Defaults CRS DEM data. Users can specify CRS strings (e.g., \"EPSG:4326\" custom projections). within_china Logical. TRUE, displays DEM within China's boundary. FALSE, displays DEM larger rectangular area around China. Default FALSE. maxcell Maximum number cells rendering (improve performance). Defaults 1e6. na.rm Logical. TRUE, removes missing values. Default FALSE. ... Additional parameters passed geom_spatraster.","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_dem.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Elevation Map of China Layer for ggplot2 — basemap_dem","text":"","code":"# Define Azimuthal Equidistant projection centered on China china_proj <- \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\" # Example 1: Display full rectangular area around China 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() #> resampled to 1001810 cells. # Example 2: Display only China's DEM and boundaries 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() #> Warning: [vect] returning polygons ignoring additional geometry types. Use 'svc' to get all geometries #> resampled to 1000968 cells."},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":null,"dir":"Reference","previous_headings":"","what":"Vegetation Map of China Layer for ggplot2 — basemap_vege","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"Adds vegetation raster map China ggplot2 plot, color-coded vegetation types.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"","code":"basemap_vege( color_table = NULL, crs = NULL, maxcell = 1e+06, use_coltab = TRUE, na.rm = FALSE, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"color_table data frame containing vegetation types corresponding colors. columns \"code\" (raster values), \"type\" (vegetation names), \"col\" (hex color codes). NULL, default color table based standard vegetation classifications China used. crs character string specifying coordinate reference system projection. NULL, default projection \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\" applied. maxcell integer indicating maximum number cells rendering improve performance. Defaults 1e6. use_coltab logical value indicating whether use color table raster values. Default TRUE. na.rm logical value indicating whether remove missing values. Default FALSE. ... Additional parameters passed geom_spatraster.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"ggplot2 layer object representing vegetation map China.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"references","dir":"Reference","previous_headings":"","what":"References","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"Zhang X, Sun S, Yong S, et al. (2007). Vegetation map People's Republic China (1:1000000). Geology Publishing House, Beijing.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/basemap_vege.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Vegetation Map of China Layer for ggplot2 — basemap_vege","text":"","code":"if (FALSE) { # \\dontrun{ # Add vegetation raster of China to a ggplot ggplot() + basemap_vege() + theme_minimal() # Customize color table custom_colors <- data.frame( code = 0:11, type = c( \"Non-vegetated\", \"Needleleaf forest\", \"Needleleaf and broadleaf mixed forest\", \"Broadleaf forest\", \"Scrub\", \"Desert\", \"Steppe\", \"Grassland\", \"Meadow\", \"Swamp\", \"Alpine vegetation\", \"Cultivated vegetation\" ), col = c( \"#8D99B3\", \"#97B555\", \"#34BF36\", \"#9ACE30\", \"#2EC6C9\", \"#E5CE0E\", \"#5BB1ED\", \"#6494EF\", \"#7AB9CB\", \"#D97A80\", \"#B87701\", \"#FEB780\" ) ) ggplot() + basemap_vege(color_table = custom_colors) + labs(fill = \"Vegetation type group\") + theme_minimal() } # }"},{"path":"https://rimagination.github.io/ggmapcn/reference/coord_proj.html","id":null,"dir":"Reference","previous_headings":"","what":"Coordinate System with Transformed Limits for Custom Projections — coord_proj","title":"Coordinate System with Transformed Limits for Custom Projections — coord_proj","text":"coord_proj wrapper around ggplot2::coord_sf(). simplifies specifying map limits (xlim, ylim) longitude latitude (WGS84 CRS) automatically transforms specified CRS accurate projections. function extends functionality coord_sf() seamlessly handle user-specified geographic boundaries projection, ensuring accurate mapping.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/coord_proj.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Coordinate System with Transformed Limits for Custom Projections — coord_proj","text":"","code":"coord_proj( crs = NULL, xlim = NULL, ylim = NULL, expand = TRUE, default_crs = \"EPSG:4326\", ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/coord_proj.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coordinate System with Transformed Limits for Custom Projections — coord_proj","text":"crs character string specifying coordinate reference system (CRS) projection (e.g., \"EPSG:4326\" custom projections like \"+proj=merc\"). xlim Longitude range (degrees) display, numeric vector length 2. ylim Latitude range (degrees) display, numeric vector length 2. expand Logical, whether expand plot limits. Default TRUE. default_crs character string specifying CRS input xlim ylim. Default \"EPSG:4326\". ... Additional arguments passed ggplot2::coord_sf().","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/coord_proj.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coordinate System with Transformed Limits for Custom Projections — coord_proj","text":"ggplot2 coord_sf object transformed limits.","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/reference/coord_proj.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Coordinate System with Transformed Limits for Custom Projections — coord_proj","text":"","code":"# World map with default projection and limits ggplot() + geom_world() + coord_proj( crs = \"+proj=longlat +datum=WGS84\", xlim = c(-180, 180), ylim = c(-90, 90), expand=FALSE ) + theme_minimal() #> Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE # Focused view with Azimuthal Equidistant projection china_proj <- \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\" ggplot() + geom_world(fill = \"lightblue\") + coord_proj( crs = china_proj, xlim = c(60, 140), ylim = c(-10, 50) ) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Boundaries of China — geom_boundary_cn","title":"Plot Boundaries of China — geom_boundary_cn","text":"Draws various types boundaries China, including mainland boundaries, coastlines, ten-segment line, special administrative region (SAR) boundaries, undefined boundaries. boundary type can customized terms color, line width, line type. function also allows optional addition compass scale bar.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Boundaries of China — geom_boundary_cn","text":"","code":"geom_boundary_cn( crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", compass = FALSE, scale = FALSE, mainland_color = \"black\", mainland_size = 0.5, mainland_linetype = \"solid\", coastline_color = \"blue\", coastline_size = 0.3, coastline_linetype = \"solid\", ten_segment_line_color = \"black\", ten_segment_line_size = 0.5, ten_segment_line_linetype = \"solid\", SAR_boundary_color = \"grey\", SAR_boundary_size = 0.5, SAR_boundary_linetype = \"dashed\", undefined_boundary_color = \"black\", undefined_boundary_size = 0.5, undefined_boundary_linetype = \"longdash\", ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Boundaries of China — geom_boundary_cn","text":"crs Character. Coordinate reference system (CRS) projection. Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". Users can specify CRS strings customize projection (e.g., \"+proj=merc\" Mercator). compass Logical. Whether display compass (north arrow). Default FALSE. set TRUE, default compass (north arrow) ggspatial::north_arrow_fancy_orienteering() added top-left corner. customize compass, use ggspatial::annotation_north_arrow() directly. scale Logical. Whether display scale bar. Default FALSE. set TRUE, default scale bar ggspatial::annotation_scale() added bottom-left corner. customize scale bar, use ggspatial::annotation_scale() directly. mainland_color Character. Color mainland boundary. Default \"black\". mainland_size Numeric. Line width mainland boundary. Default 0.5. mainland_linetype Character. Line type mainland boundary. Default \"solid\". coastline_color Character. Color coastline. Default \"blue\". coastline_size Numeric. Line width coastline. Default 0.3. coastline_linetype Character. Line type coastline. Default \"solid\". ten_segment_line_color Character. Color ten-segment line. Default \"black\". ten_segment_line_size Numeric. Line width ten-segment line. Default 0.5. ten_segment_line_linetype Character. Line type ten-segment line. Default \"solid\". SAR_boundary_color Character. Color SAR boundary. Default \"grey\". SAR_boundary_size Numeric. Line width SAR boundary. Default 0.5. SAR_boundary_linetype Character. Line type SAR boundary. Default \"dashed\". undefined_boundary_color Character. Color undefined boundary. Default \"lightgrey\". undefined_boundary_size Numeric. Line width undefined boundary. Default 0.5. undefined_boundary_linetype Character. Line type undefined boundary. Default \"longdash\". ... Additional parameters passed geom_sf.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Boundaries of China — geom_boundary_cn","text":"ggplot2 layer (list layers) displaying China's multi-segment boundaries specified styles, optionally including compass (north arrow) scale bar.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Boundaries of China — geom_boundary_cn","text":"","code":"if (FALSE) { # \\dontrun{ # Plot China's boundaries with default settings ggplot() + geom_boundary_cn() + theme_minimal() # Plot China's boundaries with a compass and scale bar ggplot() + geom_boundary_cn(compass = TRUE, scale = TRUE) + theme_minimal() # For customized compass or scale bar, use ggspatial directly: ggplot() + geom_boundary_cn() + ggspatial::annotation_north_arrow( location = \"br\", style = ggspatial::north_arrow_minimal() ) + ggspatial::annotation_scale( location = \"tr\", width_hint = 0.3 ) + theme_minimal() } # }"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"function creates ggplot2 layer displaying buffered areas around China's boundaries, including mainland boundary ten-segment line. Buffers user-defined distances generated around boundary, providing flexibility projection appearance.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"","code":"geom_buffer_cn( mainland_dist = 20000, ten_line_dist = NULL, crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", color = NA, fill = \"#D2D5EB\", ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"mainland_dist Numeric. buffer distance (meters) mainland boundary. ten_line_dist Numeric. buffer distance (meters) segment ten-segment line. specified, defaults value mainland_dist. crs Character. coordinate reference system (CRS) projection. Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". Users can specify CRS strings customize projection (e.g., \"+proj=merc\" Mercator). color Character. border color buffer area. Default NA (transparent). fill Character. fill color buffer area. Default \"#D2D5EB\". ... Additional parameters passed geom_sf.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"ggplot2 layer displaying buffered areas around China's boundaries, customizable buffer distances mainland boundary ten-segment line, using specified projection.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot Buffered Layers for China's Boundary — geom_buffer_cn","text":"","code":"if (FALSE) { # \\dontrun{ # Plot buffers with specified distances for mainland and ten-segment line ggplot() + geom_buffer_cn( mainland_dist = 10000, ten_line_dist = 5000 ) + theme_minimal() } # }"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":null,"dir":"Reference","previous_headings":"","what":"Visualize Spatial Point Data — geom_loc","title":"Visualize Spatial Point Data — geom_loc","text":"geom_loc wrapper around ggplot2::geom_sf() designed visualizing spatial point data. supports sf objects tabular data frames longitude latitude columns, automatically transforming specified coordinate reference system (CRS).","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Visualize Spatial Point Data — geom_loc","text":"","code":"geom_loc( data, lon = NULL, lat = NULL, crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", mapping = aes(), ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Visualize Spatial Point Data — geom_loc","text":"data data frame, tibble, sf object containing spatial point data. lon character string. name longitude column data (required data tabular). lat character string. name latitude column data (required data tabular). crs character string. target coordinate reference system (CRS) data. Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". mapping Aesthetic mappings created ggplot2::aes(), color size. ... Additional parameters passed ggplot2::geom_sf(), size, alpha, color.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Visualize Spatial Point Data — geom_loc","text":"ggplot2 layer visualizing spatial point data.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Visualize Spatial Point Data — geom_loc","text":"function simplifies process visualizing spatial data ggplot2 automatically handling CRS transformations providing interface sf tabular data. input tabular data frame, converted sf object using specified longitude latitude columns. See ggplot2::geom_sf() details additional parameters aesthetics.","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_loc.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Visualize Spatial Point Data — geom_loc","text":"","code":"# Generate a random dataset with latitude and longitude set.seed(123) data_sim <- data.frame( Longitude = runif(100, 80, 120), Latitude = runif(100, 28, 40), Category = sample(c(\"Type A\", \"Type B\", \"Type C\"), 100, replace = TRUE) ) # Visualize the data with China's boundaries ggplot() + geom_boundary_cn() + geom_loc( data = data_sim, lon = \"Longitude\", lat = \"Latitude\", mapping = aes(color = Category), size = 1, alpha = 0.7 ) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot China Map with Customizable Options — geom_mapcn","title":"Plot China Map with Customizable Options — geom_mapcn","text":"geom_mapcn provides flexible interface visualizing China's administrative boundaries. Users can select administrative levels (province, city, county), apply custom projections, filter specific regions.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot China Map with Customizable Options — geom_mapcn","text":"","code":"geom_mapcn( data = NULL, admin_level = \"province\", crs = \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\", color = \"black\", fill = \"white\", linewidth = 0.5, filter_attribute = NULL, filter = NULL, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot China Map with Customizable Options — geom_mapcn","text":"data sf object containing China's map data. NULL, function loads package's default map. Users can select provincial, municipal, county-level maps using admin_level parameter. admin_level character string specifying administrative level map. Options \"province\" (default), \"city\", \"county\". corresponding GeoJSON files (China_sheng.geojson, China_shi.geojson, China_xian.geojson) must located package's extdata folder. crs Coordinate Reference System (CRS). Defaults \"+proj=aeqd +lat_0=35 +lon_0=105 +ellps=WGS84 +units=m +no_defs\". Users can specify CRS strings (e.g., \"EPSG:4326\"). color Border color. Default \"black\". fill Fill color. Default \"white\". linewidth Line width borders. Default 0.5. filter_attribute Column name filtering regions (e.g., \"name_en\"). filter Character vector values filter specific regions (e.g., c(\"Beijing\", \"Shanghai\")). ... Additional parameters passed geom_sf.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot China Map with Customizable Options — geom_mapcn","text":"ggplot2 layer visualizing China's administrative boundaries.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_mapcn.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot China Map with Customizable Options — geom_mapcn","text":"","code":"# Plot provincial map ggplot() + geom_mapcn() + theme_minimal() # Filter specific provinces ggplot() + geom_mapcn(filter_attribute = \"name_en\", filter = c(\"Beijing\", \"Shanghai\"), fill = \"red\") + theme_minimal() # Use a Mercator projection ggplot() + geom_mapcn(crs = \"+proj=merc\", linewidth = 0.7) + theme_minimal()"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot World Map with Customizable Options — geom_world","title":"Plot World Map with Customizable Options — geom_world","text":"geom_world wrapper around ggplot2::geom_sf() designed visualizing world maps added flexibility. allows custom projections, filtering specific countries regions, detailed aesthetic customizations borders fills.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot World Map with Customizable Options — geom_world","text":"","code":"geom_world( data = NULL, crs = \"+proj=longlat +datum=WGS84\", color = \"black\", fill = \"white\", linewidth = 0.5, filter_attribute = \"SOC\", filter = NULL, ... )"},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot World Map with Customizable Options — geom_world","text":"data sf object containing world map data. NULL, function loads package's default world.geojson dataset. crs character string. target coordinate reference system (CRS) map projection. Defaults \"+proj=longlat +datum=WGS84\". color character string specifying border color administrative boundaries. Default \"black\". fill character string specifying fill color administrative areas. Default \"white\". linewidth numeric value specifying line width administrative boundaries. Default 0.5. filter_attribute character string specifying column name use filtering countries regions. Default \"SOC\", refers ISO 3166-1 alpha-3 country code default dataset. filter character vector specifying values filter specific countries regions. Default NULL. ... Additional parameters passed ggplot2::geom_sf(), size, alpha, lty.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot World Map with Customizable Options — geom_world","text":"ggplot2 layer world map visualization.","code":""},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot World Map with Customizable Options — geom_world","text":"geom_world simplifies process creating world maps combining functionality geom_sf user-friendly options projections, filtering, custom styling. Key features include: Custom projections: Easily apply CRS map. Filtering attributes: Quickly focus specific countries regions. Flexible aesthetics: Customize fill, borders, transparency, visual properties.","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/reference/geom_world.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Plot World Map with Customizable Options — geom_world","text":"","code":"# Plot the default world map ggplot() + geom_world() + theme_minimal() # Apply Mercator projection ggplot() + geom_world(crs = \"+proj=merc\") + theme_minimal() # Filter specific countries (e.g., China and its neighbors) china_neighbors <- c(\"CHN\", \"AFG\", \"BTN\", \"MMR\", \"LAO\", \"NPL\", \"PRK\", \"KOR\", \"KAZ\", \"KGZ\", \"MNG\", \"IND\", \"BGD\", \"TJK\", \"PAK\", \"LKA\", \"VNM\") ggplot() + geom_world(filter = china_neighbors) + theme_minimal() # Background map + Highlight specific region ggplot() + geom_world(fill = \"gray80\", color = \"gray50\", alpha = 0.5) + geom_world(filter = c(\"CHN\"), fill = \"red\", color = \"black\", linewidth = 1.5) + theme_minimal() # Customize styles with transparency and bold borders ggplot() + geom_world(fill = \"lightblue\", color = \"darkblue\", linewidth = 1, alpha = 0.8) + theme_void()"},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"new-features-0-0-2","dir":"Changelog","previous_headings":"","what":"New Features","title":"ggmapcn 0.0.2","text":"Introduced basemap_dem() visualizing elevation data customizable projections. Introduced basemap_vege() visualizing vegetation data China customizable projections. Introduced geom_world() visualizing global administrative divisions.","code":""},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"bug-fixes-0-0-2","dir":"Changelog","previous_headings":"","what":"Bug Fixes","title":"ggmapcn 0.0.2","text":"Replaced size linewidth align latest ggplot2 standards.","code":""},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"enhancements-0-0-2","dir":"Changelog","previous_headings":"","what":"Enhancements","title":"ggmapcn 0.0.2","text":"Improved styling options various boundaries geom_boundary_cn().","code":""},{"path":[]},{"path":"https://rimagination.github.io/ggmapcn/news/index.html","id":"initial-release-0-0-1","dir":"Changelog","previous_headings":"","what":"Initial Release","title":"ggmapcn 0.0.1","text":"Added basic functionality creating customized maps China. Integrated seamless support ggplot2. Included administrative boundary datasets provinces, cities, counties.","code":""}] diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 118e310..9ea0d36 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -8,6 +8,7 @@ https://rimagination.github.io/ggmapcn/news/index.html https://rimagination.github.io/ggmapcn/reference/basemap_dem.html https://rimagination.github.io/ggmapcn/reference/basemap_vege.html +https://rimagination.github.io/ggmapcn/reference/coord_proj.html https://rimagination.github.io/ggmapcn/reference/geom_boundary_cn.html https://rimagination.github.io/ggmapcn/reference/geom_buffer_cn.html https://rimagination.github.io/ggmapcn/reference/geom_loc.html diff --git a/vignettes/Adding_Basic_Map.Rmd b/vignettes/Adding_Basic_Map.Rmd index da795f9..b0ab325 100644 --- a/vignettes/Adding_Basic_Map.Rmd +++ b/vignettes/Adding_Basic_Map.Rmd @@ -72,7 +72,7 @@ ggplot() + theme_minimal() ``` -## Example 3: Filtering China and Its Neighbors +## Example 4: Filtering China and Its Neighbors This example demonstrates filtering for China and its neighboring countries, highlighting China in red.