|
POST
|
Nice work. Might need to change your import syntax though if you want to make the toolboxes publishable as GP Services. I think this might still be an issue. https://community.esri.com/t5/arcgis-pro-questions/not-all-scripts-copy-to-server-when-publishing-gp/m-p/1151555
... View more
10-02-2023
11:37 PM
|
2
|
1
|
3040
|
|
POST
|
The way I do it is to check if parameter.altered and not parameter.hasBeenValidated. From the help: altered altered is true if the value of a parameter is changed... Once a parameter has been altered, it remains altered until the user empties (blanks out) the value, in which case it returns to being unaltered. hasBeenValidated hasBeenValidated is false if a parameter's value has been modified by the user since the last time updateParameters and internal validate were called. Once internal validate has been called, geoprocessing automatically sets hasBeenValidated to true for every parameter. hasBeenValidated is used to determine whether the user has changed a value since the last call to updateParameters. Re your questions: Altered is has the user changed the value (see above) and yes you can have altered and UNvalidated. After a value is changed, internal (basic ArcGIS) validation happens which doesn't change "hasBeenValidated", then UpdateParameters is called. valueAsText/value is if you need to access the actual value of the parameter (as an object or as text) e.g. to check it or to use it for something else - for example to populate a filter list Something like: def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if self.params[0].altered and not self.params[0].hasBeenValidated:
etc...
... View more
09-10-2023
03:13 PM
|
0
|
0
|
2959
|
|
POST
|
Another way would be to Combine (Spatial Analyst) the 3 bands. You need to add them to the map (or tool) separately, not as the tif. e.g. The output will contain the RGB values as fields. You can then add a class field which you can update from the known RGB values:
... View more
09-05-2023
07:06 PM
|
0
|
0
|
5389
|
|
POST
|
I downloaded a couple. They're definitely 3 band RGB (tested with GDAL and QGIS as well) with no attributes. I think it's just a poor choice of output format by the authors. However, it's a very simple classification: 255,0,0 = Building 133,133,133 = Road 128,236,104 = Grass/Shrub 34,139,34 = Tree canopy etc...
... View more
09-05-2023
01:15 AM
|
0
|
1
|
5439
|
|
POST
|
@TobiasWalter wrote: I have a DEM raster for Germany with about 2000 pixels. A "value" that describes the altitude below or above the sea level is attached to each individual pixel in the attribute table that I gained access to when I converted the raster from float to integer using the Int-tool. You probably have more than 2000 pixels. Have a look at the attribute table, you'll see value and count columns. The count column has the number of pixels in the raster that have the corresponding value. Unless every one of the 2000 records has a count of 1, then you have more than 2000 pixels (sum up the counts to get the total, excluding any nodata pixels). If your attribute field is integer or string, just specify it as the field to copy to the output in the Raster to Polygon tool. If your attribute field is neither integer or string, after you convert the raster to polygon, use the Join Field tool to copy the field across, you don't have to have the same number of rows. Alternatively, you can run Dissolve (or Pairwise Dissolve) on the output, then join.
... View more
09-02-2023
01:13 AM
|
0
|
0
|
1874
|
|
POST
|
I think feature class names need to use ascii characters only. From the help:
... View more
08-30-2023
09:23 PM
|
0
|
0
|
2096
|
|
POST
|
@AlfredBaldenweck wrote: Each feature dataset is considered its own environment by arcpy, so functions like Walk() and ListFeatureClasses() will ignore stuff in a feature dataset if run on a geodatabase. Not quite right for Walk. You just need to keep iterating through the Walk results. Any feature datasets are considered workspaces, so Walk will recurse to them and return their contents.
... View more
08-30-2023
02:52 PM
|
0
|
1
|
2110
|
|
POST
|
Works for me in ArcMap 10.8.2. Given a FGDB with 2 FCs, "A" and "B" with "B" in feature dataset "FD": import arcpy
for parent, workspaces, datasets in arcpy.da.Walk("Default.gdb"):
print("parent: %s"%parent)
print("workspaces: %s"%workspaces)
print("datasets: %s"%datasets) Output showing that "B" is listed correctly in the feature dataset "FD": parent: Default.gdb
workspaces: [u'FD']
datasets: [u'A']
parent: Default.gdb\FD
workspaces: []
datasets: [u'B']
... View more
08-30-2023
02:45 PM
|
0
|
1
|
2110
|
|
POST
|
Perhaps try running the Check (or Repair) Geometry tool.
... View more
08-28-2023
03:31 AM
|
2
|
1
|
3322
|
|
BLOG
|
Hmmm "Python in Excel runs on the Microsoft Cloud with enterprise-level security as an M365 connected experience". What about people who don't have a M365 subscription who receive a Python powered spreadsheet....? More info including some limitations here.
... View more
08-24-2023
03:37 PM
|
0
|
0
|
438
|
|
POST
|
Yes, it's because you are trying to open data that you don't have stored on your computer (or is stored in a different location than the layer is looking for the data in). A layer file (*.lyrx") does not contain the data, it just contains a link to the datasource (e.g shapefile, geodatabase feature class or raster etc) plus the symbology, definition query, labelling etc. The exclamation point is telling you that Pro can't find the datasource the layer file is linked to. It doesn't mean that Pro can't find the layer file itself. You should ask the 3rd party to share their data as well as the layer file, either in it's original format or as a layer package (*.lpkx).
... View more
08-24-2023
01:50 PM
|
4
|
0
|
15749
|
|
POST
|
@BlakeTerhune wrote: Oh, that's an interesting idea. Could you share a sample of your calling script? Script tool (scripttool.py) import arcpy
def main(parameter1, parameter2):
#do something with parameters
return
if __name__ == "__main__":
#this won't get run when imported
param1 = arcpy.GetParameterAsText(1)
param2 = arcpy.GetParameterAsText(2)
main(param1, param2) Test script (test.py) import scripttool
# Some hardcoded path for debugging
parameter1 = "D:/Temp/test2.shp"
parameter2 = "D:/Temp/test2.shp"
scripttool.main(parameter1, parameter2):
... View more
08-11-2023
05:19 PM
|
2
|
0
|
5870
|
|
POST
|
As you get into more complicated scripts, one way is to do all your testing and debugging in a proper IDE such as PyCharm or Visual Studio Code. Keep all the logic in functions (just as you've got in your screenshot) and then either in the if __name__ == "__main__": block comment out the arcpy.GetParameterAsText lines and replace with hardcoded values and run in the IDE debugger, or leave your script as-is, create a test/debug script that imports your script and calls the function with hardcoded values and run the test/debug script in the IDE debugger.
... View more
08-11-2023
03:42 PM
|
2
|
3
|
5879
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-24-2022 03:08 PM | |
| 1 | 07-30-2025 03:00 PM | |
| 1 | 06-10-2025 08:06 PM | |
| 5 | 05-20-2025 07:56 PM | |
| 1 | 05-04-2025 10:34 PM |