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?
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.
How can I rename the raster files based on a vector attribute with the iterate raster - rename approach?
The second approach worked (see script below) but using the Clip tool in a loop is substantially slower than the Split Raster tool:
cursor = arcpy.SearchCursor(Catchment) for poly in cursor: print(poly.getValue(Outlet_ID)) OutletID_poly = poly.getValue(Outlet_ID) Output_poly = Tile_chm_catchment2 + "/Tile_chm_catchment" + str(OutletID_poly) + ".tif " arcpy.Clip_management (CHM, "281898 706162 249670 761440", Output_poly, CHM, "", "NONE", "NO_MAINTAIN_EXTENT") print "Tile_chm_catchment_" + str(OutletID_poly) + " is done"
You could use the iterate rasters with the rename tool in a model builder. I almost think it would be easier to make a tool that iterates features and then clips the rasters. You could use get field value tool to generate the naming output.
The attribute is an ID which is different from the FID. Can the rename be done automatically? Renaming all of them manually would be laborious as the Split Raster tool created more than 100 files.
Maybe this can be done using an overlap query?
The only way as far as I can see would be to run the Split Raster tool with your polygon grid, then rename each one afterwards with your attribute id. You would have to make sure that these are unique of course. Are these map sheet names / ids or something.
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.