I have a script that takes in lot, long values (in decimal degrees) and determines whether the points are contained within a polygon in another feature class. I assume I have to create a point object and get it into the same coordinate system as the polygon, but the projection comes back empty (no points). I don't fully understand all the ins and outs of projections so hopefully I'm doing something obviously incorrect here.
x = -88.155675
y = 43.223869
f_cs = 'WGS 1984 Web Mercator (auxiliary sphere)'
t_cs = 'NAD 1983 UTM Zone 16N'
xform = 'WGS_1984_(ITRF00)_To_NAD_1983'
pt = arcpy.Point(x,y)
pg = arcpy.PointGeometry(pt, arcpy.SpatialReference(f_cs))
pgp = pg.projectAs(t_cs, xform)
print (pgp.firstPoint)
Solved! Go to Solution.
you x, y aren't in web mercator,
x = -88.155675
y = 43.223869
sr = arcpy.SpatialReference(4326)
t_cs = 'NAD 1983 UTM Zone 16N'
xform = 'WGS_1984_(ITRF00)_To_NAD_1983'
pt = arcpy.Point(x,y)
pg = arcpy.PointGeometry(pt, sr)
srto = arcpy.SpatialReference('NAD 1983 UTM Zone 16N')
pgp = pg.projectAs(srto, xform)
pgp.firstPoint
<Point (406145.6122366393, 4786322.940660958, #, #)>
pt
<Point (-88.155675, 43.223869, #, #)>
seems to work
you x, y aren't in web mercator,
x = -88.155675
y = 43.223869
sr = arcpy.SpatialReference(4326)
t_cs = 'NAD 1983 UTM Zone 16N'
xform = 'WGS_1984_(ITRF00)_To_NAD_1983'
pt = arcpy.Point(x,y)
pg = arcpy.PointGeometry(pt, sr)
srto = arcpy.SpatialReference('NAD 1983 UTM Zone 16N')
pgp = pg.projectAs(srto, xform)
pgp.firstPoint
<Point (406145.6122366393, 4786322.940660958, #, #)>
pt
<Point (-88.155675, 43.223869, #, #)>
seems to work
That's it! I must have tried a hundred combinations and at some point I was using 4326 but must have had something else off at that point. Thanks Dan!