Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. import arcpy
  2. ws = arcpy.env.workspace = r"path/to/workspace"
  3. fc = r"path/to/shapefile"
  4. feat_to_points = arcpy.FeatureVerticesToPoints_management (fc, "feat_to_points", "ALL")
  5.  
  6. arcpy.AddField_management (feat_to_points, "Lat", "FLOAT")
  7. arcpy.AddField_management (feat_to_points, "Long", "FLOAT")
  8.  
  9. wgs = arcpy.SpatialReference(4326)
  10. with arcpy.da.UpdateCursor(feat_to_points, ['SHAPE@', 'Lat', 'Long']) as cursor:
  11. for row in cursor:
  12. pnt_wgs = row[0].projectAs(wgs)
  13. row[1:] = [pnt_wgs.centroid.Y, pnt_wgs.centroid.X]
  14. rows.updateRow(row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement