ArcGIS Split Tool: How to change output name prefix based on polygon attribute

7727
13
Jump to solution
12-09-2015 01:27 AM
LaraFaelivrin
New Contributor

I want the output file names of the raster split tool (ArcGis;http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000009v000000) to carry a specific attribute (not FID) of the polygon I used to split the raster file. How can I achieve this?

Tags (1)
0 Kudos
13 Replies
LukeSturtevant
Occasional Contributor III

Lara,

I'm guessing you are getting an error because of the search cursor. I think I forgot to finish the code for the search cursor the last time I gave it to you. It should be this:

arcpy.da.SearchCursor(Catchment,["OID@","Outlet_ID"],where_clause = '{0} = {1}'.format(arcpy.AddFieldDelimiters(CHM_Input, oidField),Raster_Number)).next()[1]

I'm not sure why you are getting a "\\Service" tagged to your output name. If it was working fine for you before then I would suggest going back the way you had it before.

On another note it might be helpful for us to see an arc catalog screen shot of your workspace folder with the raster files.

LaraFaelivrin
New Contributor

IT WORKED

Thanks!!

One last question: The direction of the slash always seemed to matter. Why does it not matter here?

0 Kudos
LukeSturtevant
Occasional Contributor III

The double backslash or the a single forward slash can be used for storing and parsing paths. A single backslash is an escape character​ in the python language so that would cause problems if you were attempting to use that.

LaraFaelivrin
New Contributor

But I did use a single backslash character:

//.../Data_out/CHM/Tile_chm_catchment\Tile_chm_catchment_.TIF

But maybe the print output just hides the second one because after all it worked!

Many thanks!!

0 Kudos