Search code examples
rgisshapefilergdalogr

readOGR not recognizing the projection


OS: Windows

R: 3.5.1

rgdal: 1.3-4

I am having difficulty plotting the Maryland shoreline. I think this is because it is not detecting the projection.

The Maryland shoreline data can be downloaded from https://geodata.md.gov/imap/rest/services/Boundaries/MD_MarineBoundaries/MapServer/exts/MDiMAPDataDownload/customLayers/0.

library(rgdal)
water <- readOGR("~/BNDY_Shoreline_MGS/BNDY_Shoreline_MGS.shp")
summary(water)

Object of class SpatialPolygonsDataFrame
Coordinates:
       min      max
x -8607524 -8348291
y  4563395  4821814
Is projected: TRUE 
proj4string :
[+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs]
Data attributes:
 OBJECTID Id      Shape_area          Shape_len       
 1:1      0:1   Min.   :1.096e+10   Min.   :15758295  
                1st Qu.:1.096e+10   1st Qu.:15758295  
                Median :1.096e+10   Median :15758295  
                Mean   :1.096e+10   Mean   :15758295  
                3rd Qu.:1.096e+10   3rd Qu.:15758295  
                Max.   :1.096e+10   Max.   :15758295  

I was expecting the x and y values to look more like latitude and longitude values. Is there an argument that I missing from the readOGR() call?


Solution

  • It looks like that's the correct projection for the boundary file.

    If you want a different projection, you can reproject the file yourself after reading in to give EPSG 4326 for example:

    water <- spTransform(water, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))