POST
|
Hello, I have a series of models/scripts that create many temporary feature layers based on selection (using the MakeFeatureLayer tool), Since they are within models and scripttools they are not automatically loaded/visualized in my MXD (which is what I want). I was wonder if there is a way to programatically access and delete all these temporary layer files. I know I can use 'Delete' to see them and delete them individually, but Im curious if there is a way to access in ArcPy so I could loop through all layers that end in "_Layer" and delete (see below. I tried deleting everything in the 'in_memory' but that didnt remove them. I do not want to delete the underlying feature class, just the instance of the layer. When I manually delete the temporary layer using the delete tool, it does what I want (just deleting layer instance but maintaining data) Any help would be appreciated thanks! Neal
... View more
06-27-2020
06:16 AM
|
0
|
2
|
1529
|
POST
|
Hello, I have a script tool loaded into a custom toolbox in ArcMap. The script runs a bunch of sub-tools and creates a results layer. I have created a .lyr file with desired symbology for the output results, and am using simple code in the script tool to load the resultant layer (location is user parameter). See first code snippet below If I used the 'default' settings in my tool where it writes to a specific database, everything works fine, but if I change to a different database, when I try to apply symbology to output layer, I get following error message. It is suggeesting that layers do not match, but both are just simple polygons. Again, it works without issue, if I write to the 'default' database, only when I change the location of database does it give error. The really odd thing is it appears that it does apply the symbology, but has a broken source link. Any ideas of what may be going on? Thanks! Neal ---------------------BEGIN CODE SNIPPET TO LOAD LAYER AND APPLY SYMBOLOGY---------- outcurRskScrBldgsLyr = arcpy.MakeFeatureLayer_management(outcurRskScrBldgs,"zcurRiskScrBldgs") curMXD=arcpymap.MapDocument("CURRENT") df=arcpymap.ListDataFrames(curMXD)[0] lyr=arcpymap.Layer("zcurRiskScrBldgs") lyrfile=arcpymap.Layer(wksp+r"\_RARRSupportFiles\ArcGISLayerFiles\RARR_curRiskScrBldgs.lyr") arcpymap.AddLayer(df,lyrfile,"TOP") arcpy.ApplySymbologyFromLayer_management(lyr, lyrfile) ---------------------END CODE SNIPPER---------- ----------- BEGIN ERROR MESSAGE --------------- Traceback (most recent call last): File "C:\temp\RARR_OY1\_RARRSupportFiles\PythonScripts\RARR_CalcRskScr_Batch.py", line 171, in <module> arcpy.ApplySymbologyFromLayer_management(lyr, lyrfile) File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\management.py", line 6951, in ApplySymbologyFromLayer raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000968: The symbol layer does not match the input layer Failed to execute (ApplySymbologyFromLayer). -------------------------------- END ERROR MESSAGE --------------------------
... View more
06-23-2020
05:09 AM
|
0
|
1
|
804
|
POST
|
Hi David - thanks for the suggestion, but unfortunately trying to set the values didnt seem to work either. Ill look into the envelope option - that sounds promising. Thanks again
... View more
06-15-2020
12:41 PM
|
0
|
0
|
3222
|
POST
|
Hello I have a series of models. One of the models creates/overwrites a feature class based on a user selection of features. A second tool is trying to run an 'Union' tool using the extents of the feature class mentioned. Initially I had extents of feature class as an environment input into Union in my model, however, I found that I have to revalidate the model every time before I run, otherwise it just uses the same extents coordinates. I tried using the 'Calculate Value' saving value as 'Extent' object to recalculate the extent and use that everytime, but it doesnt work. It runs without errors but does not appear to use the extents Im trying to pass through. Ive tried several syntax options but none work. Any ideas on how to do this? Below is very simple model
... View more
06-15-2020
11:58 AM
|
1
|
7
|
3261
|
POST
|
Hello, I have simple model to create a file geodatabase. It uses model parameters to populate "default" values for folder location and FGD name. For the folder location, I am trying to use the "Current Workspace" geoprocessing environment as the default. If I run this in the model everything works fine. However, if I try to run through toolbox it gives me the red X and wont let me run - saying folder doesnt exist or is not support (error code of 000732). I know I have other models with variable substitution that run fine in toolbox, so not sure what is different. It will allow me to manually click the folder where current workspace point to, but that negates the point of have the default populate. Any insight would be greatly appreciated! Thanks Neal
... View more
06-13-2020
05:02 AM
|
0
|
1
|
670
|
POST
|
Hello, I have created a custom tool box that contains several tool sets an lots of individual models (see screenshot. To be able to batch run many of the individual tools, I have create a several simple script tools that basically run a series of the models in sequence. Even though my script tools are withing the same overall toolbox, it seems in order for ArcMap to recognize and run my custom models I have to import the toolbox first (using ImportToolBox) before running the scripttool If I dont, I get an error about 'module has no object'. I can work around this by importing the toolbox, but when sharing the tools, this can create some confusion if I hard code a path My main questions are: Is there a better way to handle this so I dont have to import toolbox explicity within script with a path to the custom toolbox Why would you have to load the toolbox if it is already loaded within my ArcMap session and I am calling the script tool from the same toolbox? Any insight would be greatly appreciated Thanks! Neal
... View more
05-13-2020
03:07 AM
|
0
|
1
|
642
|
POST
|
Hello, I have a floating point raster (representing hundreds of thousands of elevation cells) that I am trying to publish as colorized stretch raster. When I publish, the image service default colors is a black/white color ramp. Unlike feature layers where you can change symbology in ArcMap and then publish, I dont see how to change this at the service level definition. Is there a way to define a color ramp for a floating point raster at the service level? Thanks Neal
... View more
02-06-2020
06:26 AM
|
0
|
2
|
945
|
POST
|
I just realized my problem. Apparently some of the records in the table that I was calculating had null values. This seems to be throwing off numerical functions. I replace null with 0 values in the code and it is populating the field. Thank you Dan and Joshua for taking a look
... View more
11-11-2019
06:40 PM
|
1
|
0
|
1293
|
POST
|
def Calc(ScrA, ScrB, ScrC, ScrD, ScrE, ScrF, ScrG, ScrH, ScrI, ScrJ, ScrK, ScrL, ScrM, multN, multO, multP, multQ, ScrTot):
dicComMult={multN:"N", multO:"O", multP:"P",multQ:"Q"}
maxMult = max(dicComMult)
if maxMult > 1:
maxMultCom = dicComMult[max(dicComMult)]
ScrMult = round(ScrTot - (ScrTot / maxMult),1)
else:
maxMultCom='NA'
ScrMult = 0
lstCom = [("A", ScrA), ("B", ScrB), ("C", ScrC), ("D", ScrD), ("E", ScrE), ("F", ScrF), ("G", ScrG), ("H",ScrH), ("I", ScrI), ("J", ScrJ), ("K", ScrK), ("L", ScrL), ("M", ScrM), (maxMultCom,ScrMult)]
lstHCFs=[]
cumPctScr=0
for Com in lstCom:
PctScr = round(Com[1] / ScrTot * 100,1)
strlist=str(PctScr)
return "TEST" The code above returns "null" (not expected) when I run it The code below returns "TEST" (as expected) if I simply remove the round and division on line 15. I did not change any indentation in the field calculator def Calc(ScrA, ScrB, ScrC, ScrD, ScrE, ScrF, ScrG, ScrH, ScrI, ScrJ, ScrK, ScrL, ScrM, multN, multO, multP, multQ, ScrTot):
dicComMult={multN:"N", multO:"O", multP:"P",multQ:"Q"}
maxMult = max(dicComMult)
if maxMult > 1:
maxMultCom = dicComMult[max(dicComMult)]
ScrMult = round(ScrTot - (ScrTot / maxMult),1)
else:
maxMultCom='NA'
ScrMult = 0
lstCom = [("A", ScrA), ("B", ScrB), ("C", ScrC), ("D", ScrD), ("E", ScrE), ("F", ScrF), ("G", ScrG), ("H",ScrH), ("I", ScrI), ("J", ScrJ), ("K", ScrK), ("L", ScrL), ("M", ScrM), (maxMultCom,ScrMult)]
lstHCFs=[]
cumPctScr=0
for Com in lstCom:
PctScr = Com[1]
strlist=str(PctScr)
return "TEST"
... View more
11-11-2019
03:48 PM
|
0
|
1
|
1293
|
POST
|
Hello, I have a Python expression that utilizes a code block that I am trying to run as a field calculation (manual or with Field Calculator geoprocessing tool). The code runs without issue, but returns nulls even if I hard-code the return value to a simple string. I have tried going through line by line to better understand where/why it is not working. Best I can tell is it fails once I try to round a number. The code does include some lists, dictionaries, and loops, but it works fine when I run in an independent Python IDE with hardcoded input values. In the code snippet below, Ive hard coded the function just to return a "TEST" (see near bottom), but it return null. If I take out the line with round statement it does at least return "TEST". I think Ive checked all my indentation, but cant think of anything else that may be causing the issue Does field calculator have any limitations with lists, loops, etc.? Any ideas what may be causing this? Any thoughts would be greatly appreciated! Thanks Neal -------------------- Code Snippet --------- def Calc(ScrA, ScrB, ScrC, ScrD, ScrE, ScrF, ScrG, ScrH, ScrI, ScrJ, ScrK, ScrL, ScrM, multN, multO, multP, multQ, ScrTot): dicComMult={multN:"N", multO:"O", multP:"P",multQ:"Q"} maxMult = max(dicComMult) if maxMult > 1: maxMultCom = dicComMult[max(dicComMult)] ScrMult = round(ScrTot - (ScrTot / maxMult),1) else: maxMultCom='NA' ScrMult = 0 lstCom = [("A", ScrA), ("B", ScrB), ("C", ScrC), ("D", ScrD), ("E", ScrE), ("F", ScrF), ("G", ScrG), ("H",ScrH), ("I", ScrI), ("J", ScrJ), ("K", ScrK), ("L", ScrL), ("M", ScrM), (maxMultCom,ScrMult)] lstHCFs=[] cumPctScr=0 for Com in lstCom: val=round(Com[1],1) strlist=str(val) return "TEST" ------------------------------------------------
... View more
11-11-2019
01:41 PM
|
0
|
4
|
1396
|
POST
|
Hello - I must be missing something easy. I have a raster that I published as an image service. Everything seems normal, but when I load the image service in an AGOL map, there is no option to "Configure Popups" which would allow me to click on the raster and see the cell values (see graphic below). I have another image service that I published a while back that appears to have the same/similar service settings which works fine. I cant see what Im doing different that is not allowing me to configure. Any pointers would be greatly appreciated Thanks! Neal
... View more
09-10-2019
06:20 AM
|
0
|
0
|
304
|
POST
|
Ok after tinkering around I think I have a workaround to keep me going, but still doesnt answer why what I have doesnt work. What I ended up doing was using the 'Calculate Value' tool in model building to build the name of the feature class. I linked the derived output as a precondition. In my case my script tool used the 'Create Feature Class' tool based on user input of workspace and output feature class name. The script tool created and populates the resultant feature class. Based on your example I think this approach will work. Just note that the 'Calculate Value' tool uses some pretty funny syntax - for strings you have to enclose them in "" in addition to the in-line variables %. Below are some screenshots.
... View more
07-29-2019
06:23 PM
|
1
|
1
|
3074
|
POST
|
I also have this issue and just posted a similar question (before I saw your post). I still dont understand why the SetParameterAsText doesnt work, but think I found a work around that allows me to use the derived output from the script tool in subsequent Model Builder. What I ended up doing was using the 'Calculate Value' tool in model building to build the name of the feature class. I linked the derived output as a precondition. In my case my script tool used the 'Create Feature Class' tool based on user input of workspace and output feature class name. The script tool created and populates the resultant feature class. Based on your example I think this approach will work. Just note that the 'Calculate Value' tool uses some pretty funny syntax - for strings you have to enclose them in "" in addition to the in-line variables %. Below are some screenshots.
... View more
07-29-2019
06:21 PM
|
2
|
1
|
3104
|
POST
|
Hello I have Python script tool that creates (and populates) and point feature class using the 'Create Feature Class' tool. The script tool exposes input parameters for the input workspace and the name of the output feature class. The actual full feature class path/name is created constructed in the script tool Im wanting to embed the script tool into a ModelBuilder model so that I can perform additional operations on the output point feature class, but am having issues. Following the examples, I added a 'Derived Output' parameter in the script tool definition/properties and use the 'SetParameterAsText' function to explicitly set the output feature class path/name. However, when I run the model, it doesnt seem to recognize the output feature class and wont perform and functions. See graphics below. I feel like I must be missing obvious - any help would be appreciated! Thanks Neal
... View more
07-29-2019
05:38 PM
|
1
|
3
|
3444
|
POST
|
That is very helpful. I really appreciate your time in help me working through this
... View more
06-15-2019
05:23 PM
|
0
|
0
|
2670
|
Title | Kudos | Posted |
---|---|---|
3 | 09-10-2022 07:03 AM | |
1 | 07-29-2019 05:38 PM | |
1 | 07-29-2019 06:23 PM | |
1 | 06-15-2020 11:58 AM | |
1 | 09-12-2022 04:05 AM |
Online Status |
Offline
|
Date Last Visited |
02-13-2024
11:20 AM
|