I am using a raster with a 0.66 x 0.66 m² resolution in which I need
to perform some calculations. As you can imagine, this will take aeons
of time if I do it in the complete raster dataset. Therefore I have
created a fishnet that covers the region in which I want to perform
the calculations in.
Now i need to clip my raster dataset against this fishnet, but in an
automatic way so I do not have to perform a new action everytime I
calculate a fishnet cell with the raster.
I think this is possible to do it in Python language but I simply have
no knowledge at all with this language and I am very short on time,
can anyone help me? AML scripting is also welcome!
Thank you!
Hope that helps!
----------------------------
Robert Claypoool
Nashville, TN
#
---------------------------------------------------------------------------
# MakeDEMs_Geoprocess.py
#
---------------------------------------------------------------------------
# Import system modules
import sys, string, os, win32com.client
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
# Set product license
gp.SetProduct("ArcView")
# Check out any necessary licenses
gp.CheckOutExtension("spatial")
# Load required toolboxes
gp.AddToolbox("C:/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx")
gp.AddToolbox("C:/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst
Tools.tbx")
# Create a search cursor
Buffer_Polygons = "C:\\Documents and Settings\\robert.claypool\\Desktop
\\Bucks_Co\\Approx_Study\\MergeStream_Buffers.shp"
rows = gp.SearchCursor(Buffer_Polygons)
row = rows.Next()
# Loop through all the records in the shapefile
# Geoprocess each record.
try:
while row:
# Find the FID field
FID = row.GetValue("FID")
# Find the "Source_Nm" field. Get it's value for this row.
This value will be used to select the feature and name output
files.
Name = row.GetValue("Source_Nm")
Name = Name[0:-4] # This removes the last 4 characters
(".mdb") from the string
# Generate an expression to select the feature
Expression = '\"FID\" = ' + str(FID) # Where "FID"=FID
# Execute Process: Select the feature for this row, save it to
a new shapefile
Output_Path_1 = "C:\\temp\\" + Name+ "_BUFFER.shp"
gp.Select_analysis(Buffer_Polygons, Output_Path_1,
Expression)
# Execute Process: Clip DEM using the new shapefile as a mask
Dem = "C:\\Documents and Settings\\robert.claypool\\Desktop\
\Bucks_Co\\DEM\\dem"
Output_Path_2 = "C:\\temp\\dem" + Name
gp.ExtractByMask_sa(Dem, Output_Path_1, Output_Path_2)
# Advance the cursor for next iteration of the loop
row = rows.Next()
except:
# If an error occurred while running a tool, print the messages
print gp.GetMessages()
#
---------------------------------------------------------------------------
# END MakeDEMs_Geoprocess.py
#
---------------------------------------------------------------------------
> > > Thank you!- Hide quoted text -
>
> - Show quoted text -