[SOLVED] sp::proj4string(obj) : CRS object has comment, which is lost in output in R

Issue

This Content is from Stack Overflow. Question asked by enat_b

I am trying to run this vignette using the SUMMER package on my own data (shapefile of London at the LSOA level). This is how I import the shapefile:

#geo = readOGR(“./LSOA11_London_noclip/LSOA11_London_noclip.shp”)

The vignette works fine until I try to run the part under “We can visualize one or more metrics on the map is by the mapPlot function.” I get the following error :

Warning message: In sp::proj4string(geo) : CRS object has comment,
which is lost in output; in tests, see
https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html

I am aware of this topic, but when I try to import the shapefile with the sf package and rerun, I get another error:

Error in (function (classes, fdef, mtable) : unable to find an
inherited method for function ‘proj4string’ for signature ‘”sf”’

Thank you!



Solution

Use the sf package to read the shapefile:

R> area_dnipro <- sf::read_sf("dnipro.shp")
R> tm_shape(area_dnipro) + tm_polygons()

this does not show the warning.

See also ?tm_shape:

shp: shape object, which is an object from a class defined by the ‘sf’ or ‘stars’ package. Objects from the packages ‘sp’ and ‘raster’ are also supported, but discouraged.


This Question was asked in StackOverflow by Helios and Answered by rcs It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?