Se está trabajando en la posibilidad de ampliar las características de una fila de búsqueda para producir mapas individuales por fila (como las páginas de datos pero para filas individuales en el conjunto de datos).
No consigo que el zoom llegue a la medida. He buscado pero no encuentro lo que necesito en la guía de ayuda de sintaxis.
Guión que aparece a continuación
import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True
#Set File workspace
file_workspace = 'N:\\GIS\\Projects\\AA_Leith_Hawkins_TestBed\\Search_Cursor\\Search_Cursor.gdb'
env.workspace = file_workspace
#buffer set up
Holdings = 'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb\Data\Holdings'
distances = [1000, 4000]
unit = "Meters"
#Make a feature layer
arcpy.MakeFeatureLayer_management(Holdings,'Holdings_Layer')
#searchcursor for evey row in dataset
with arcpy.da.SearchCursor(Holdings, ['Holding_Reference_Number'])as Holdings_Ref_cursor:
for row in Holdings_Ref_cursor:
print row[0]
query = "Holding_Reference_Number = " + str(row[0])
print query
File_output = file_workspace+ '\\' 'Buffer_'+str(row[0])
#print File_output
#Select Feature using the reference number from holdings layer
arcpy.SelectLayerByAttribute_management('Holdings_Layer', 'NEW_SELECTION',"Holding_Reference_Number = " + str(row[0]))
# Export holding to geodatabase
Holding_Boundary = file_workspace+ '\\' 'Holding_'+str(row[0])
arcpy.management.CopyFeatures('Holdings_Layer', Holding_Boundary)
#Mutliple ring Buffer using Selected Features
arcpy.MultipleRingBuffer_analysis('Holdings_Layer', File_output, distances, unit, "", "ALL")
arcpy.MakeFeatureLayer_management(File_output, 'Buffer_Layer')
#arcpy.Buffer_analysis("Holdings_Layer", ofc, var_Buffer, "FULL", "ROUND", "ALL", "")
print 'Buffer complete'
#Intersect Features
Intersect_out_feaatures = file_workspace+ '\\' 'Intersect_'+str(row[0])
arcpy.Intersect_analysis([Holdings,File_output],Intersect_out_feaatures, "", "", "INPUT")
print "intersect Complete"
#add Layers to the Map
mxd = arcpy.mapping.MapDocument('N:\\GIS\Projects\\AA_Leith_Hawkins_TestBed\\Search_Cursor\\Search_Cursor_mxd.mxd')
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
addLayer = arcpy.mapping.Layer(File_output)
addLayer2 = arcpy.mapping.Layer(Holding_Boundary)
addLayer3 = arcpy.mapping.Layer(Intersect_out_feaatures)
arcpy.mapping.AddLayer(df, addLayer, "TOP")
print addLayer
arcpy.mapping.AddLayer(df, addLayer2, "TOP")
print addLayer2
arcpy.mapping.AddLayer(df, addLayer3, "TOP")
print addLayer3
#zoom to layer
print df
lyr = arcpy.mapping.ListLayers(mxd, '', df)[2].name
print lyr
extent = lyr.getExtent()
print extent
df.extent = extent
#Export Map to PNG File
Png_output = "N:\\GIS\Projects\\AA_Leith_Hawkins_TestBed\\" + str(row[0]) + '.png'
arcpy.mapping.ExportToPNG(mxd,Png_output)
print 'Map Created'
del mxd
El mensaje de error que me sale es (he incluido las impresiones de la tirada también para que veáis lo que producen para intentar facilitarlo:
108050022
Holding_Reference_Number = 108050022
Buffer complete
intersect Complete
Buffer_108050022
Holding_108050022
Intersect_108050022
<geoprocessing Data Frame object object at 0x1262EC00>
Buffer_108050022
Traceback (most recent call last):
File "N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Script\SearchCUrsor.py", line 65, in <module>
extent = lyr.getExtent()
AttributeError: 'unicode' object has no attribute 'getExtent'