Search code examples
rgeospatialshapefiler-sprgdal

Is there an R function that can assign a CRS (Coordinate Reference System) to a dataset? Or is it only possible with shapefiles?


I'm working with two geospatial datasets in R. But the coordinates were captured using two different CRS. One dataset used WGS84 and the other used NAD83. Is it at all possible to convert the WGS84 dataset to NAD83 and vice versa? I've heard the sf and rgdal libraries can do this but aren't they exclusive to shapefiles?


Solution

  • This is more a comment but I don't have the rep to comment! If you're using sp class objects like SpatialPointsDataFrame then sp::spTransform will convert reference systems. If you're using sf then you need stTransform. For example, if df is a SpatialPointsDataFrame with NAD84 then to get to WGS84

    df2 <- spTransform(df,CRS("+init=epsg:4326"))
    

    There's a good vignette here here