Hello,
You will find a warning that I have when I use the sf
package.
This warning 2 imply a big problem : when I want to plot (X,Y) points in my background.
these points are not plotted on the shape centroid (they have the same crs)
See snapshot
Have you an idea?
> library(dplyr)
> library(sf)
>
> map<-st_read("map.gpkg")
Reading layer `countries' from data source `.../map.gpkg' using driver `GPKG'
Simple feature collection with 232 features and 16 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: -180 ymin: -55.52139 xmax: 180 ymax: 83.59961
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs
>
> pt_centroid<-map %>% sf::st_centroid()
Warning messages:
1: In st_centroid.sf(.) :
st_centroid assumes attributes are constant over geometries of x
2: In st_centroid.sfc(st_geometry(x), of_largest_polygon = of_largest_polygon) :
st_centroid does not give correct centroids for longitude/latitude data
> pts<-sf::st_coordinates(pt_centroid)