getmap: Get the map data with sf format

View source: R/getmap.R

getmapR Documentation

Get the map data with sf format

Description

Get the map data at province, city or district level

Usage

getmap(adcode, level = "default")

Arguments

adcode

The administrative code

level

The level of map data, including province, city and district

Value

sf data

Examples

## Not run: 
library(ggplot2)
# China map
# (1) China map at province level
china <- getmap(adcode = 100000, level = "province")
ggplot(china) +
  geom_sf(fill = "white") +
  theme_bw()
# (2) China map at city level
china <- getmap(adcode = 100000, level = "city")
ggplot(china) +
  geom_sf(fill = "white") +
  theme_bw()
# (3) China map at district level
china <- getmap(adcode = 100000, level = "district")
ggplot(china) +
  geom_sf(fill = "white") +
  theme_bw()
# (4) missing value in the argment "level"
china4 <- getmap(adcode = 100000)
ggplot(china) +
  geom_sf(fill = "white") +
  theme_bw()

# Sichuan
# (1) map at province level
sichuan <- getmap(adcode = 510000, level = "province")
ggplot(sichuan) +
  geom_sf(fill = "white") +
  theme_bw()
# (2) map at city level
sichuan <- getmap(adcode = 510000, level = "city")
ggplot(sichuan) +
  geom_sf(fill = "white") +
  theme_bw()
# (3) map at district level
sichuan <- getmap(adcode = 510000, level = "district")
ggplot(sichuan) +
  geom_sf(fill = "white") +
  theme_bw()

# Chengdu
# (1) map at city level
chengdu <- getmap(adcode = 510100, level = "city")
ggplot(chengdu) +
  geom_sf(fill = "white") +
  theme_bw()
# (2) fetch and map at district level
chengdu <- getmap(adcode = 510100, level = "district")
ggplot(chengdu) +
  geom_sf(fill = "white") +
  theme_bw()

## End(Not run)

xiaojunlin/amap documentation built on Sept. 29, 2022, 6:35 a.m.