Select to view content in your preferred language

Clipping a raster and renaming it

930
2
Jump to solution
04-01-2013 02:36 PM
RileyCotter
Occasional Contributor
I am still pretty much a beginner when it comes to python, so go easy on me.  I am trying to clip a raster to a tiled polygon layout. I have a feeling that my errors: ERROR 000628: Cannot set input into parameter rectangle. and Error 000622  are happening when I am trying to use the geometry of one feature to clip my raster, and then renaming it to that tile name in the "text" field.

Any help would be much appreciated, and please let me know if anything needs to be clarified.

Thanks!!

desc = arcpy.Describe(DEMpoly) shapefieldname = desc.shapeFieldName  rowCursor = arcpy.SearchCursor(DEMpoly)  for row in rowCursor:     feat = row.getValue(shapefieldname)     arcpy.Clip_management(OUTraster, feat, row.getValue(Text) + ".img")     cursor.next()
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RileyCotter
Occasional Contributor
fixed it.....just had my input and output values for the clip tool all messed up

for row in rowCursor:     feat = row.getValue(shapefieldname)     arcpy.Clip_management(OUTraster, "#", row.getValue(field) + ".img", feat, "0", "ClippingGeometry")     rowCursor.next()

View solution in original post

0 Kudos
2 Replies
RileyCotter
Occasional Contributor
fixed it.....just had my input and output values for the clip tool all messed up

for row in rowCursor:     feat = row.getValue(shapefieldname)     arcpy.Clip_management(OUTraster, "#", row.getValue(field) + ".img", feat, "0", "ClippingGeometry")     rowCursor.next()
0 Kudos
curtvprice
MVP Alum
Since you're new to Python, I thought I'd show you how formatting strings help with the syntax.
Much easier to debug when a SQL expression or pathname gets complicated!

for row in rowCursor:
    feat = row.getValue(shapefieldname)
    clipRas = "{0}.img".format(row.getValue(field))
    arcpy.Clip_management(OUTraster, "#", clipRas, feat, "0", "ClippingGeometry")
    rowCursor.next()
0 Kudos