Tool to display Lat/Long of vertice

781
2
02-06-2012 12:21 PM
MikeMatthews
New Contributor II
We are in the process of moving our County Section Maps from Coverage to GDB. Years ago, when my coworkers were creating these maps in WorkStation, my boss wrote an AML to identify the latitude/longitude of a given node. The nodes did not have a lat/long stored, so the AML took the county grid X,Y and projects it, and spits out the latitude and longitude. I'm not sure why he needs this, and I honestly don't have experience with python or scripts, but I've been tasked to find or create a tool to do this. Any help or reference materials is greatly appreciated.

Note: I have found that the edit sketch properties window will give me X/Y county grid coordinates of the vertices of a selected arc, but can't find a setting to change it to LAT/LONG coordinates.

Thanks.
Tags (2)
0 Kudos
2 Replies
markdenil
Occasional Contributor III
With AML one could project a text file, which was handy.
However, with arcpy, one can:
identfy the wanted point
use a search cursor to grab the shape object
create a PointGeometry object from the point object and the fc spatial reference
make an in-memory FC with the Point Geometry object
project the in-mem fc (you have to project to an on-disc output fc)
use another search cursor to grab the (projected) point object
pull out its component X and Y positions

This snippit is part of a larger routine, and gets the Lat Long location of a polygon centroid, but it's the same idea...

descObj = arcpy.Describe(inFeatures)
shapeName = descObj.shapeFieldName
spatialRef = descObj.spatialReference
pointGeometryList = []

###     finds polygon centroid in projected meters
rows = arcpy.SearchCursor(inFeatures)
for row in rows:
    polyCent = row.getValue(shapeName).centroid
    pointGeometry = arcpy.PointGeometry(polyCent, spatialRef)
    pointGeometryList.append(pointGeometry)   
del rows

###     creates in memory point feature
if arcpy.Exists(outFeatures): arcpy.Delete_management(outFeatures)
arcpy.CopyFeatures_management(pointGeometryList, outFeatures)

###     projects centoid to WGS84 (must write to FeatClass)
if arcpy.Exists(ddFeatures): arcpy.Delete_management(ddFeatures)
arcpy.Project_management(outFeatures, ddFeatures, ddPrj)

###     find centroid in decimal degrees
descObj = arcpy.Describe(ddFeatures)
shapeName = descObj.shapeFieldName
rows = arcpy.SearchCursor(ddFeatures)
for row in rows:
    longitude = row.getValue(shapeName).centroid.X
    latitude = row.getValue(shapeName).centroid.Y
print str(longitude)
print str(latitude)
del rows
0 Kudos
MikeMatthews
New Contributor II
Very good. Thank you sir.
0 Kudos