the inconsistency in ggplot when adding points to sf maps

The inconsistent behavior is due to different projections for each shapefile. You typically need to supply the point locations that match the units of the projection you are using. You could either convert the points to your shapefile’s projection, or, if you don’t care if the data are in a geographic coordinate system, you can convert to 4326 which is lat/long on WGS84 datum.

Method 1: Maintaining your shapefile’s projection. This method will convert your point(s) to a spatial sf data type, so you can just plot with geom_sf.

pts <- st_point(c(-70.67, -33.45)) %>% st_sfc() %>% st_as_sf(crs=st_crs(4326))

ggplot(data = shapefile) +
  geom_sf() +
  geom_sf(data = pts, size = 10, colour = "red")

Method 2: Converting the shapefile to EPSG 4326.

ggplot(data = shapefile %>% st_transform(st_crs(4326))) +
  geom_sf() +
  geom_point(x = -70.67,y =-33.45, size = 10, colour = "red")

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top