4

ArcMap 10.2

I am creating a utility mapbook to show HVAC points on an installation. The data driven pages are named and sorted by a separate layer (area feature class). There are 70 named areas, however, not every page has HVAC units within the extent.

Is there a method to automatically exclude pages that do NOT include HVAC points within the viewing extent?

Notes: - The data itself has to remain untouched so I can't add any additional fields. - I'm familiar enough with python to run a script but I don't know what modules to call or run.

  • You can't add a field to the area feature class? – ianbroad Aug 13 '15 at 19:50
  • @ian Unfortunately no. It's government data and there are pretty strict restrictions on what fields are included. – Tobel Aug 13 '15 at 20:01
3

The way I've always limited what pages are included is through a definition query.

If you can't edit the original data, then you could make a copy of it. However, I'm not sure of all your requirements.

The script below will make a copy of the original area layer, and add a field called DisplayPage. It then does a SelectByLocation to select all the areas that contain an HVAC feature. After the selection it uses an UpdateCursor to populate the DisplayPage field with a Yes for all the currently selected areas.

import arcpy

arcpy.env.overwriteOutput = True

#change paths to where your data is located
original_area = "C:\\temp\\Data.gdb\\Area"
hvac_features = "C:\\temp\\Data.gdb\\HVAC"

#change path to where you'd like the copy outputted
copy_area = "C:\\temp\\Data.gdb\\AreaCopy"

arcpy.CopyFeatures_management(original_area, copy_area)
arcpy.AddField_management(copy_area, "DisplayPage", "TEXT")

copy_area_fl = arcpy.MakeFeatureLayer_management(copy_area, "copy_area_fl")
hvac_features_fl = arcpy.MakeFeatureLayer_management(hvac_features, "hvac_features_fl")

arcpy.SelectLayerByLocation_management(copy_area_fl, "CONTAINS", hvac_features_fl)

with arcpy.da.UpdateCursor(copy_area_fl, ("DisplayPage")) as cursor:
     for row in cursor:
         row[0] = "Yes"

         cursor.updateRow(row)

arcpy.Delete_management(copy_area_fl)
arcpy.Delete_management(hvac_features_fl)

Then in ArcMap set a definition query on the copied area layer to DisplayPage = 'Yes'. And use this layer as the index for the Data Driven Pages.

enter image description here

  • 1
    Thank you, this did exactly what I needed. And I appreciate you writing this in python as I need more experience in this area and it will be good to break this down. – Tobel Aug 13 '15 at 20:40

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.