I have a point shapefile with over 3000 points that are updated frequently, when they are updated they need to have their lat/longs changed which is entered into the attribute table.
When the lat/longs are updated in the attribute table I notice that the feature does not actually change its position in correlation to the new lat/long entered in the attribute table.
Is there a way to make this happen in ArcView with out having to re-export the attribute table out as a dbf, add it to the map then display xy data?
Answer
It sounds like you're updating some attributes of your features instead of updating the actual geometry. You can make changes to a feature's geometry using python but it's a couple extra lines of code. Check out this example:
import arcpy
shapeName = arcpy.Describe('c:/path/to/shp/update_geom.shp').shapeFieldName
rows = arcpy.UpdateCursor(r'c:/path/to/shp/update_geom.shp')
row = rows.next() # just one row...you could iterate through all rows
pnt = arcpy.Point(row.getValue(shapeName).getPart(0).X + 0.5, row.getValue(shapeName).getPart(0).Y + 0.5)
row.setValue(shapeName, pnt)
rows.updateRow(row)
del rows
That only updates one row but demonstrates how to update a point feature's geometry.
**Added code that loops over all rows.
import arcpy
shapeName = arcpy.Describe('c:/path/to/shp/update_geom.shp').shapeFieldName
rows = arcpy.UpdateCursor(r'c:/path/to/shp/update_geom.shp')
for row in rows:
row = rows.next()
pnt = arcpy.Point(row.getValue(shapeName).getPart(0).X + 0.5, row.getValue(shapeName).getPart(0).Y + 0.5)
row.setValue(shapeName, pnt)
rows.updateRow(row)
del rows
No comments:
Post a Comment