Fellow GIS professionals, I have a polygon feature containing individual polygon for each land parcel, which is intersected by another polygon/and polyline containing power lines and powerlines buffers, I need to create MapSeries for each parcel, clipping the powerlines within the extent of that specific parcel only, which is simple. But!! I also need to export the MapSeries zooming into the area of intersection only, and not the whole (default) full extent of the parcel, map series extent options are limited to best fit, fixed scale, or scale from field, is there is a way to achieve this, maybe through ArcPy? In example picture attached, I want to only zoom-in to the area marked in red as an example, in each of the parcel plans.
Thanks in advance.
Solved! Go to Solution.
In this situation we could possibly do the following:
Would the above work well enough in your situation?
In this situation we could possibly do the following:
Would the above work well enough in your situation?
Here is a crude script put together based on your suggested approach, I initially thought that you can access the MapSeries and manipulate the scale using ArcPy (mind you, not a pro python user! so maybe there is a way that I just don't know about), but for now, this script at least spared us the torture of the manual steps.
import arcpy
arcpy.env.overwriteOutput = True
workspace = arcpy.GetParameterAsText(0) # tool parameter (workspace) in ArcPro
aprx = arcpy.mp.ArcGISProject('Current')
mp = aprx.listMaps(aprx.activeMap.name)[0]
# ---------------------------Accept multiple layers as a list----------------------------------------------------------#
# Get user input for multiple layers (store in a list)
# tool parameter (layer) in ArcPro, with multiple values
layer_list_temp = arcpy.GetParameterAsText(1).split(";") # Split the comma-separated string
layer_list_temp = [layer.strip() for layer in layer_list_temp] # Remove leading/trailing spaces
layer_list = [(mp.listLayers(f'{i}')) for i in layer_list_temp]
# Check if any layers were entered
lyt = aprx.listLayouts()[0]
mainMapFrame = lyt.listElements("MAPFRAME_ELEMENT")[0]
if not layer_list:
arcpy.AddMessage("\nNo layers were selected. Please enter at least one layer.")
else:
arcpy.AddMessage(f"\nYou entered the following layers: {', '.join(layer_list_temp)}")
# ---------------------------------------Merge the layers------------------------------------------------------------- #
if len(layer_list) > 1:
# Function to merge multiple feature classes (assumes same geometry type)
def merge_features(layer_list, output_path):
"""
Merges a list of feature classes with the same geometry type into a single output feature class.
Args:
layer_list: A list of feature class paths.
output_path: The path to the output merged feature class.
"""
if not layer_list:
arcpy.AddMessage("\nError: No layers provided for merge operation.")
return
# Merge the feature classes
try:
arcpy.Merge_management(layer_list, output_path)
arcpy.AddMessage(f"\nSuccessfully merged layers into: {output_path}")
except arcpy.ExecuteError:
arcpy.AddMessage(f"\nError: Failed to merge layers. Please check the input list and output path.")
# Define output path for the merged feature class
output_path = f"{workspace}\Merged_Features"
# Call the merge function
merge_features(layer_list, output_path)
else:
output_path = layer_list[0]
# -------------------------------------Intersect & Dissolve with main layer--------------------------------------------#
inFeatures = [output_path,
f"{workspace}\{arcpy.GetParameterAsText(2)}"] # Base layer (Parcels), select parameter as Layer
arcpy.AddMessage("\nCreating Intersect & Dissolve...")
arcpy.analysis.Intersect(
in_features=inFeatures,
out_feature_class=f"{workspace}\MERGE_Intersect",
join_attributes="ALL",
cluster_tolerance=None,
output_type="INPUT"
)
arcpy.management.Dissolve(
in_features=f"{workspace}\MERGE_Intersect",
out_feature_class=f"{workspace}\Dissolved_Layer_MapSeries",
dissolve_field="Parcel_Num",
statistics_fields=None,
multi_part="MULTI_PART",
unsplit_lines="DISSOLVE_LINES",
concatenation_separator=""
)
# ---------------------------------------------Repair Geometry---------------------------------------------------------#
try:
arcpy.AddMessage("\nRepairing geometry...")
arcpy.management.RepairGeometry(
in_features=f"{workspace}\Dissolved_Layer_MapSeries",
delete_null="DELETE_NULL",
validation_method="ESRI")
except:
arcpy.AddMessage("\nRepair Geometry not Licensed, skipping this step...")
# ------------------------------------------display in the current map-------------------------------------------------#
arcpy.AddMessage(f"\nAdding {workspace}\Dissolved_Layer_MapSeries")
aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps()[0]
map.addDataFromPath(f"{workspace}\Dissolved_Layer_MapSeries")
arcpy.AddMessage("\nScript Completed!")
# Data cleanup, comment if you want to keep the data
if arcpy.Exists(f"{workspace}\Merged_Features"):
arcpy.Delete_management(output_path)
else:
pass
arcpy.Delete_management(f"{workspace}\MERGE_Intersect")
Hi Glen,
Appreciate the quick response. I should have elaborated further, your solution is what we actually have in place to export the maps, the process is roughly something like this: Intersect all layers within the parcel, can be more than one > Dissolve based on the parcel number field > use page query on all layers. Since we have Pro license which allows for only 2 feature intersections, and both parcels and powerlines features, or other affecting features changes frequently, this becomes a cumbersome process, I was after a more automated method to apply to the map series.
for example: