<?
from win32com.client import Dispatch
GP = Dispatch("esriGeoprocessing.GPDispatch.1")
import math
from math import *
GP.Workspace = raw_input("Input the workspace: ")
rasList = GP.listRasters ()
rasList.Reset()
ras = rasList.next()
print "The raster dataset in the work space are: "
while ras:
print "\t" + ras
ras = rasList.next()
rasData = GP.Describe(raw_input("Raster Data to be divided to tiles: "))
extentList = rasData.extent.split(" ")
math.sqrt(cellNum) = int(cells)
print "The extent of the Raster"
print "------------------------"
print "Xmin, Ymin: (" ,extentList[0],",",extentList[1],") Xmax, Ymax (" ,extentList[2],",",extentList[3],")"
print "Number of Rows = ", cellNum,"and the number of Columns = " , cellNum
a = astart = int(extentList[0])
b = bstart = int(extentList[1])
c = cstart = int(extentList[2])
d = dstart = int(extentList[3])
cW = int((c - a)/cellNum)
cH = int((d - b)/cellNum)
print "The width of each cell is: ", cW, " and the height will be: ", cH
tileCount = 1
output = "OutRast"
a = a
b = b
c = a + cW
d = b + cH
#Concept of structure#
##################
#row4#i4j1, i4j2, i4j3 etc
#row3#i3j1, i3j2, i3j3 etc
#row2#i2j1, i2j2, i2j3 etc
#row1#i1j1, i1j2, i1j3 etc
##################
for i in range(1,cellNum+1):
print "\nRow", i,"started"
for j in range(1,cellNum+1):
coords = str(a) +" "+ str(b) +" "+ str(c) +" "+ str(d)
outRas = str(output)+str(tileCount)
print "\tCell #",tileCount," Complete"
GP.clip_management (rasData.name,coords,outRas)
a = a + cW
b = b
c = c + cW
d = d
tileCount = tileCount +1
a = astart
b = bstart + (cH * i)
c = astart + (cW)
d = bstart + (cH * i) + cH
print "\nThe DEM has now been cut into",cells," individual cells"
?>
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||