Created
August 26, 2013 16:34
-
-
Save scw/6343532 to your computer and use it in GitHub Desktop.
Compare between ArcGIS and Proj.4 when converting between WGS84 and Mass State Plane.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyproj | |
import arcpy | |
# ArcMap result (meters): | |
# 306,414.514 854,124.573 | |
x = -70.216908 | |
y = 41.930268 | |
# perform projection using pyproj (PROJ.4) | |
p1 = pyproj.Proj(init='epsg:4326') # geographic WGS84 | |
p2 = pyproj.Proj(init='epsg:26986') # Mass State Plane | |
p_x,p_y = pyproj.transform(p1,p2,x,y) | |
# perform projection using Arcpy (PE) | |
sr_wgs84 = arcpy.SpatialReference(4326) | |
sr_msp = arcpy.SpatialReference(26986) | |
point = arcpy.Point(x, y) | |
point_geom = arcpy.PointGeometry(point, sr_wgs84) | |
proj_point = point_geom.projectAs(sr_msp) | |
a_x, a_y = (proj_point.firstPoint.X, proj_point.firstPoint.Y) | |
print """pyproj:\t\tarcpy: | |
{0}\t{1} | |
{2}\t{3}""".format(p_x, a_x, p_y, a_y) |
Author
scw
commented
Aug 26, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment