Ideal Parcels Locator Script By Heather Dean hgdean@hotmail.com I am pretending like I am looking for a home to buy, and would like to generate a list of ideal parcels that I can keep an eye on in case they come up for sale. My requirements are that they are in the RP Sports Complex neighborhood, that they are within ½ mile of a light rail station so I can walk to the train quickly in the morning, and within ¼ mile of a park so I can take my dog to play. I will perform a count on the number of parcels and list them out, trying to exclude the ones without both street number and street address, and write these out to a separate text file.
General Script Processes I started the script by defining the workspace and creating variables for my next step. I put print statements at the end of each step so I could monitor the progress of the script as I went along. Python Shell
General Script Processes Geoprocessing tasks can only be run on feature layers, but I had shapefiles! Before I could create feature layers out of the shapefiles, I put in code to delete any pre-existing layers of the same name. I then created the feature layers.
General Script Processes Next, I wanted to select all of the parcels in my desired neighborhood. I did this by creating a query that indicated my desired neighborhood, which I then used in a SelectLayerByAttribute script on the neighborhoods layer. To transfer this selection to the parcels layer, I used an ‘intersect’ type SelectLayerByLocation script. I received errors when I left the search distance field blank, so I just put in ‘0 FEET’. That seemed to work fine.
General Script Processes After creating a selection of the parcels in my desired neighborhood, I performed two SelectLayerByLocation scripts to narrow the selection to parcels within ½ mile of a lightrail station and ¼ mile of a park. The programmer can select from currently selected features using the “SUBSET_SELECTION” method. Just for fun, I threw in a “GetCount” script. The count, 91, matched the count that I got when I performed the same process in ArcMap.
General Script Processes Now that all of the ideal parcels have been selected, I want to be able to view their addresses. I accomplished this with a search cursor that would list them out for me. I wrote this search cursor script from the example script in the textbook.
General Script Processes As you can see in a selection of the result of the script in my python shell on the right, some of the street address fields didn’t show up. I tried rewriting my query several times without an improved result. The next step would be to move the list to a text file.
General Script Processes First, I had to create a file that the resulting text file would be written to. I took this code snippet from ArcGIS Help and played with it until I got it to do what I wanted.
General Script Processes On the right is the output text file opened in Notepad. All of the pesky addresses without street numbers are there, but the data is in a format that is manageable by any non-GIS user.