POST
|
I've changed the print statement a bit just to print the length of the varLyrs list and found that it is 0 (see screenshot below). Then realized that I've accidentally deleted my wild card symbol in my ListLayers parameter. So after adding it back in, the script works fine now! Thanks so much, Dan, really appreciate your help!
... View more
04-08-2016
11:02 AM
|
0
|
0
|
427
|
POST
|
That makes sense I've replaced the print statement with the one you suggested but then I got a syntax error for the for loop line, which has never came up before...
... View more
04-08-2016
10:34 AM
|
0
|
0
|
427
|
POST
|
Thanks for the suggestion, Dan! I've installed and loaded the code into PyScripter, changed all the tabs to spaces, and added some print statements. Then I ran it in Pyscripter, and found that the code only runs until it hits the for loop then it stops. Any idea why it doesn't go into the for loop? I've put a screenshot below. This is probably something obvious - does ArcMap need to be running when I run this script? I have been opening the mxd in arcmap before I run this code. So I'm wondering if that has anything to do with this...
... View more
04-08-2016
10:12 AM
|
0
|
3
|
427
|
POST
|
I have been using a python code to automate some mapping by loading the python script onto the GIS (10.2) python window and pressing Return to get it to start running. It has been working but for some reason the next time I loaded the code into the python window and pressed Return, instead of the code running, it went straight back to a command prompt. I cannot figure what has changed for this code to no longer get executed. Please help! Any suggestions would be very very helpful! import arcpy
import numpy as np
mxd = arcpy.mapping.MapDocument("Current")
lstDataFrames=arcpy.mapping.ListDataFrames(mxd)
varLyrs = arcpy.mapping.ListLayers(mxd,'_Wt_norm*')
var_list = np.arange(0,16)
for ilyr in varLyrs:
var_n = ilyr.name[:2].upper()
for i in var_list:
outpath = r"F://GIS_Data//SOM//Results_12Var4by4//Maps//" + var_n + "_N" + i + "_Norm.jpg"
arcpy.ApplySymbologyFromLayer_management(ilyr, r"F://GIS_Data//Arcpy//SOM_Norm_Default.lyr")
ilyr.symbology.valueField = "N" + str(i)
ilyr.visible = True
arcpy.mapping.ExportToJPEG(mxd, outpath)
print("Node ", i)
ilyr.visible = False
... View more
04-07-2016
09:33 PM
|
0
|
5
|
2426
|
POST
|
Thank you Dan! I'll change my directories to have no space to be safe - can't rely on luck!
... View more
06-16-2015
01:59 PM
|
0
|
0
|
673
|
POST
|
Thank you so much for all your advice and responses! Sorry for the delayed reply - I haven't had access to this GIS machine again until today. To my surprise, I used the same syntax as I did last week and it got executed successfully as below. Any suggestions to what may have changed? Darren and Dan - Last week before I posted this message, I have also tried the syntax you have suggested (i.e. including the where clause) but I got the same error. However, when I tried again today, it worked also as shown below. What I have found interesting was that when I took out the space between the = and 0, it no longer works
... View more
06-16-2015
10:30 AM
|
0
|
2
|
673
|
POST
|
Hi Everyone, I'm using the expression below to try convert all the values that are negative or equal to zero to NoData SetNull("cov_fdg_ct" <= 0,"cov_fdg_ct") But it failed to execute with the error message below: Executing: RasterCalculator SetNull("cov_fdg_ct" <= 0,"cov_fdg_ct") "E:\GIS Data\Thesis modeling\FloodDepthGrids\cov_fdg_c"
Start Time: Fri Jun 12 17:49:33 2015
SetNull("cov_fdg_ct" <= 0,"cov_fdg_ct")
ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 5, in rcexec
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\sa\Functions.py", line 320, in SetNull
where_clause)
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\sa\Utils.py", line 47, in swapper
result = wrapper(*args, **kwargs)
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\sa\Functions.py", line 309, in Wrapper
["SetNull", in_conditional_raster, in_false_raster_or_constant])
RuntimeError: ERROR 000732: Input Raster: Dataset cov_fdg_ct does not exist or is not supported
Failed to execute (RasterCalculator).
Failed at Fri Jun 12 17:49:34 2015 (Elapsed Time: 0.16 seconds) I've been reading many posts from those who also got the ERROR 000539 and most of them seem to be due to a syntax error. However, I can't seem to figure out what syntax error is in my simple expression. It would be much appreciated if you can provide some advice! Thank you!
... View more
06-12-2015
06:03 PM
|
0
|
14
|
7803
|
POST
|
The forum had two different solutions... although there's one that most people found helpful, I found the other one had helped me. So should give both a try...
... View more
02-25-2015
02:23 PM
|
1
|
0
|
788
|
Title | Kudos | Posted |
---|---|---|
1 | 02-25-2015 02:23 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|