0

Here's my situation: I've got multiple utility feature classes, and each fc is subtyped according to one the primary attributes, which is a String. Each fc has at least 12 attribute fields, and each attribute is formatted as "String". My goal is to write a Python script that will sort, separate and export out feature classes for each subtype of the data. Does anyone have a good place to start or an idea of how to set-up the skeleton of the Py to get my script going? As an example (or reference) I'd like to pull all, "Watermain, 8in, PVC, Owner" out of a jumble of utility data.

1

There are a few ways you could go about this, and I am not 100% sure which would be the best for your situation. You could try using arcpy.Select_analysis (http://resources.arcgis.com/EN/HELP/MAIN/10.2/index.html#//000800000005000000) to create a feature class from a selection. Your where clause would probably look like 'Type = 'Watermain' and Measurment = '8in' and make = 'PVC' and Owner='Joe' ' or something of that nature, now that will select all of the attribute columns so you may need to trim the columns you do not want.

Another possiblity is to use the arcpy.da.SearchCursor (http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000) This way you could set the fields you want specifically, and then using a cursor you could go row by row of the results and do something like build a feature class by appending each row.

I also reccomend using the 'in_memory' workspace. You can use this to create a sort of temporary feature class, get it looking how you want, then copy it into your file gdb or where ever. (http://resources.arcgis.com/en/help/main/10.2/index.html#//002w0000005s000000)

If you were to post example data, I could look at writing something more specific, but here is a general outline of how I would tackle the problem. First I would create an empty feature class, or classes, in the in_memory workspace. With the fields named how they are, and only the ones I want. Then I would use a search cursor with a where clause denoting what I am trying to separate, append the results to my in_memory featureclass 'in_memory/target_waterlinefc'. and then copy that in the the file gdb or database connection when I am finished. Hope this helps get you going.

  • dude, I will be definitely using your tips to start this script off. Also, I will try to post some of the data shortly. – Winston Aug 5 '15 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.