|
POST
|
Dan, this is great! And now i'm learning about NumPy Data type objects. One thing: I'm getting an error which I'm guessing is a result of something specific with the raster I'm using. out['Value'] = uniq
Traceback (most recent call last):
File "<string>", line 1, in <module>
ValueError: Can't cast from structure to non-structure, except if the structure only has a single field. Conceptually, I understand what you're doing with your example. Thanks! EDIT: I uploaded some sample raster data to my original post.
... View more
01-31-2019
06:54 AM
|
0
|
2
|
5799
|
|
POST
|
I have a previously reclassified raster file which I run a simple process on and then need to generate a very basic report about the percentages of each class. I'm able to calculate the total count for each raster value/class using summary stats and was wondering if there's a way to skip summary stats and accomplish this with NumPy instead? Here's a sample code: import arcpy
import pandas as pd
InRaster = "SomeSingleBandRaster" ##This raster was reclassified to have 4 classes##
OutGDB = arcpy.env.scratchGDB
SlopeReport = OutGDB + '/' + "SlopeReport"
StatsTable = OutGDB + '/' + "StatsTable"
#Generate Summary Statistics#
arcpy.analysis.Statistics(InRaster, StatsTable, "Value SUM", "Count")
#Create array and calculate percentate of each class
array = arcpy.da.TableToNumPyArray(StatsTable, ['Count','SUM_Value'])
df = pd.DataFrame(array)
df['perc'] = df["Count"] / df["Count"].sum() * 100
print(df) This will generate the following output: Count SUM_Value perc
0 5.0 4.0 0.198255
1 274.0 3.0 10.864393
2 1057.0 1.0 41.911182
3 1186.0 2.0 47.026170 This works but I'm always eager to cut out unnecessary steps (while hopefully learning something in the process!) Thanks!
... View more
01-30-2019
11:51 AM
|
0
|
9
|
6335
|
|
POST
|
Joshua Bixby Dan Patterson Darren Wiens Hi everyone, I wanted to thank you for your help and also give you a bit of an update. Here's what I know to date: Today Esri Support verified there was a bug for this tool. BUG ID: BUG-000117445 Synopsis: The Save To Layer File management tool fails and returns Error 999999 when run from the Python IDLE window in ArcGIS Pro. Status: New We confirmed that this tool also fails when used in a script tool The current ArcGIS Pro documentation is still outdated and referencing working with .lyr files. I was able to find a workaround using 'saveACopy' as part of the arcpy mapping module layer class. Here is a quick example: #Import Modules
import arcpy, os
#Variables
Date = time.strftime("%m%d%Y")
OutputFolder = "D:\\TEMP"
LayerName = "SoilsMUID_" + Date + ".lyrx"
ExportLayer = os.path.join(OutputFolder, LayerName)
#Setup Map Document Info
aprx = arcpy.mp.ArcGISProject("Path to your aprx file")
map = aprx.listMaps("Soils")[0]
SoilsLyr = map.listLayers('SoilsMUID')[0] ##This layer's data source is a shapefile
#Export Layer File
arcpy.AddMessage("Exporting Layer File to {0}".format(ExportLayer))
SoilsLyr.saveACopy(ExportLayer)
... View more
01-24-2019
11:58 AM
|
1
|
1
|
1216
|
|
POST
|
Joshua Bixby this is very helpful from a diagnostic perspective. Thanks a bunch!
... View more
01-18-2019
10:19 AM
|
0
|
0
|
1216
|
|
POST
|
Dan Patterson Dan, that makes perfect sense! So, now I'm wondering why (regardless of the script tool) the tool works one way but not the other in Pro? I don't know if that's a bug or hints at one, or possibly that there is indeed something wrong with the inputs since arcpy.management.SaveToLayerFile Returns a 000622 error. Also, I failed to answer one of Dan's original questions which was if the map project was open. When I run the code from the python window setting the aprx to 'CURRENT' it works fine. However...when I run the code in the python window from another map project and set the aprx to the full file path of the closed project, then I get the same error as in my script tool! So that's something there.
... View more
01-18-2019
05:11 AM
|
0
|
0
|
3502
|
|
POST
|
Dan Patterson I didn't expect this thread to morph like this so I should probably rename the title. I'm still curious what the difference between arcpy.mangement.{tool} vs arcpy.{tool}_management
... View more
01-17-2019
12:01 PM
|
0
|
6
|
3502
|
|
POST
|
I like your thinking in eliminating that, but that also failed with a 999999 error (Curiously, looking up a 999999 error I expected it to say "This is the most informative error code ever!"...sadly it did not).
... View more
01-17-2019
11:18 AM
|
1
|
0
|
3502
|
|
POST
|
Dan, I didn't expect that it will return a full path for a file on disk since I'm using the listLayers method for a layer within the map. I modified the message per your request and got the following from the script tool. Again, if we comment out the SaveToLayerFile the script goes on to use SoilsLyr for several other things just fine so it sure seems the script has access to that as an input just fine? arcpy.SelectLayerByAttribute_management(SoilsLyr, "NEW_SELECTION")
mf.zoomToAllLayers(True,True)
arcpy.SelectLayerByAttribute_management(SoilsLyr, "CLEAR_SELECTION")
mf.camera.setExtent(mf.getLayerExtent(SoilsLyr,True, True))
... View more
01-17-2019
10:52 AM
|
0
|
2
|
3502
|
|
POST
|
Ah, yes...important clarifications. Sorry if i wasn't specific enough...I thought Esri was calling the 'python window' the built-in interface...well, at least that's what they called it in ArcMap. But yes: built-in interface in ArcGIS Pro...no console. 2 separate issues but I'll focus on your questions first. If I run the the code from the 'python window' the layer file is exported just fine...within the script tool it fails with a 999999 error. One thing to keep in mind here is that these inputs are used elsewhere in the script tool just fine. But let me try to pare this down to what's relevant here. #Import Modules
import arcpy, os
#Variables
Date = time.strftime("%m%d%Y")
OutputFolder = "D:\\TEMP" ##In the script tool this is exposed as a parameter and not hard-coded.
LayerName = "SoilsMUID_" + Date + ".lyrx"
ExportLayer = os.path.join(OutputFolder, LayerName)
#Setup Map Document Info
aprx = arcpy.mp.ArcGISProject("CURRENT") ##In the script tool, this points to an aprx file using the full path.
map = aprx.listMaps("Soils")[0]
SoilsLyr = map.listLayers('SoilsMUID')[0] ##This layer's data source is a shapefile
#Export Layer File
arcpy.AddMessage("Exporting Layer File to {0}".format(ExportLayer))
arcpy.SaveToLayerFile_management(SoilsLyr, ExportLayer) In the script tool (if the SaveToLayerFile is commented out), the tool goes on to select the in_layer, zoom to it, and some other stuff and then a PDF is exported no problem. FWIW, I also tried to create a feature layer from SoilsLyr and then pass that to SaveToLayerFile_management (unneeded but worth a try) and that fails as well.
... View more
01-17-2019
10:24 AM
|
0
|
11
|
3502
|
|
POST
|
I'm seeing some different behavior here in ArcGIS Pro. In this particular case I'm using arcpy.SaveToLayerFile_management(in_layer,out_layer) [Curiously, this works in the python command window but fails in a script tool]. When I try arcpy.management.SaveToLayerFile(in_layer, out_layer) in the python window with the same parameters the tool fails with an 000622 error. I tried to supply the other optional parameters but it still failed.
... View more
01-17-2019
06:53 AM
|
0
|
13
|
5137
|
|
POST
|
We are looking to extend our ArcGIS Enterprise environment to additional divisions of our company which operate in an only somewhat overlapping capacity. All of our users authenticate the same way (against our AD), and each division would (eventually) be generating some of their own content. There are not proprietary issues at stake here, but the challenge is more organizational in nature. Are 'Groups' the right solution for this, or should we be thinking more about 'Sites' in Enterprise. Thanks!
... View more
01-10-2019
12:02 PM
|
0
|
2
|
1158
|
|
POST
|
We are looking to extend our ArcGIS Enterprise environment to additional divisions of our company which operate in an only somewhat overlapping capacity. All of our users authenticate the same way (against our AD), and each division would (eventually) be generating some of their own content. There are not proprietary issues at stake here, but the challenge is more organizational in nature. Are 'Groups' the right solution for this, or should we be thinking more about 'Sites' in Enterprise. Thanks!
... View more
01-10-2019
12:01 PM
|
0
|
2
|
881
|
| Title | Kudos | Posted |
|---|---|---|
| 9 | 03-24-2026 11:41 AM | |
| 1 | 11-06-2024 06:58 AM | |
| 1 | 12-16-2022 07:01 AM | |
| 1 | 08-09-2024 06:55 AM | |
| 1 | 08-13-2024 05:58 PM |
| Online Status |
Offline
|
| Date Last Visited |
03-24-2026
12:51 PM
|