POST
|
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!!
... View more
12-09-2015
11:53 AM
|
0
|
0
|
41
|
POST
|
IT WORKED Thanks!! One last question: The direction of the slash always seemed to matter. Why does it not matter here?
... View more
12-09-2015
11:31 AM
|
0
|
2
|
41
|
POST
|
Thank you so much for your help!! When running the arcpy rename function I get the Error 9999: Error executing function When printing the Rename_Output I get the following string: //service.geo.uzh.ch/private/test/data/Desktop/Test/Data_out/CHM/Tile_chm_catchment \ Tile_chm_catchment_<da.SearchCursor object at 0x00000000054E6870>.tif --> The slash before Tile_chm_catchment is in the wrong direction (this is the output of the walk function which I copied from the ArcGIS help). Why does this happen? Does this have to be changed? --> The da.SearchCursor is an object. Why is not a number? When applying "feature_class_string_NoNumber_NoTif = ''.join([i for i in feature if not i.isdigit()]).split(".")[0]" it somehow adds "//service" to the line. I have no clue why this happens. See updated code: # CHM = Raster Dataset # Catchment = Vector Dataset # Outlet_ID = Polygon_ID with I want to add to the Output of the Raster Split Tool workspace = Tile_chm_catchment walk = arcpy.da.Walk(workspace, datatype="RasterDataset", type="TIF") feature_classes = [] for dirpath, dirnames, filenames in walk: for filename in filenames: feature_classes.append(os.path.join(dirpath, filename)) print feature_classes # Output = u'///Data_out/CHM/Tile_chm_catchment\\Tile_chm_catchment_99.TIF # unicode to string feature_class_string = [x.encode('UTF8') for x in feature_classes] # print feature_class_string # Output = '//.../Data_out/CHM/Tile_chm_catchment\\Tile_chm_catchment_99.TIF' for feature in feature_class_string: #print feature # Output = //..../Data_out/CHM/Tile_chm_catchment\Tile_chm_catchment_99.TIF Raster_Number = int(re.findall('\d+', feature)[0]) # Raster_99 would lead to Raster_Number = 99 print Raster_Number # Output = ['99'] ## feature_class_string_NoNumber_NoTif = ''.join([i for i in feature if not i.isdigit()]).split(".") ## print feature_class_string_NoNumber_NoTif[0] feature_class_string_NoNumber = ''.join([i for i in feature if not i.isdigit()]) #print feature_class_string_NoNumber # Output = //.../Data_out/CHM/Tile_chm_catchment\Tile_chm_catchment_.TIF feature_class_string_NoNumber_NoTif = feature_class_string_NoNumber[:-4] #print feature_class_string_NoNumber_NoTif # Output = ///Data_out/CHM/Tile_chm_catchment\Tile_chm_catchment_ CHM_Input = feature oidField = arcpy.Describe(Catchment).oidFieldName #print oidField fieldValue = arcpy.da.SearchCursor(Catchment,["OID@","Outlet_ID"],where_clause = '{0} = {1}'.format(arcpy.AddFieldDelimiters(CHM_Input, oidField),Raster_Number)) # ID@ —The value of the ObjectID field fieldValue = arcpy.da.SearchCursor(Catchment,["OID@","Outlet_ID"],where_clause = '{0} = {1}'.format(arcpy.AddFieldDelimiters(CHM_Input, oidField),id)) # ID@ —The value of the ObjectID field #printfieldValue Rename_Output = str(feature_class_string_NoNumber_NoTif) + str(fieldValue) + ".tif" print Rename_Output arcpy.Rename_management(feature, Rename_Output)
... View more
12-09-2015
11:04 AM
|
0
|
4
|
59
|
POST
|
I tried to do this but I am doing something wrong... I think i did not implement the arcpy.da.SearchCursor correctly: # CHM = Raster Dataset # Catchment = Vector Dataset # Outlet_ID = Polygon_ID with I want to add to the Output of the Raster Split Tool workspace = Tile_chm_catchment walk = arcpy.da.Walk(workspace, datatype="RasterDataset", type="TIF") feature_classes = [] for dirpath, dirnames, filenames in walk: for filename in filenames: feature_classes.append(os.path.join(dirpath, filename)) #print feature_classes # Output = u'//.../Data_out/CHM/Tile_chm_catchment\\Tile_chm_catchment_99.TIF # unicode to string feature_class_string = [x.encode('UTF8') for x in feature_classes] # print feature_class_string # Output = '/.../Data_out/CHM/Tile_chm_catchment\\Tile_chm_catchment_99.TIF' for feature in feature_class_string: #print feature Raster_Number = re.findall('\d+', feature) # Raster_99 would lead to Raster_Number = 99 #print Raster_Number # Output = ['99'] feature_class_string_NoNumber = ''.join([i for i in feature if not i.isdigit()]) #print feature_class_string_NoNumber # Output = //.../Data_out/CHM/Tile_chm_catchment\Tile_chm_catchment_.TIF feature_class_string_NoNumber_NoTif = feature_class_string_NoNumber[:-4] #print feature_class_string_NoNumber_NoTif # Output = //.../Data_out/CHM/Tile_chm_catchment\Tile_chm_catchment_ CHM_Input = feature oidField = arcpy.Describe(CHM_Input).oidFieldName #print oid_Field fieldValue = arcpy.da.SearchCursor(Catchment,["OID@","Outlet_ID"],where_clause = '{0} = {1}'.format(arcpy.AddFieldDelimiters(CHM_Input, oidField),id)) # ID@ —The value of the ObjectID field #printfieldValue Rename_Output = str(feature_class_string_NoNumber_NoTif) + str(fieldValue) + ".tif" arcpy.rename_management(fieldname_string, Rename_Output)
... View more
12-09-2015
09:34 AM
|
0
|
6
|
59
|
POST
|
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"
... View more
12-09-2015
05:36 AM
|
0
|
8
|
59
|
POST
|
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?
... View more
12-09-2015
04:28 AM
|
0
|
10
|
59
|
POST
|
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.
... View more
12-09-2015
04:26 AM
|
0
|
0
|
59
|
POST
|
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?
... View more
12-09-2015
01:27 AM
|
0
|
13
|
4554
|
POST
|
My aim is to calculate catchments for around 150 points and to extract land-use variables for them. In order to do so I need a vector dataset where no polygons overlap. This, however, seems to be a challenging task. Presume, that I already calculated the catchments for all 150 points (see Figure 1; here only points 1-6 are visualized): How do I get from the overlapping catchment features in Figure 1 to the none overlapping catchment features in Figure 2? How can I associate the catchment features to previous overlaps? I thought of adding up the IDs (see 'Sum ID Overlap' in the attribute table in Figure 2). Can this be done automatically?
... View more
08-22-2015
12:55 AM
|
0
|
1
|
2727
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|