Web Analytics Made Easy -
StatCounter

Node Dangles

ArcScripts

One of the great advancements over the last decade plus in GIS is that government agencies have started to move away from a ‘recover-our-cost’ mentality to more of an ‘Open Data’. Minnesota, for example, has launched their Geospatial Commons as a platform for sharing data. And while getting free, authoritative data is awesome, it can leave you in a bind if the structure of the data changes. Sometime between April and September, Hennepin County, Minnesota, changed the schema of their publicly available street centerlines data.
Working on doing some advanced ArcGIS server printing and had the need to batch convert many existing .mxd files to .lyr files. So instead of opening up X number of map documents, thought I would do it via code. All of my .mxds in this case had just one data frame so the process was pretty simple–I add an empty group layer (Thanks Petr Krebs for the idea), copy all the existing layers into it, and save it out as a layer file.
Recently I’ve created Python add-ins for data entry for our staff. Most of these have a toolbar with a ‘Help’ button that opens a help file in .pdf format.Sample python add-in toolbar. The first add-in was for ArcCatalog and this worked splendidly. I was using os.startfile(path to help.pdf). However, when I started doing ArcMap add-ins, clicking the Help button would open the help.pdf but ArcMap would crash. Oops! Luckily the Python development team at Esri already had a blog post about this at their ArcPy Café blog.
I’ve been working on a few different data import routines and one of the things I recently built was the ability to verify that a potential Code to be entered into a field with a Coded Value Domain is valid. The logic of the code is pretty straight-forward. Get a field’s domain and check that a potential value is one of the code values. The biggest ‘trick’ in this code is that arcpy.
In mapping cross sections, our geologists often find themselves renaming their stratigraphic units midway, or at the end, of creating multiple cross sections. This can cause a situation where we need to change multiple values in multiple fields in multiple feature classes–a situation that can get messy very fast. Perfect situation for a quick & dirty arcpy script and, in this case, an ArcToolbox tool that can be downloaded. This tool will change all feature classes in the O:\clay_cga\sand-distribution_model\dnrPackages\stratlines directory.
I was helping a co-worker who needed to check if a field exists in their arcpy script. Since we were located at their computer, I thought I would just do a quick Google search and pull the code off this blog. Seemed logical since I the original purpose was exactly that—to serve as a handy, public place to store code snippets that I use & that others might find handy.
I’ve found that sometimes I can not find the answer to a question until I know the answer & then it becomes ridiculously easy to find the answer. One small annoying thing that I never spent much time was when you delete features from a feature class making it significantly smaller but the envelope does not get re-sized so the zoom extent (still the original extent) is too large. This often happens to use when we convert tables to an XY theme and there are blank records–most of our data shows in Minnesota but there are some in Oklahoma (I think).
Question: How do I get ArcMap to automatically pan through an area. As I mentioned in a previous post, I recently had the need to have ArcMap automatically pan through a project area. My first attempt was to print a series of data-driven pages (using a fishnet polygon layer as the index) this but that did not accomplish what I needed so I switched to arcpy, which made the task simple enough.
Almost a year ago, I updated ERSI’s Domain Sort code for VB 6 to work with ArcGIS 10. Recently, I had a comment that this Add-In caused ArcCatalog to explode if you had an open OLE connection. When I tested it, it turned out the reports were accurate. I got around to adding in a Try-Catch around the offending chunk of code & it is now better than ever. You can download just the Add-In or the Add-In with source code or get it from ESRI’s ArcGIS Resource Center.
One of the common functions I have to do is assign each record in a feature class with a unique identifier–normally just a sequential number from 1 to N. In ArcView 3.x, the formula was simply ‘rec + 1’ if I wanted to start with the number 1. In ArcGIS, the process got a little more complex–you had to write a little VBA in Field Calculator as described by ESRI.
Menu