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.

I'm looking to update the point geometry of lets say "oldFC" by obtaining the shape geometry of "newFC" and applying that to the "oldFC". I also want it to grab the value in the ID field in "newFC"and use that to search for the same ID in "oldFC" and then set the shape value.

I believe I have the loop set up and it appears to be grabbing the ID just fine but it doesn't update the shape geometry.

I'm very much a beginner with using Python so my code is rough. Any help would be appreciated. Thanks.

Here's the code snippet... running 9.3 (no access to 10):

rows = gp.SearchCursor(newFC):

row = rows.next()


gp.MakeFeatureLayer_management(oldFC, oldLayer, "")
gp.MakeFeatureLayer_management(newFC, newLayer, "")

while row:

newgeo = row.getValue("Shape")
newID = row.getValue("ID")

print newgeo
print newID

where =  "ID" + '= '   + str(newID) #my sql expression

print where

new_rows = gp.UpdateCursor(oldFC, where)
new_row = rows.next()
while new_row:
    new_row.setValue("Shape", newgeo)
    new_rows.UpdateRow(new_row)
    new_row = new_rows.next()
row = rows.next()
share|improve this question
    
9.3, 10, feature class... may I guess this is about that ArcGis thing? –  Nicklas Avén Dec 30 '10 at 5:47
    
Yes, sorry I should have mentioned that. –  amasephy Dec 30 '10 at 12:56
1  
you should take caution using the ESRI id to grab matching features. There are many esri functions on any esri resource which will re-write the FID or OID or other internal esri ObjectID. webhelp.esri.com/arcgiSDEsktop/9.3/… explains some of the basics about oids. and the following from edn edndoc.esri.com/arcobjects/9.2/NET/… –  Brad Nesom Dec 30 '10 at 15:22
    
I actually am using a "managed" ID that is used on the data and not the ESRI id your referring to. But thanks for the heads up. –  amasephy Dec 30 '10 at 16:49

1 Answer 1

up vote 4 down vote accepted

You won't want to use the setValue method to set geometry. It should be:

new_row.shape = newgeo
new_rows.UpdateRow(new_row)
new_row = new_rows.next()
share|improve this answer
    
When I modified that line I get this error AttributeError: 'NoneType' object has no attribute 'Shape' –  amasephy Dec 30 '10 at 14:40
    
A couple of things come to mind. First, try setting newgeo = row.shape in the top part of your script. Second, are you setting your geoprocessor object to run against 9.3 (gp = arcgisscripting.create(9.3))? –  user890 Dec 30 '10 at 15:06
    
the newgeo = row.shape worked perfectly. There is also a typo in my original code.. for new_row = rows.next() it should be new_row = new_rows.next(). Thanks to everyone for the help! –  amasephy Dec 30 '10 at 15:34

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.