Web Analytics Made Easy -

Node Dangles


During a process I was working on, I needed to compare a feature class before and after some edits. I did not quickly find anything in ArcToolbox but searching ArcResources led me to Change Detector script by Bruce Harold. After making a couple of tweaks–for some reason in one of my feature classes, the Shape field had an upper case ‘S’ and in the other it was a lower case ’s'.
I was making an edit (adding leading ‘0’s) to a coded-value domain in an SDE database and realized that my edits were changing the order of the rows of my domain. Rows were moved to the bottom of the list when they were edited. So I went through the process of converting my domain back to a table, made my edits in Access and exported the rows to a .dbf in the order I wanted them.
One of the things I had not gotten around to doing in ArcGIS 10 was figure out how to directly manipulate the geometry of a record using the Field Calculator. When I stumbled upon a bug in the way the Extract Values to Points tool handles Null geometries, I figured it was time to figure it out. Setting the X, Y to 0,0 was sufficient for my needs. I set the Parser to Python and the formula was simple once I figured out the syntax:
I have been loading existing raster data into a geodatabase to be included in a new Mosaic Dataset–a very cool and useful addition to ArcGIS 10. The most time-consuming part of the process for the human (at least this human) has been getting the names of the rasters right. Our existing data is organized by tiles with the directory name representing the tile name and then the data within each tile directory having the same name.
Updating some python code from 9.3 that using geoprocessing to 10.0 using arcpy and the first real object I’ve had to change relates to detecting whether or not an index exists on a table. I previously posted code using a 9.3 geoprocessing commands, the core of it being: indexList = gp.listindexes(tablename) for iIndex in indexList: if (iIndex.Name == indexname): return True return False With arcpy, ESRI has gone back to using the Describe methodology.
Ever since the ever-popular post, Zipping a shapefile using python, came out, people have been asking (one person, yesterday) for a sample of how to zip a file geodatabase using python. The key trick, as shown in line 17, is appending the basename of the file geodatabase (‘nfg.gdb/’ in my example) in front of each file as you write it to the zipfile. UPDATE: WordPress messes with the spacing when I post code, making it difficult to post code that can just be copied & pasted and have work.
Related to my post on how I enable a script to accept parameters from different sources, I also often set up pythons scripts to output information a variety of ways. This is largely due to the fact that some are called by ArcToolbox scripts. Running in ESRI’s domain, these scripts need to send the output through the arcgisscripting object but if you are running the python outside the ArcGIS framework, you can just print.
UPDATE: After receiving a request to modify the code to ignore .lock files, I have an updated to this post.  I’ve received a request on how to use the Zip Shapefile code I posted last week from ArcGIS. Sorry, I did not set the code up to call directly from ArcGIS but only as an illustration of how it can be done. I have, however, with some minor tweaking, made a version that can added to ArcToolbox.
Since I use python for different tasks, I launch python scripts a variety of ways. Depending on what I am doing, a single script may need to accept parameters from either: Passed in from an ArcGIS Toolbox Tool. Re-occurring default value. Often used in scheduled processes, a nightly backup, for example. A temporary set of values used in an interactive, debugging session. What I often do is make the parameter interpretation flexible to meet my needs.
UPDATE: After receiving a request to modify the code to ignore .lock files, I have an updated to this post. One of the tasks I’ve been automating is publishing a weekly data update to a website. The update consists of shapefile. The trouble with shapefiles is they consist of 3 or more files with the same basename but different extensions in the same directory. Not an overly complicated situation but a common one that ArcGIS does not have a solution out-of-the-box.