8

I have coordinates, all of which should be located in DC, but I cannot figure out how to convert them from NAD 83 to latitude and longitude in R. I'm using the spTransform() function in the rgdal package and get an error about non-conformant data.

library(rgdal)
nad83_coords <- data.frame(x=c(396842.6, 397886.9, 398315.5, 398154.3, 398010.3), y=c(140887.1, 139847.0, 138743.9, 139534.5, 138697.3))
coordinates(nad83_coords) <- c('x', 'y')
proj4string(nad83_coords) <- CRS("+init=epsg:4269")
Error in `proj4string<-`(`*tmp*`, value = <S4 object of class "CRS">) : 
  Geographical CRS given to non-conformant data: 398315.5 140887.1

Other combinations of proj4strings yield the same error. I believe the error is because the coordinates are too large, but I'm not sure why that would be. The documentation for the coordinates is below:

Values are in the Maryland State Plane meters NAD 83 map projection.

I'm very new to mapping and projections, and any help is appreciated.

Erik Shilts
  • 4,389
  • 2
  • 26
  • 51

1 Answers1

6

Look up espg:4269:

http://spatialreference.org/ref/epsg/4269/

and its a lat-long system. So your big numbers (which are metres) are way too big.

If you've got a shapefile anywhere with data in these coordinates then you might have a .prj file with it that will have the projection spec, otherwise you'll have to chase it on spatialreference.org:

http://spatialreference.org/ref/?search=nad83+maryland&srtext=Search

There's assorted variations on NAD83, and there's also 'State plane' here and there. I'm not too sure precisely which is which. The epsg: codes are more standard, then there's a bunch of esri: codes. The sr-org: ones are user-supplied on the site.

The esri code looks closest enough to the text you gave. Lets try:

> proj4string(nad83_coords)=CRS("+init=esri:102285")
> spTransform(nad83_coords,CRS("+init=epsg:4326"))
SpatialPoints:
             x        y
[1,] -77.03642 38.93586
[2,] -77.02437 38.92650
[3,] -77.01942 38.91656
[4,] -77.02128 38.92368
[5,] -77.02294 38.91614

Anywhere near DC? Actually, epsg:2804 and epsg:3559 give the same answers, and are probably more 'standard'...

Spacedman
  • 92,590
  • 12
  • 140
  • 224
  • 1
    Thanks, that's great. To be clear, esri:102285 is the Maryland State Plane for NAD 83 with units in meters, and epsg:4326 is the standard longitude/latitude coordinate system? – Erik Shilts Jul 25 '12 at 13:53
  • 2
    Yup, for some value of 'Standard' :) If you look it up http://spatialreference.org/ref/epsg/4326/ it tells you its what you get from a GPS. There are other standard lat-longs based on other measurements of the flattening of the earth, or different zero meridians etc... – Spacedman Jul 25 '12 at 14:02
  • Thanks for the clear question! Reproducible example, you've done a bit of work yourself, you've given us the error message. – Spacedman Jul 25 '12 at 14:21
  • I cannot reproduce this for the following set of x and y: (1 2262720.70221, 616937.73307). I use proj4string(nad83_coords)=CRS("+init=esri:102271") spTransform(nad83_coords,CRS("+init=epsg:3436")) but it returns wrong answer: 9256140.81716 2171112.70876 – Rotail Sep 14 '16 at 20:53