ArcMap Data Driven Page - Exclude pages without point within extent

Here's this as a reference from GIS SE:

http://gis.stackexchange.com/questions/158226/arcmap-data-driven-page-exclude-pages-without-point-within-extent


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.

http://i.stack.imgur.com/KXZmN.png

/r/gis Thread