Web Analytics Made Easy -
StatCounter

Node Dangles

Python

In the last week, I have looked for multi-part features a couple of times. Today, I was looking for multi-part polygons after dealing with the fall-out of a case of Clip Gone Wild as shown below. I have not found a way to write a query to find these but Field Calculator does allow you to calculate a field’s value to the number of parts. Using the Python parser, just write the formula (note that case matters): !
This is a bit of a tangent but for some crazy reason, I wanted to convert some text to audio so I could listen to it while I drive. A quick Google search left me without any freeware that could handle the 53 page document–there are some cool websites that do text to mp3 like vozme and YAKiToMe! but they didn’t convert the whole document. I then found pyTTS, a python package that serves as a wrapper to the Microsoft Speech API (SAPI) , which has been in version 5 since 2000.
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.
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, !
Received a request yesterday asking how to use the ArcMap Calculator to copy values from a Text field to a Double field using python syntax. As any good blogger would do, I immediately thought, ‘Awesome! Someone’s question is the perfect topic for a new blog post’. The python parser is actually pretty good at casting values on the fly so if the values in your text field (!Day! in my example) are valid values that can be converted to a Double value, it is as simple as just setting the formula to be the text field.
As contributor of the day, Jason Scheirer, pointed out, python has a simple, direct way to browse through the subdirectories of a directory–os.walk Here is a bare-bones example of using it to print out the subdirectories in a path. The files variable of the 3-tuple is a list of files similar to the dirs variable that I loop through. Thanks Jason for pointing out something I missed. import os theDir = 'c:/temp/' for root, dirs, files in os.
Someone asked how to have python recursively search a folder structure. There may be a better way but this is how I typically do it–it basically starts with one directory and loops through the contents compiling a list of sub-directories as it goes through the contents. import glob, os theDir = 'c:/temp/' theDirList = [] theDirList.append(theDir) while len(theDirList)> 0: newDirList = [] for iDir in theDirList: print iDir for iFile in glob.
One of the standards in our databases is to store dates as 8-digit integer values in the format of yyyymmdd. This requires us to occasionally convert values from date fields into this format. We can do this in the ArcMap Field Calculator using this arcpy function: def datetodouble(inNum): splitList = str(inNum).split("/") return splitList [2] +("0"+ splitList [0])[-2:] +("0"+ splitList [1])[-2:]
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.
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.
Menu