1

I am trying to build a model that reads through about 30 different point feature classes and appends only the selected features to a new feature class. Some of the feature classes don't have any selected records, so it is appending every record from that feature class. Is there a way to exclude these features from being appended? In the past we used a VBA macro to read through each feature class and uses selection sets to determine if any of the records are selected, but I can't figure out how to get that same functionality using Python.

  • 4
    What GIS software and version are you using? – recurvata Sep 29 '14 at 12:09
  • Is the feature selection performed within the model, or does it happen before the model is run? – Erica Sep 29 '14 at 12:32
1

If using python (as your tag suggests), and ArcGIS (maybe?), you could do something like this ... (edited)

# Check to be sure there is at least one feature selected.
ftrCountBefore = int(arcpy.GetCount_management(layer).getOutput(0))
# ToDo Perform a Selection 
# ftrCountAfter = int(arcpy.GetCount_management(layer).getOutput(0))
if (not (ftrCountBefore == ftrCountAfter)):
    doSomething
  • Thanks this is really useful but it returns a count of all the records if nothing is selected. I need a count of 0 if nothing is selected. I'm on ArcMap 10.2 fyi. – Drew M Sep 29 '14 at 21:25
  • 1
    Ah I see. Perhaps you could try to run it before you do the selection and compare that with what you get after you run the selection and skip the "doSomething" part if they are the same. I edited my answer to take this approach. – jbchurchill Sep 29 '14 at 21:47
  • 1
    Thanks but I think I found my answer. If you use the arcpy.Desribe function it returns he IDs of only the selected records and a "u''" if nothing is selected. – Drew M Sep 30 '14 at 0:53

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.