|
POST
|
When posting answers, I've been intermittently getting a message about invalid HTML being changed. Nothing appears to have been changed and if I retry to submit, I get the same message. This is even with plain text, no code, no images, or links. I figured out that I could edit the raw HTML directly and submit the post (get rid of the span tags), but still a bit of a pain. Not sure how I managed to get the rich text editor to add those span tags. Next time it happens, I'll try and nail down what I did while editing to make this reproducible.
... View more
03-26-2021
12:21 AM
|
0
|
3
|
1650
|
|
POST
|
If you've put in a *.gdb folder, don't. In fact never put anything into a .gdb using non-ArcGIS tools. They're a geodatabase, not a folder and ArcGGIS won't see any non database files in there. If you didn't actually copy them into a .gdb, but into a non gdb folder, then you may just need to right click the folder (from within Pro, i.e using the catalog pane) and select refresh
... View more
03-25-2021
09:31 PM
|
2
|
0
|
2562
|
|
POST
|
You're right, should've tested my example, the "+=" will fail with UnboundLocalError: local variable 'somevar' referenced before assignment because it's trying to create a local scope variable from a local scope variable which doesn't exist. Regardless, if you assign a value to a variable in the function without declaring it as a global, it will "shadow" (replace) the global in the function, but not update the global. somevar = 0
def test1():
somevar = 111
return somevar
def test2():
global somevar
somevar = 111
return somevar
print('global', somevar, 'local', test1())
print('global', somevar, 'local', test1(), "global somevar has not changed")
print('global', somevar, 'local', test2())
print('global', somevar, 'local', test2(), "global somevar has been updated")
... View more
03-25-2021
05:25 PM
|
2
|
1
|
5377
|
|
POST
|
The Q. "What are the rules for local and global variables in Python?" in @DanPatterson's link explains: If a variable is assigned a value anywhere within the function’s body, it’s assumed to be a local unless explicitly declared as global. In the 1st example, your global i gets assigned a value and thus overwritten in each loop iteration, so must be declared as a global otherwise it would get replaced by a local variable. In the 2nd example, you are not assigning a value to uniqueList (and thus overwriting the initial global var with a local var), you are calling the append method of an existing global. This is one reason I avoid globals, too easy to introduce bugs.
... View more
03-25-2021
03:25 PM
|
2
|
4
|
5390
|
|
POST
|
Looks like the folder r"C:\EsriTraining\PythEveryone\CreatingScripts" doesn't exist. Based on the bit of your error message that shows the name of your script, it should be r"C:\EsriTraining\PythEveryone\PythEveryone\CreatingScripts\SanDiegoUpd.txt" Note the "PythEveryone\PythEveryone"
... View more
03-24-2021
06:35 PM
|
0
|
1
|
2934
|
|
POST
|
One suggestion is to use 2 parameters, one a DEFile and the other GPBoolean. Have parameter validation set to clear one when the other is altered. Something like: # -*- coding: utf-8 -*-
import arcpy, os
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the .pyt file)."""
self.label = "Toolbox"
self.alias = ""
# List of tool classes associated with this toolbox
self.tools = [Tool]
class Tool(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
"""Define parameter definitions"""
param0 = arcpy.Parameter(displayName="Current Pro-Document",
name="currentProDocument",
datatype="GPBoolean",
parameterType="Optional",
direction="Input")
param1 = arcpy.Parameter(displayName="Other Pro-Document",
name="otherProDocument",
datatype="DEFile",
parameterType="Optional",
direction="Input")
param1.filter.list = ['aprx']
param2 = arcpy.Parameter(displayName="Layout",
name="inlayout",
datatype="GPString",
parameterType="Required",
direction="Input")
params = [param0, param1, param2]
return params
def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a
parameter has been changed."""
if parameters[1].altered and not parameters[1].hasBeenValidated:
parameters[0].value = False
parameters[2].value = None
parameters[2].filter.list = []
prodoc = parameters[1].valueAsText
elif parameters[0].value and parameters[0].altered and not parameters[0].hasBeenValidated:
parameters[1].value = None
parameters[2].value = None
parameters[2].filter.list = []
prodoc = 'CURRENT'
else:
prodoc = None
if prodoc is not None:
aprx = arcpy.mp.ArcGISProject(prodoc)
layout_list = [l.name for l in aprx.listLayouts()]
parameters[2].filter.list = layout_list
return parameters
def execute(self, parameters, messages):
"""The source code of the tool."""
aprx = arcpy.mp.ArcGISProject(parameters[0].valueAsText)
arpxPath = str(os.path.normpath(aprx.filePath))
arcpy.AddMessage(f"Pro-Doc Path: {arpxPath}")
return
... View more
03-22-2021
09:46 PM
|
1
|
0
|
5594
|
|
POST
|
You are passing a feature class to SelectLayerByAttribute and not using the returned feature layer (which has the selection applied). And then passing the original feature class to the next tool. Feature classes are the actual data (on disk, in a geodatabase, in the cloud, etc.) and in ArcGIS can't have selections (or symbology, joins, etc.). Feature layers are a representation of a feature class that are a link to the feature class and can also have selections (and symbology, joins, etc.).
... View more
03-22-2021
03:33 PM
|
2
|
0
|
4116
|
|
POST
|
Perhaps use DEFile and only allow aprx files using a filter: def getParameterInfo(self):
param0 = arcpy.Parameter(
displayName="Input Project",
name="in_project",
datatype="DEFile",
parameterType="Required",
direction="Input")
# set the filter list to a list of file extension names
param0.filter.list = ['aprx']
... View more
03-22-2021
02:02 PM
|
1
|
1
|
5610
|
|
POST
|
You need to pass a feature class not an ArcGIS Pro aprx file as the output.
... View more
03-21-2021
10:29 PM
|
0
|
0
|
4037
|
|
POST
|
One more option which works with ArcGIS Pros arcgispro-py3 python environment Save and run the fgddem.py script from https://gist.github.com/minorua/4993166. D:\Temp\jpgis> activate arcgispro-py3
(arcgispro-py3) D:\Temp\jpgis> python fgddem.py
No input files selected
=== Usage ===
python fgddem.py [-replace_nodata_by_zero] [-f format] [-out_dir output_directory] [-q] [-v] src_files*
src_files: The source file name(s). JPGIS(GML) DEM zip/xml files.
(arcgispro-py3) PS D:\Temp\jpgis> python fgddem.py -f GTIFF -out_dir . FG-GML-4930-01-20-DEM5A-20161001.xml
translating FG-GML-4930-01-20-DEM5A-20161001.xml
completed
... View more
03-18-2021
02:30 PM
|
1
|
1
|
7865
|
|
POST
|
Have a look at "demtool" for converting Japanese GML DEMs: https://github.com/tmizu23/demtool https://www.ecoris.co.jp/contents/demtool.html
... View more
03-18-2021
01:57 AM
|
1
|
0
|
5834
|
|
POST
|
@DanPatterson wrote: Also, no matter how I try every line has a line break after every number so it doesn't comply with the header, so compare the "worked" vs the "didn't work" The use of space or newline separators doesn't matter as long as the number of values = NCOLS x NROWS.
... View more
03-17-2021
04:45 AM
|
0
|
0
|
5869
|
|
POST
|
Your A01-20-DEM5A.asc is corrupt. The header specifies NCOLS 225 and NROWS 150 which means you should have exactly 33750 (225x150) values in your asc file, but there are only 16063 values. If I pad out the file so there are 33750 values, then the file will convert (but obviously is missing lots of actual data). See below (I've used black to represent -9999, blue for data values and green for the padding values that I added just to demonstrate).
... View more
03-17-2021
01:40 AM
|
1
|
4
|
5872
|
|
POST
|
arcpy.env.workspace = inPut is correct, you set the workspace to a path inPut = arcpy.env.workspace is wrong, you are setting your inPut variable to whatever the workspace is (which will be None if you haven't set it previously)
... View more
03-12-2021
04:13 AM
|
0
|
0
|
4161
|
|
POST
|
That's because @Anonymous User points out, you need to pass the full filepath: with open(os.path.join(inPut, out), "w") as k:
k.write('Hellow') Note, the above will overwrite your original files. If you want to append to the existing files, use the 'a' argument to open: with open(os.path.join(inPut, out), "a") as k:
k.write('Hellow')
... View more
03-12-2021
03:46 AM
|
2
|
0
|
4207
|
| 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 |