Mapping in R using latitude and longitude coordinates

I am trying to make a map in R and need some help, I have latitude and longitude coordinates of hotels in China and I want to map them but I can't seem to create a map specific to china and wanted to know if there is a way to fit those coordinates in a map specific to china. I have attached the screenshot of the map I got!

shang3<- pd %>% select(price, longi


tude, latitude, minimum_nights, maximum_nights, amenities)

world <- map_data("world")
world

pd_map <- ggplot() +
geom_map(
data = world, map = world,
aes(long, lat, map_id = region),
color = "white", fill = "lightgray", size = 0.1
) +
geom_point(
data = shang3,
aes(longitude, latitude),
alpha = 0.7
)
pd_map

This solution depends on using a geographic source in the form of a "simple features" object, which is a data frame specialized for geographic information systems.

library(ggplot2)
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.2, PROJ 7.2.1
library(magrittr)
library(spData)
#> To access larger datasets in this package, install the spDataLarge
#> package with: `install.packages('spDataLarge',
#> repos='https://nowosad.github.io/drat/', type='source')`
data("world")
world[140,] %>% st_geometry() %>% ggplot() + geom_sf() + theme_minimal()

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.