|
POST
|
A spatial join is the only other thing that comes to mind but I would prefer SelectLayerByLocation(). There's a code sample at the bottom of the Geometry doc page that shows using arcpy.Geometry() as the output for CopyFeatures() and having immediate access to the geometry for everything. You could try that after they're selected instead of the numpy array or search cursor.
... View more
09-20-2021
03:54 PM
|
0
|
0
|
2498
|
|
POST
|
Could you clarify how you determine a feature is at a given location? Check out the Geometry object for a way to get coordinates.
... View more
09-20-2021
03:31 PM
|
0
|
2
|
2518
|
|
POST
|
Could you use tempfile.mkdtemp() to make a temporary directory to unzip the shapefile and then clean it up when finished?
... View more
09-20-2021
12:10 PM
|
1
|
1
|
2824
|
|
IDEA
|
It seems the CreateGISServerConnectionFile() function was not implemented in ArcGIS Pro. It would be nice to have this available. Here is evidence this is requested from other users. https://community.esri.com/t5/arcgis-pro-questions/how-to-create-an-arcgis-server-connection-file/m-p/1042845 https://community.esri.com/t5/arcgis-pro-questions/how-to-create-an-arcgis-server-connection-file/m-p/1032848
... View more
09-20-2021
10:11 AM
|
18
|
10
|
5451
|
|
POST
|
Am I correct in my understanding that this just selects features where GIS_ACRES IS NULL, then calculates the geometry (acres) into the GIS_ACRES field? Try this version of the script to do the same thing. It looks like it is referencing a local temp workspace so you might need up update scratchWorkspace # -*- coding: utf-8 -*-
"""
Generated by ArcGIS ModelBuilder on : 2021-09-17 14:39:12
"""
import arcpy
def GeometryCalc(): # GeometryCalc
# To allow overwriting outputs change overwriteOutput option to True.
arcpy.env.overwriteOutput = False
arcpy.ImportToolbox(r"c:\program files\arcgis\pro\Resources\ArcToolbox\toolboxes\Data Management Tools.tbx")
# Model Environment settings
with arcpy.EnvManager(scratchWorkspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp10544\1ba0f558-c873-4c6c-be6d-dc08393016c0\Default.gdb", workspace=r"C:\Users\abishop\AppData\Local\Temp\ArcGISProTemp10544\1ba0f558-c873-4c6c-be6d-dc08393016c0\Default.gdb"):
parcel_2_ = "parcel"
# Process: Select Layer By Attribute (Select Layer By Attribute) (management)
parcel, count = arcpy.management.SelectLayerByAttribute(in_layer_or_view=parcel_2_, selection_type="NEW_SELECTION", where_clause="GIS_ACRES IS NULL", invert_where_clause="")
# Process: Calculate Geometry Attributes (Calculate Geometry Attributes) (management)
if count:
arcpy.management.CalculateGeometryAttributes(in_features=parcel_2_, geometry_property=[["GIS_ACRES", "AREA"]], length_unit="", area_unit="ACRES", coordinate_system="PROJCS[\"NAD_1983_StatePlane_Florida_West_FIPS_0902_Feet\",GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",656166.6666666665],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",-82.0],PARAMETER[\"Scale_Factor\",0.9999411764705882],PARAMETER[\"Latitude_Of_Origin\",24.33333333333333],UNIT[\"Foot_US\",0.3048006096012192]]", coordinate_format="SAME_AS_INPUT")[0]
if __name__ == '__main__':
GeometryCalc()
... View more
09-17-2021
03:25 PM
|
0
|
0
|
5521
|
|
POST
|
Oh, sorry, I didn't realize there was not a version that worked.
... View more
09-17-2021
12:05 PM
|
0
|
1
|
5528
|
|
POST
|
Well, post the full script you export that actually runs and describe the logical operation you'd like it to have. We'll come up with a solution together.
... View more
09-17-2021
11:07 AM
|
0
|
5
|
5535
|
|
POST
|
The logic could easily be added back in manually in the Python script.
... View more
09-17-2021
11:00 AM
|
0
|
7
|
5537
|
|
POST
|
I think as @DarrenWiens2 mentioned in the other thread, something appears to have gotten messed up when exporting this script from the model. Maybe try exporting it again.
... View more
09-17-2021
10:42 AM
|
1
|
2
|
3360
|
|
POST
|
Didn't work as in you got an error or it did something unexpected? If an error, include the entire error message with traceback.
... View more
09-17-2021
10:31 AM
|
0
|
4
|
3364
|
|
POST
|
Sorry, I didn't get a message and haven't had a chance to look closely at the screenshots. But regarding that error, simply deleting line 6 in that code you posted will resolve the syntax error.
... View more
09-17-2021
08:26 AM
|
0
|
6
|
3366
|
|
POST
|
Are you sure the slowness is coming from ListFeatureClasses()? If so, maybe try arcpy.da.Walk() If not, it might be the counting of records that's slow. @JoshuaBixby posted a blog article a while back concerning the performance of counting records. Unfortunately, the formatting was lost in transition to the new Geonet forum but he summarizes in the comments that: If you can reach back to the layer, feature layer, feature class, table view, or table; then the Get Count tool is by far the quickest method. However, it does look like you're applying a where_clause so you'd probably have to make a selection first for get count, which would likely negate the performance gain. Maybe try ArcSDESQLExecute() with a where clause and count?
... View more
09-17-2021
08:21 AM
|
0
|
0
|
2501
|
|
POST
|
Is there any chance the same parcel feature class would be added as a layer to the map more than once? Or would the parcel layer be present in more than one map in the project?
... View more
09-16-2021
10:29 AM
|
0
|
2
|
3379
|
|
POST
|
Is it safe to assume the layer will always have the same name ("parcel") or would it be better to check the data source of the layer for the feature class name?
... View more
09-16-2021
09:10 AM
|
0
|
12
|
5526
|
|
POST
|
If you don't know the exact name or position, I can't think of another way than simply looping over everything that's there and checking for likeness. There may be some inefficiency in your code that could be improved. Feel free to post a snippet of what you're doing.
... View more
09-16-2021
09:09 AM
|
0
|
2
|
2525
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 2 weeks ago | |
| 1 | 10-23-2025 03:53 PM | |
| 1 | 04-28-2026 07:25 AM | |
| 1 | 03-19-2026 08:59 AM | |
| 1 | 02-12-2026 01:37 PM |