3

I have a python code that goes through my map document and exports a jpg for each polygon grid. Right now it clips the image to the boundary of the each polygon.

Does anyone know how I can make it clip a small amount of data around the grid?

I only want a 1-2% more added but I'm not sure if this can be added to my existing code or do I have to create new polygons that are all a small amount bigger so I can capture this extra data.

Below is the code I am using right now.

import arcpy
... mxd = arcpy.mapping.MapDocument(r"C:\Users\markd\OneDrive\Documents\GIS\PalmSprings\PalmSprings_TileExport.mxd")
... df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
... lyr = arcpy.mapping.ListLayers(mxd,"L8_PS")[0]  ##shapefile layer name called grid
... rows = arcpy.SearchCursor(lyr)
... x=1
... for row in rows:
...     df.extent = row.Shape.extent
...     arcpy.mapping.ExportToJPEG(mxd, r"C:\GIS\PalmSprings\L8_PS\ " + str(row.getValue("PageName")) + ".jpg", df, df_export_width = 1200, df_export_height = 1200, resolution = 96, world_file=True, jpeg_quality = 100)
...     print x
...     x+=1
... del mxd

1 Answer 1

4

I used to do this by modifying the scale of the data frame:

...
for row in rows:
    df.extent = row.Shape.extent
    df.scale = df.scale * 1.02
    arcpy.mapping.ExportToJPEG(...)
    ...

You might need to play a bit with the scaling factor to find the extent that suits you (1.02 is probably a bit low).

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.