Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Clipping a Raster into 5×5(25) equal tiles through the use of arcpy?

$
0
0

I am curious to find our if there is a way to create a python code that enables you to clip a raster into equal parts example: 5×5(25) tiles with the use of arcpy?

From what I can think of you would need to divide the lengths of the extents into 5 equal parts from the width and 5 equal parts from the length and then determine the coordinates from that.

Can anyone think of a way to perform this with arcpy? or possibly provide a better method than the one I am thinking of?

    import arcpy
arcpy.env.workspace = r"folder path"
outWorkspace = "folder path"
arcpy.env.OverwriteOutput = True

rasList = arcpy.ListRasters()
print "The rasters in the workspace are:"
for ras in rasList:
    print "-- " + ras

rasDescr = arcpy.Describe("raster name")
print "nThe type of the data is : " + rasDescr.DataType
rasExtent = rasDescr.Extent

print "The extent of the data : "
print "tX-Min: " + str(rasExtent.XMin) + " X-Max: " + 
str(rasExtent.XMax)
print "tY-Min: " + str(rasExtent.YMin) + " Y-Max: " + 
str(rasExtent.YMax)

print arcpy.Usage("clip_management")
coords = ("X Min   Y Min   X Max   Y Max")
output = outWorkspace + "\" + "output name"
arcpy.Clip_management(rasDescr.Name, coords, output)

Viewing all articles
Browse latest Browse all 767

Trending Articles