ArcScripts
I was working on a project and wanted my own custom mouse cursor and did not easily find a way to make your own in ESRI’s instructions. But, once you know how to do it, it is pretty easy. In Visual Studio, Add a New Item:
Add a Cursor File:
You can edit your cursor with the editor program in Visual Studio. Once you satisfied with how it looks, make sure that the Build Action on the cursor is ‘Embedded Resource’.
I’ve previously posted python code to check if a field index exists for both ArcGIs 9.3 and ArcGIS 10.0.
Recently I have been working on a process that was using this code but it was not working because it looks for an index with a specific name. It was not working in this case because the name of the indexes was getting incremented as they were being created. For example, I was building an index on the table C5ST, field RelateId ([C5IX].
Discovered something today. I was working on an arcpy script that copies a raster dataset from a file geodatabase into a Postgres SDE geodatabase and then does some boring routine tasks–building stats, creating a mosaic dataset, adding the raster to the mosaic dataset and making a couple referenced mosaic datasets.
It sometimes has trouble with the initial step of uploading the raster because of the sheer size of if (1m elevation raster for counties) and it failed today on one.
I am working on an data-entry application to edit feature classes that contain several coded-value-domains. The problem with some of the domains, however, is that some entries have been added after the initial creation. So the first 25 entries are in alphabetical order and there are some stragglers at the end that are in the order they were appended.
This can be confusing for users–they go to select ‘Milli Vanilli’ and look between ‘Madonna’ and ‘Motley Crue’ but can not find their favorite band there–they have to go to the end of the list to find their selection.
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 working my way through this ESRI Walkthrough: Building custom UI elements using add-ins (ArcObjects .NET 10 SDK). And came across a couple minor errors that I had to correct during the process.
First, while implementing the OnClick() code for ZoomToLayer.vb, Visual Studio gave me a ‘Name ‘ArcMap’ is not declared.' error.
In the walk-through, they mention that the ArcMap method of your class. For me, however, it appeared under the .
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.
NOTE: I have a post here that shows how to check if a field exists using arcpy in ArcGIS 10.0.
In developing a python script to reload a geodatabase, I wanted to create any necessary indexes.
No problem creating the index, for example:
gp.AddIndex_management(tablename, field, IndexName, "NON_UNIQUE", "NON_ASCENDING") But before creating the index, I wanted to verify that it did not exist. I tried the ever-popular, exists but could not get it to work–either it does not detect indexes or I just never got the fully-qualified name for the index right (ArcSDE using a postgres datastore).
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.
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.