Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

coordinates conversion with pyproj

I am not experienced in gis coordinates conversion but managed, using this page: http://all-geo.org/volcan01010/2012/11/change-coordinates-with-pyproj/ to convert shapefile coordinates from EPSG:28992 to EPSG:4326 using the python module pyproj using these statements:

wgs84=pyproj.Proj("+init=EPSG:4326")
epsg28992=pyproj.Proj("+init=EPSG:28992")
pyproj.transform(epsg28992, wgs84,x,y)

When I reverse and enter these coordinates in google maps they give me correct locations. So this is working fine.

Now I have another shapefile(s) and I look at the shapefile.prj file to determine what projection was used. The ESRI WKT corresponds with ESRI:102686 which I find here: http://epsg.io/102686 As the ESRI:102686 code is not known by pyproj (gives error), I have to use proj4 notation which I got from the same site (http://epsg.io/102686):

wgs84=pyproj.Proj("+init=EPSG:4326") 
esri102686=pyproj.Proj("+proj=lcc +lat_1=41.71666666666667 +lat_2=42.68333333333333 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000.0000000001 +datum=NAD83 +units=us-ft +no_defs")
pyproj.transform(esri102686, wgs84,x,y)

I get e.g. coordinates and use these in google maps: 60.275122729462495, -61.873986125999316 which is somewhere in the ocean...

But my results should be in Cambridge, MA in the US, so more around: 41.00000, -71,5000000

What am I doing wrong?

like image 873
musicformellons Avatar asked Oct 19 '14 16:10

musicformellons


People also ask

What does Epsg 4326 mean?

If you're really going to pick a nit: EPSG 4326 defines a full coordinate reference system, providing spatial meaning to otherwise meaningless pairs of numbers. It means "latitude and longitude coordinates on the WGS84 reference ellipsoid."

What is Pyproj?

Pyproj is an Interface for the cartographic projections and coordinate transformations library (PROJ).

How do you change the projection in Python?

Changing the projection is really easy to do in Geopandas with . to_crs() -function. As an input for the function, you should define the column containing the geometries, i.e. geometry in this case, and a epgs value of the projection that you want to use. Let's see how the coordinates look now.

What is ENU coordinate system?

East-North-Up Coordinates An east-north-up (ENU) system uses the Cartesian coordinates (xEast,yNorth,zUp) to represent position relative to a local origin. The local origin is described by the geodetic coordinates (lat0,lon0,h0). Note that the origin does not necessarily lie on the surface of the ellipsoid.


1 Answers

Solved, added preserve_units = True, like this:

esri102686 = pyproj.Proj("+proj=lcc +lat_1=41.71666666666667 +lat_2=42.68333333333333                +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000.0000000001 +datum=NAD83 +units=us-ft     +no_defs",preserve_units= True)

Now it works fine. If the optional keyword 'preserve_units' is True, the units in map projection coordinates are not forced to be meters. See here.

like image 121
musicformellons Avatar answered Sep 30 '22 11:09

musicformellons