arcgis
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.
I just had the need to go through a directory containing many (100+) layer files (.lyr) and verify the data sources in each. I could have loaded each into ArcMap and checked the properties, but choose not to. Here’s the bare-bones script I used instead:
import arcpy, glob,os theDir = r"L:\gdrs\data\org\us_mn_state_dnr\elev_minnesota_lidar\\" os.chdir(theDir) for iFile in glob.glob("*.lyr"): print iFile lyr = arcpy.mapping.Layer(iFile) for i in arcpy.mapping.ListLayers(lyr): try: print " {0}: {1}".format(i,i.dataSource) except: print " {0}: Does not support dataSource".
I was recently re-evaluating our back-up procedures and discovered and found a nasty bug with the arcpy’s ListFeatureClasses request. If you have a feature class in a feature dataset with the same name, ListFeatureClasses may not find it or anything else in that feature dataset.
Unfortunately, we recently made our daily backup a python-based system that uses ListFeatureClasses and got bit by this bug.
After discovering missing data in our backups, I reconstructed what happened and found this bug.
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.
Seems like a lot of people are finding the ArcMap Field Calculator examples that I have posted useful so I will make an effort to post more of them. Most posts are generated after I do something and think that others might want to know how to do it. (Or so I can go back and remember how I did something without re-inventing it).
Something I did today was create a field (!
You may have noticed that this post–ArcMap Field Calculator: Identifying Unique Cases, Single Field–specifies ‘Single Field’. Yes, that was my version of a cliff-hanger post.
The basic structure I listed in that post can be expanded on to satisfy your needs. The example in my earlier post was case sensitive for example, you could modify it so it treats ‘a’ the same as ‘A’.
Today’s example groups records into different cases based off the values of two fields, !
I have been working on a python script that I want (NEED) to run as a scheduled task on a remote machine. I got to the point that the script did exactly what I needed when I was interactively running it in a Windows session but had problems when running it as a scheduled task. The debugging process was cumbersome–make a change, schedule a task to run it, log out of the machine, and wait.
Random luck me to discovering a bug related to feature classes whose names start with ‘nd_'. It appears that you are allowed to create feature classes starting with ‘nd_’ but ArcCatalog will not display them. Further research shows this behavior also occurs for table and for ArcSDE (PostGres) geodatabases, personal geodatabase, and file geodatabases–I am using ArcCatalog 10.0.
I first noticed something odd was occurring while importing a series of shapefiles into a geodatabases.
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.