POST
|
Thanks Xander, I will try this as soon as I get an opportunity and post to confirm if successful, but it doesn't seem as though it will be a problem. Thanks for getting back to me so quickly. All the best, Matt
... View more
12-10-2013
01:23 AM
|
0
|
0
|
399
|
POST
|
Hi Xander, This is fantastic - it works! Placing R in front of the output filenames did the job. Thanks so much for your help. Just to clarify, in the code I was running the fields were defined correctly but I just simplified them here to A,B,C for clarity. I'm not trying to take advantage, but I now have just one more question! - If I now want the base e exponential values of "result", should it be a simple case of adding "Exp" to the 'result' code? I have tried this but it hasn't worked (predictably). I have added import arcpy.sa to the first line of script to allow access to the toolset, but I am sure that I need to define the tool to use at some point in the script ("with arcpy.sa.exp") - I'm just not sure where!!: >>> import arcpy,os,arcpy.sa
... arcpy.env.workspace = "C:\A\B\Test\TIMESLOOKUP.gdb"
... arcpy.env.scratchWorkspace = "C:\A\B\Test\TIMESLOOKUP.gdb"
... inWS = r'C:\A\B\C\EucDistRasters' # input rasters are stored here
... outWS = r'C:\A\B\Test\' # output rasters will be stored here
...
... tbl = 'LOOKUP$'
... fldName1 = 'A' # field with output raster name (no path included)
... fldName2 = 'B' # field with input raster name (no path included)
... fldName3 = 'C' # multiply value field
...
... fields = [fldName1,fldName2,fldName3]
... with arcpy.da.SearchCursor(tbl, fields) as cursor:
... for row in cursor:
... value_from_row = row[2]
... inName = row[1]
... outName = row[0]
... inRasLoc = os.path.join(inWS,inName)
... inRas = arcpy.Raster(inRasLoc)
... result = Exp(inRas * value_from_row)
... outRasLoc = os.path.join(outWS,outName)
... result.save(outName)
...
... del row, inRas, tbl Your help would be greatly appreciated. Best wishes, Matt
... View more
12-09-2013
01:14 AM
|
0
|
0
|
399
|
POST
|
Hi Xander, Please find below a screenshot of the first 12 rows of data. The first two columns are string and the third is numeric. The output names in column 1 are formatted as [year][month]_[inRaster]. There is an output name for each month of 2009 for each of the 126 input rasters. Thanks for your continued help. Matt
... View more
12-05-2013
11:15 PM
|
0
|
0
|
399
|
POST
|
Hi Xander, Thanks for another really helpful message. As you can probably tell, I'm very new to python! I have made the changes that you suggest but I'm encountering the same error message. I have also tried closing & reopening excel and ArcMap and reloading it into the TOC. Thanks again, Matt
... View more
12-05-2013
02:46 AM
|
0
|
0
|
399
|
POST
|
Hi Xander, Of course - please see below. I have emboldened the changes that I made to the original code that you posted. >>> import arcpy,os
... arcpy.env.workspace = "C:\A\B\Test\TIMESLOOKUP.gdb"
... arcpy.env.scratchWorkspace = "C:\A\B\Test\TIMESLOOKUP.gdb"
... inWS = r'C:\A\B\C\EucDistRasters' # input rasters are stored here
... outWS = r'C:\A\B\Test\' # output rasters will be stored here
...
... tbl = 'LOOKUP$'
... fldName1 = 'A' # field with output raster name (no path included)
... fldName2 = 'B' # field with input raster name (no path included)
... fldName3 = 'C' # multiply value field
...
... fields = [fldName1,fldName2,fldName3]
... with arcpy.da.SearchCursor(tbl, fields) as cursor:
... for row in cursor:
... value_from_row = row[2]
... inName = row[1]
... outName = row[0]
... inRasLoc = os.path.join(inWS,inName)
... inRas = arcpy.Raster(inRasLoc)
... result = inRas * value_from_row
... outRasLoc = os.path.join(outWS,outName)
... result.save(outName)
...
... del row, inRas, tbl Best wishes, Matt
... View more
12-05-2013
02:03 AM
|
0
|
0
|
1041
|
POST
|
Thanks so much for responding so quickly, Xander. Extremely helpful! And yes, the assumption that you listed are correct - sorry if my question could have been more clear. Unfortunately I am getting the following error message: RuntimeError: ERROR 010240: Could not save raster dataset to C:\""\""\'SCRATCHWORKSPACE'.gdb\"OutName" with output format FGDBR Are you aware of any work-around? Thanks again! Matt
... View more
12-05-2013
01:48 AM
|
0
|
0
|
1041
|
POST
|
Thanks for posting, Xander. I have similar requirements to Marcin, but I with some complications. Firstly, I want the input raster (DEM in Marcin's example) to be multiplied only by values in which another field (column 2) of the table matches the filename of the input raster. Secondly, I want the output file to assume the name of another field of the table (values in column 1). And thirdly, I have multiple input rasters and would like to automate the process. To expand on Marcin's helpful input-output map: "input_ras" * "value_from_r c_[3]" (IF "value_from_r c[2]" = "input_raster_filename") = "[value_from_r c[1]" where r[] = row & c[] = column/field of the table. Is there any way to do all of these things in python? I would really appreciate any help!!!
... View more
12-04-2013
11:42 PM
|
0
|
0
|
1041
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|