Unable to transform an sf object to an sp object due to error with unused argument (SRS_string = from$wkt)

nilesguo

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.

nilesguo

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to plot SP object as SF, in R leaflet

How to Transform string message error in object or array?

How can I transform a SF object into a Spatial Points Data Frame?

Transform a Multipolygon SF object in R from XY coordinates to lat/lon

How to Transform CRS of Map Window and Datapoints to Match SF Object?

Transform string to object in Javascript

Trying to transform this string to an object

Convert String to Object gives error due to double quotes at start and end

Warning: expression result unused when returning an object with a two argument constructor

Sudden "unused argument" error

Overriding with object or string as argument

how to to transform an object to a string php

Transform String into xml object for Request

How to transform string into object by Lodash

Compilation error in Android due to mContext object

Error: "Operation is not valid due to the current state of the object"

Error: TypeError: argument 1 must be a string or unicode object

error: The argument type 'Object?' can't be assigned to the parameter type 'String'

rnaturalearth and sf object

Changing CRS of a SF object

Reorder sf object by column

converting sf object to topojson

transform list of object into object

Transform Yup validation error into a useable object

Exception in unused object

Error when plotting sf object --- Error: could not find function "geom_sf"

Unable to map String to Object

Unable to convert a object to a string

Getting this error: "The argument type 'Object?' can't be assigned to the parameter type 'List<Map<String, Object>>'."