1

How can i expand extent of a raster image with Python as the image shown in below. I have the coordinate information of a raster image such as Xmin Ymin Xmax Ymax,how can i expand its extent based on the specified size(Ex, expand 10px or 1px)? I know it can be easily implemented on AML through the command such as setwindow, con(isnull ...etc, but i have no idea on ArcPy.

Does anyone know about it?

enter image description here

4

Set the Output Extent environment setting with arcpy.env.extent, then make a copy of the raster

import arcpy
from arcpy.sa import *

arcpy.CheckOutExtension('Spatial')

arcpy.env.extent = arcpy.Extent(0,0,10,10)
arcpy.env.cellSize = 1

#Dummy raster just for demonstration
a = CreateConstantRaster(1)
print a.extent.XMin
0.0

#Widen Extent
arcpy.env.extent = arcpy.Extent(-2,-2,12,12)

# Copy the raster
b = a * 1
print b.extent.XMin
-2.0

Raster "b" from above code with NoData symbolized as light blue:

enter image description here

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.