POST
|
Hi, I'm attempting to run a simple canopy height model (CHM) using a surface and bare-earth terrain model. I figured it would be quicker to do this in numpy, so I am using the RasterToNumPyArray methods in arcpy: import arcpy
import os
arcpy.CheckOutExtensions('Spatial')
arcpy.env.overwriteOuptut = True
datadir = 'D:/Data'
dsm = os.path.join(datadir, 'dsm.tif')
dtm = os.path.join(datadir, 'dtm.tif')
arcpy.env.outputCoordinateSystem = dsm
arcpy.env.cellSize = dsm
dsm_arr = arcpy.RasterToNumPyArray(dsm, nodata_to_value=0)
dtm_arr = arcpy.RasterToNumPyArray(dtm, nodata_to_value=0)
diff_arr = dsm_arr - dtm_arr
# Set things below 2m difference to 0
diff_arr[diff_arr < 2] = 0
diff = arcpy.NumPyArrayToRaster(diff_arr, value_to_nodata=0)
diff.save(os.path.join(datadir, 'diff.tif'))
arcpy.CheckInExtension('Spatial') The result is that the diff.tif output is way off. The cell sizes are right, the SRS remains the same, and relatively speaking the values are correct (it's dropping negligible values I don't care about), but the georeferencing is off by thousands of miles. What am I doing wrong? Do I need to explicitly feed in a corner or extent? If so, how would I do that?
... View more
03-14-2023
12:03 PM
|
0
|
2
|
1024
|
IDEA
|
When getting a single extent, the polygon property returns the object as a multipolygon rather than a polygon. Extents are simple geometry consisting of 5 points (4 + origin to close). They are not complex geometry and do not need to be returned as multipolygons. However, when I do something like this: p = arcpy.mp.ArcGISProject("CURRENT")
wkt = p.activeView.camera.getExtent().polygon.WKT it returns, somewhat oddly: MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0))) When what ought to be returned should be in the format (notice, no spaces between the primitive and the double open-parentheses): POLYGON((0 0, 1 0, 1 1, 0 1, 0 0)) Generally I just use regex to fix this but my OCD finally forced me to request this as an Idea...hopefully a simple fix, thanks!
... View more
01-09-2023
09:42 AM
|
3
|
0
|
924
|
POST
|
Oh, yikes I didn't realize this was something from modelbuilder. I am an infant in MB. I would probably go with writing a python toolbox (*.pyt) which gives you more control over the workflow and parameters. What exactly is this supposed to do? I could write up a quick example for you; it would be easier to read and maintain.
... View more
01-05-2023
02:05 PM
|
0
|
1
|
1265
|
IDEA
|
No, this isn't a joke. I just discovered that when you try to add an Esri JSON file as a new hosted feature layer, ArcGIS Enterprise throws an error and demands GeoJSON. While GeoJSON is a perfectly great transfer format for spatial data, Esri JSON contains full schema information for replicating a layer - datatypes and so forth. Whereas in GeoJSON you lose all that. Esri, I can't believe I'm asking you to please support your own format, but can we make this happen?
... View more
01-05-2023
02:00 PM
|
9
|
0
|
434
|
POST
|
Hi Nicole, Could you post the code of BatchSelectLayerByLocation which appears to reside in Default.tbx? It's citing two lines in there that I'm guessing are not reading parameters correctly.
... View more
01-05-2023
12:27 PM
|
0
|
4
|
1285
|
IDEA
|
I do appreciate this but would like to stay away from extras like the massive Data Interop extension. As an Idea, it has precedent (as 3d export of multipatch is already supported) and is a logical evolution of the Multipatch to Collada tool.
... View more
01-04-2023
10:11 AM
|
0
|
0
|
3901
|
POST
|
@Anonymous User Thanks for this! I ran into this same issue in a larger geoprocessing tool where I wanted to display rapid, ephemeral results and the IO expense really hurt user experience. Based on your solution I threw together a helper function that I reference in a bunch of scripts now: def memory_to_active_map(self, memory_fc):
active_map = arcpy.mp.ArcGISProject("CURRENT").activeMap
lyr_result = arcpy.MakeFeatureLayer_management(
memory_fc, arcpy.Describe(memory_fc).name)
mem_lyr = lyr_result.getOutput(0)
return active_map.addLayer(mem_lyr)[0]
... View more
01-03-2023
01:36 PM
|
4
|
0
|
549
|
IDEA
|
@JohXENIE There is a way to go smoothly from a terrain/image raster combo to a glb that Blender handles beautifully, but it involves using QGIS and the Qgis2three.js plugin. This is my current workflow but it causes me to have to maintain extra software. If you want more info just message me privately.
... View more
01-02-2023
03:31 AM
|
0
|
0
|
3947
|
IDEA
|
To flesh this out more, there ought to be a .valueAsTable property for when one wants to return the ValueTable object: parameters[0].valueAsTable # returns ValueTable
... View more
12-30-2022
01:57 PM
|
0
|
0
|
982
|
IDEA
|
Currently, the only 3D model transfer format that ArcGIS Pro supports in terms of exporting is Collada. However Collada is an older spec and not handled well by many 3D design software titles. I would like functionality to export a 3D Multipatch object from ArcGIS Pro into GLTF (ascii AND/OR binary). The general flow would be similar to arcpy.MultipatchToCollada_conversion() and could be something like arcpy.MultipatchToGLTF(output_path, output_name, prepend_source_name, format="BINARY") (or, format="ASCII") GLTF/GLB files are handled very pleasantly not only by numerous 3D design titles (e.g., Blender can open a 100mb GLTF without breaking a sweat while a 50mb Collada will bring it to its knees) but also the universal three.js framework. Please bring GLTF export support to ArcGIS Pro!
... View more
12-30-2022
11:27 AM
|
1
|
14
|
4751
|
IDEA
|
When a Parameter holds multiple values, it would be nice to be able to catch them in a simple list object instead of a String or ValueTable. For example, given: param0 = arcpy.Parameter(
displayName="Inputs",
name="inputs",
datatype="GPString",
parameterType="Required",
direction="Input",
multiValue=True) If the user inputs multiple strings like "Orange", "Apple", "Banana" the current options are parameters[0].valueAsText # "Orange;Apple;Banana" or parameters[0].value # <geoprocessing value table object> I would like to be able to return multiple values in a more idiomatic way: parameters[0].value # yields simple list: ["Orange", "Apple", "Banana"] Yes, it is easy to do parameters[0].valueAsText.split(";") or search through a value table, but both approaches are a needless complication. Getting a list directly from the Parameter seems to be the most straightforward, intuitive way to deal with multiple values.
... View more
12-29-2022
09:25 AM
|
3
|
1
|
1029
|
POST
|
Here's the super duct tapey way I handle this now, by the way: import arcpy
import re
def get_wkts(self, lyr):
# This is part of a larger python toolbox class
wkts = []
with_z = r"(\d+\.\d+) (\d+.\d+) (\d+,?)"
without_z = r"(\d+.\d+) (\d+.\d+,?)"
typemap = {
"MULTILINESTRING (": ["LINESTRING", without_z, "((", "))"],
"MULTILINESTRING Z (": ["LINESTRING", with_z, "((", "))"],
"MULTIPOLYGON (": ["POLYGON", without_z, "(((", ")))"],
"MULTIPOLYGON Z (": ["POLYGON", with_z, "(((", ")))"],
"POINT (": ["POINT", without_z, "(", ")"],
"POINT Z (": ["POINT", with_z, "(", ")"]
}
with arcpy.da.SearchCursor(lyr, ["SHAPE@WKT"]) as cur:
for row in cur:
for k, v in typemap.items():
if row[0].startswith(k):
wkt_prefix = v[0]
coords = v[2] + ",".join([str(f[0] + " " + f[1]) for f in re.findall(v[1], row[0])]) + v[3]
wkts.append(wkt_prefix + coords)
return wkts
... View more
06-07-2022
11:49 AM
|
0
|
0
|
822
|
POST
|
Not sure if "what's the best way" questions are frowned on, but before I burn a bunch of cycles fixing this, I figured there might be a capability buried in ArcPy that I'm missing. I'm attempting to get WKT of what appears to be a simple line feature in ArcGIS Pro. When I use the SHAPE@WKT token to call it, it returns as MULTILINESTRING Z ((10.0 20.0 0, 11.0 21.0 0,...)) I would like to return the feature as LINESTRING((10.0 20.0,11.0 21.0,12.0 22.0,...)) as I am issuing these geometries as query criteria to various web services that are looking for simple OGC WKT. Is there preprocessing available to me to ensure the SHAPE@WKT returns as a LINESTRING or POLYGON without Z, vs. MULTILINESTRING or MULTIPOLYGON? I can brute force this with re patterns and a dictionary of replacements, but I was hoping for something slicker and more idiomatically "esri."
... View more
06-07-2022
10:43 AM
|
0
|
1
|
837
|
IDEA
|
Another vote for this; we'd like to change the HTML/CSS on the default portal page without having to create a landing page in Sites.
... View more
05-27-2022
09:21 AM
|
0
|
0
|
2739
|
IDEA
|
@ThomasCrossmanpythonnet 3.0 alpha appears to support .NET 6, so it's on the way. https://github.com/pythonnet/pythonnet/releases referencing https://github.com/pythonnet/pythonnet/pull/1620
... View more
05-21-2022
09:28 AM
|
0
|
0
|
2113
|
Title | Kudos | Posted |
---|---|---|
4 | 02-03-2025 01:29 PM | |
1 | 01-31-2019 11:15 AM | |
1 | 03-29-2022 12:18 PM | |
1 | 05-21-2024 12:32 PM | |
1 | 05-21-2024 01:03 PM |