Reputation: 162
I am currently working on a sf dataset of points in R, and I want to transform that dataset to an SpatialPointsDataFrame for some downstream analysis. This seems easy enough so I use the as_Spatial()
function, but it throws an error that I've never seen before:
Error in sp::CRS(SRS_string = from$wkt) : unused argument (SRS_string = from$wkt)
The object I'm trying to transform is a little large for me to add to the question, but the basic object information is as follows:
Simple feature collection with 1357 features and 10 fields
geometry type: POINT
dimension: XY
bbox: xmin: 2.763816 ymin: 4.292756 xmax: 13.66089 ymax: 13.76644
geographic CRS: WGS 84
I tried to transform the CRS code of the object, thinking it might have a string that the as_Spatial function isn't recognizing. But when I tried to use the st_transform()
function, it doesn't look like it updated the geographic CRS. I guess one workaround is change my workflow upstream so that I don't use sf objects, but that would mean throwing away a lot of prior work and use the less efficient intersect()
function instead of the st_join()
function. If anyone has any idea where I can look to troubleshoot this issue, that would be fantastic. Thank you all.
Upvotes: 1
Views: 1232
Reputation: 162
I did a little more digging and it looked like the CRS for the sf
object was incorrectly set. For some reason when I loaded in the initial shapefile prior to my spatial join, the CRS incorporated a ton of extra information that sf
ended up not able to handle. I used st_crs()
to reset the CRS information and that resolved the issue.
Upvotes: 1