How to update coordinates from excel file

07-20-2016 10:50 PM
Occasional Contributor

I have an excel file of points which are resurveyed with updated Coordinates.Now i want to update my existing arcsde geodatabase. i found this , But my problem is my users are not from  GIS background so i am looking for a python script which they can run.Any help will be grateful

Tags (1)
0 Kudos
2 Replies
Occasional Contributor III

depends how you read an excel file, you can use python xlrd library or use it as if it as a normal table in ArcMap. Anyway just create a dictionary from your excel file,

myUpdatedCoordinates = {PNTID:(X,Y), ......PNTIDn:(Xn,Yn))

the loop thru your featureclass with an updateCursor,

with arcpy.da.UpdateCursor(fc, ['ID', 'SHAPE@']) as cur:
     for row in cur:
          if row[0] in myUpdatedCoordiantes:
               newgeo = arcpy.PointGeometry(arcpy.Point(myUpdatedCoordinates[row[0]][0],myUpdatedCoordinates[row[0]][1]), spatialReference=XXXX)
               row[1] = newgeo
MVP Esteemed Contributor

You mentioned your users aren't GIS savvy, but will they be useing ArcGIS or are you looking for a standalone solution? If within ArcGIS, you may want to create a toolbox/tools that they can use

What is a script tool?—Help | ArcGIS for Desktop

you can then set up the input parameters to promot them for the excel file name and featureclass to use.  The link you provided has the logic laid out, and Thanos Of Titan​ has a good start for the scripting logic. ( I'm not at a Python machine right now to write/test).

if using Desktop, not Pro, you can go one step further and create a Python addin to make it easier for them to load the tools on their own install.  I have a post Tip: Python Addin - getting custom tools/toolbox to work - GPToolDialog​ which has some tips about this to get started.

I will edit this with additional addin links, but saving to prevent iPad from eating my response.    Python addin wizard, download page

What is a Python add-in?—Help | ArcGIS for Desktop