I am looking for an automated way to scan through a dataset, panning to the location of each observation on the map, then take a picture of that observation, and then name the picture after one of the variables.
I am thinking that python is going to be my best best for accomplishing this with a for loop but am unsure of functions would be able to accomplish this. I have some experience with python but not a lot of experience with ArcGIS and python. You can see an example below of the type of picture I want to take. I don't have to select each observation like in the picture but that would be nice.
Thanks
Solved! Go to Solution.
I was able to cobble together some working code from the links you gave thanks.
mxd = arcpy.mapping.MapDocument('CURRENT') df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0] OutputLocation=r"\\mriglobal\kcshares\Projects\311190\STATISTICAL ANALYSIS\PLOTS" Layer = "Export_Output" cursor = arcpy.SearchCursor(Layer) for row in cursor: FID_txt=str(row.getValue('FID')) arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION" , "FID = " + FID_txt) df.zoomToSelectedFeatures() if df.scale<2000 and df.scale>300: df.scale=2000 if df.scale<300: df.scale=1000 arcpy.RefreshActiveView() arcpy.mapping.ExportToJPEG(mxd, OutputLocation + '/' + row.getValue('SRI') + ".jpg", df, 1920, 1080) arcpy.SelectLayerByAttribute_management(Layer, "CLEAR_SELECTION")
Hi Michel,
I would look into using cursors to access the data you need for each record in your dataset and reading them to a list(if you only need one value per dataset) or a dictionary if you need more than one.
I would then probably iterate through the list/dictionary and create a defintion query to your layer in your map document using the value(s) as needed, zoom to the feature, zoom back out to a set scale(if you are working with points you will definitely want to zoom back out, polygons you might want to zoom out by a certain amount). After you have the extent set how you want, export out to whichever format works for you.
Some handy links:
Introduction to the Arcpy Mapping Modules.
Introduction to arcpy.da.SearchCursor:
Thread where I posted some code for creating several maps from a single dataset with many records with many values. Please note I used a slightly different method then, but gives you some ideas for flow and syntax.
https://community.esri.com/thread/160192
Richard Fairhurst excellent blog post about using cursors and dictionaries for data manipulation. Should help with using cursors and reading in all the data you will need. I would highly recommend only using the cursors for creating the list/dictionaries of data, since doing alot of geoprocessing while in a cursor tends to bog things down.
Arcpy Tool for exporting to PDF:
http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/exporttopdf.htm
Alternatively, look into Data Driven Pages.
https://community.esri.com/thread/160192
Regards,
Ian
Thanks for the response Ian. I'll start looking into this information and see if I can't figure something out.
This should be relatively straight forward, I feel a little bad throwing so many links at you. I know there was another thread on GeoNet for zooming and exporting at multiple scales that is a bit more relevant, but I don't have it bookmarked like some of the others. I'll dig around and see if I can find it.
Edit: Not so hard to find apparently, though this one is for a script tool.
I was able to cobble together some working code from the links you gave thanks.
mxd = arcpy.mapping.MapDocument('CURRENT') df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0] OutputLocation=r"\\mriglobal\kcshares\Projects\311190\STATISTICAL ANALYSIS\PLOTS" Layer = "Export_Output" cursor = arcpy.SearchCursor(Layer) for row in cursor: FID_txt=str(row.getValue('FID')) arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION" , "FID = " + FID_txt) df.zoomToSelectedFeatures() if df.scale<2000 and df.scale>300: df.scale=2000 if df.scale<300: df.scale=1000 arcpy.RefreshActiveView() arcpy.mapping.ExportToJPEG(mxd, OutputLocation + '/' + row.getValue('SRI') + ".jpg", df, 1920, 1080) arcpy.SelectLayerByAttribute_management(Layer, "CLEAR_SELECTION")