Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Greetings everyone, quick question regarding lat/longs and updating a point features actual location. 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? Thank you for your help!

share|improve this question
add comment

1 Answer 1

up vote 9 down vote accepted

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
share|improve this answer
    
Yes you hit it right on the nail Swingley, is it possible to make a GP of something that can do this in model builder? It is a task that is repeated very often and it is done one line at a time, usually adding a new point into the shapefile and then attributing it. Also what line of code designates what column to look up the lat long? –  Furlong Oct 27 '10 at 2:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.