简体   繁体   中英

Mark the center of state in stamen maps

I want to draw a map like the below picture of untitled state and show the center of all state by a colorful circle.

There is google map API which can use in R.But it seems that it's no longer available to use free of charge.

How can I draw this picture by Stamn Maps library in R? If there is a good tutorial about Stamn Maps, I'll appreciate any helps.

在此处输入图片说明

thanks for your answers I find one of the solutions that shows map in r by Stamn Maps

d <- data.frame(lat = state.center$y,
                lon = state.center$x)
#-128.5, 27.5, -69, 49
US <- get_stamenmap(bbox = c(left = -128.5, bottom = 27.5, right =
                               -68, top = 50) ,zoom = 4, maptype = c("terrain",
                                                                                 "terrain-background", "terrain-labels", "terrain-lines", "toner",
                                                                                 "toner-2010", "toner-2011", "toner-background", "toner-hybrid",
                                                                                 "toner-labels", "toner-lines", "toner-lite", "watercolor"),
                    crop = TRUE, messaging = FALSE, urlonly = FALSE,
                    color = c("color", "bw"), force = FALSE, where = tempdir())


p <- ggmap(US, base_layer = ggplot(data = d)) +
  geom_point(aes(x = lon, y = lat), color = "blue", size = 2, alpha = 0.5)
p

A minimal example to kickstart your journey:

set.seed(1702)
points <- data.frame(lon = rnorm(10, -95.4, 0.1),
                     lat = rnorm(10, 29.7, 0.1))

# get_stamenmap() defaults to the map of Houston, TX if there 
# is no boundary box defined in the form of:
# c(lon_min, lat_min, lon_max, lat_max)
# For more information see ?get_stamenmap
ggmap(get_stamenmap()) +
    geom_point(data = points,
               aes(lon, lat), 
               color = "red")

1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM