Update existing point geometry to GPS XY via field calculator & python?

10169
15
08-08-2011 02:33 PM
AmyWright_Webber
New Contributor III
Hello -

Thank you in advance for any help you can offer!

I have a topology between a manhole FC and main lines FC set up so that we can manually snap the existing MH to the new GPS points and have the main lines stay attached.  While this works, there are thousands to do and we are looking for a better method.

Using a common manhole ID, I have moved the GPS coordinates into two attribute fields GPS_X and GPS_Y) in the attribute table of the manhole feature class.

Is it possible to update the position of the manhole point with the values in the GPS_X and GPS_Y fields using python and the field calculator (other suggestions welcome)? My hope would be that we could and that the main would follow the "move" of the manhole point due to the topology rules.

I have attached a screen shot showing the GPS points (green), the manholes, and main lines.  The attribute table shown is that of the manholes.

Any other suggestion on how to mass update the locations of the old manholes while moving the attached mains with them would be greatly appreciated!

Sincerely,

Amy
Tags (2)
15 Replies
AlanTonkin
Occasional Contributor
It appears this is a bug, NIM097273.


Hi Jake,

Many thanks for your efforts in helping to resolve this issue. I'm happy to hear that it's a bug and not just something I was doing wrong.

Regards,

Alan
0 Kudos
MathewCoyle
Frequent Contributor
0 Kudos
JeremyJung3
New Contributor

Alan and Jake,

The Python script works great, but unfortunately I have some Null Values in my GPS Data(we had to digitize some data). Is there any way to use the python script you provided and have it leave all Null or blank values alone? When I use the python script it will remove any points with no GPS data thus I'm losing points, any help would be appreciated thank you!

0 Kudos
BlakeTerhune
MVP Regular Contributor

Before you assign the new X and Y values to the point, just check if they have values.

if row.GPS_X and row.GPS_Y:
    # continue processing new XY coordinate
else:
    # handle null XY coordinate values‍‍‍‍‍‍‍‍

EDIT:

Or better yet, use a where_clause parameter to just ignore the null values at the very beginning when creating the cursor.

where_clause = "GPS_X is not null and GPS_Y is not null"‍‍

UpdateCursor—Help | ArcGIS Desktop 

0 Kudos
JeremyJung3
New Contributor

Thanks Blake for the response! But I was wondering how I could write that in a Field Calculator. Currently I'm using this script:

I was wondering how I could write to leave all blank values alone and only calculate points that have a value. Thanks again for any help!

0 Kudos
BlakeTerhune
MVP Regular Contributor

Ah, I see. In this case, it would be easiest to simply select by attributes where GPS_X is not null and GPS_Y is not null then perform the field calc you have and it will only affect the selected records.

0 Kudos