New answers tagged arcpy
0
votes
Export ArcGIS spatially enabled dataframe to feature class
I had this issue after updating ArcGIS Pro and arcpy to v2.9. Basically if the SEDF did not have a geometry column named "SHAPE" (all caps) then the ValueError: Length mismatch: Expected ...
1
vote
Python ArcPy script hanging only when running through command line in a machine
If you read the help file on MapDocument class it clearly states the parameter must be a A string that includes the full path and file name of an existing map document.
You don't define a full path ...
2
votes
Accepted
Merging rasters from multiple days in loop using ArcPy
Here is the code you can use, obviously I don't have your data so I spoofed it up with text files, so you need to edit the code and replace the txt with tif.
Here is my sample data:
# Import modules
...
2
votes
ArcPy to include None geometries features
The RFC 7946 - The GeoJSON Format doesn't formally define empty geometries, the closest it gets is:
GeoJSON processors MAY interpret Geometry objects with empty "coordinates" arrays as null ...
0
votes
Accepted
ERROR 000732 Dataset does not exist or is not supported RematchAddresses
Without checking all of your syntax, I think you should change:
reGeos = arcpy.arcpy.conversion.TableToTable(addressTable, r"C:\MyDatPath", 'SSA_regeocode', Q2)
to:
arcpy.conversion....
0
votes
Script in ArcGIS Pro does not work in ArcMap
arcpy.da.Describe is not available for Python2
Replace the two lines using the da.Describe methodology
desc = arcpy.da.Describe(fc)
fcType = desc["shapeType"]
With these old Describe ...
0
votes
ArcPy GridIndexFeature doesn't calculate square Grids - But using the tool in ArcGIS Pro desktop it does
You are not using the same parameters in the Desktop application as in the arcpy script.
Re-run the script using the same parameters and see if you get the same results. Eg, your arcpy script does not ...
1
vote
Accepted
Raster to Numpy array for aspecified area, search maximum value using ArcPy and numpy
The following code works by masking the raster and returning the max value then storing it in a dictionary for subsequent use.
The two key optimisations are to use glob to create a list of tifs and to ...
0
votes
Raster to Numpy array for aspecified area, search maximum value using ArcPy and numpy
Not tested, but if your extr1 is populated by 1, this (untested) should work:
from arcpy.sa import *
ONE = Raster(extr1)
for raster in inras:
R = arcpy.Raster(raster)*ONE
arcpy.AddMessage(R....
0
votes
Accepted
ArcPy error handling not picking up index error in script tool
I think your logic is badly flawed, this is how I understand your code.
You create an insert cursor, open a csv file, on the first line of data you check if longitude is between 180, if not delete the ...
1
vote
ArcGIS - run a tool thousands of times
Perhaps this will work for you:
arcpy.conversion.TableToTable(r"confusionmatrix"+str(i), r"path_of_folder_to_save_to", r"confusionmatrix"+str(i)+".csv")
...
3
votes
Accepted
Converting extent to int is changing value
Rounding before integer worked.
print int(round(extent.YMin)), int(round(extent.XMin)), int(round(extent.YMax)), int(round(extent.XMax))
-46 -90 -45 -89
1
vote
Installing ArcPy in Anaconda gives ImportError: Unable to locate a valid Pro or Server installation
In the Description field of the annaconda.org release site, it states:
Provides the ArcPy interface to ArcGIS Pro and Server installations. Requires ArcGIS Pro or Server installed on the same machine....
0
votes
Using Intersect with arcpy.GetParameterAsText() and ArcMap
Thanks for the comments. It's led me to a solution. The AddMessage was showing that in the DesList2 it was listing the dataset as:
u"'\DRBS-NAS01\ueec\GIS\100 MT testing\BufferTest\Data\...
0
votes
Accepted
Create points from CSV file using csv.reader
Your are inserting a point object instead of PointGeometry object.
try this
# create points from csv
with arcpy.da.InsertCursor(out_points, ['SHAPE@', 'ID', 'LAT', 'LONG']) as cursor:
point = ...
0
votes
how to test if linear exists with a buffer with ArcPy
Use the Clip tool to get the geometry of the lines within the buffer, then compare the length of the clipped lines with the original lines to get your percentage within the buffer
2
votes
Accepted
Saving selected features as new layer using ArcPy
You can try to save the result of the selection in a variable and then copy the value in the variable.
sel = arcpy.management.SelectLayerByLocation(input, "INTERSECT", intersecting_features, ...
1
vote
Accepted
Iterate through fishnet polygons for extents and update field
You need to get the polygons geometry object before you can get the extents for each polygon. As you have it you are asking for the extents of GEOCELL (which looks to be a text field in your data).
...
0
votes
How do I determine the distribution of my spatial data in order to choose a kernel density bandwidth estimation method?
These type of statistical tools tend to be outside my skill set so I may have misunderstood your requirements (because I don't fully understand the tool). When you say my data is normally distributed ...
2
votes
ArcPy UpdateCursor for each row in a table using calculated values
It looks like you are trying to put si in the sindex field but are trying to index it from set s_index={oid, si}? Sets do not support indexing and even if that were the case, it'd update it with the ...
0
votes
Copy feature class with the same name from different gdbs/datasets into one gdb
Here's an attempt at solving your problem by making a few modifications to the code in this other answer.
# Import system modules
import arcpy
import os
import pathlib
def export_layers_to_single_gdb(...
1
vote
Copy feature class with the same name from different gdbs/datasets into one gdb
Assuming all of the geodatabases are within the same folder, you just need to iterate through the folder of geodatabases, then save a copy of the feature class with the new name. Just change the ...
2
votes
Adding new MapFrame to Existing Layout using arcpy and ArcGIS Pro
A layout can have more than one MapFrame so when you realise that then you realise that it's a collection object that you need to be inserting your MapFrames into, typically in python its a list. In ...
1
vote
Accepted
How do I preserve all fieldnames when merging features?
Just add all the fields you want to retain in the dissolve fields parameter:,
arcpy.management.Dissolve(
in_features=inputlayer,
out_feature_class=fcMerged,
dissolve_field = ['projectId', ...
0
votes
List Feature Classes and use Update Cursor to calculate date values
Here's my solution to the first part of your script. Maybe combining this with your UpdateCursor will help? I think you may be grabbing the fields wrong. Let me know if this works! If not, I can do ...
0
votes
Accepted
Using ArcPy with ArcGIS Pro to zoom to features and export PDF
Answering my own question - it appears that you do have to set the map's camera as well, though I was having trouble with the code. With credit to https://community.esri.com/t5/python-questions/zoom-...
1
vote
Accepted
How to convert memory raster to points in ArcPy?
There are multiple issues with the code:
You appeared to be mixing ArcMap and ArcPro flavours of arcpy so this code would probably have failed.
There is no property called setSpatialExtent() on ...
1
vote
How do I adjust a layout's zoom level before exportToPNG?
Since the commentary on Keagan Allan's answer is geting quite lengthy, here is another approach that I have attempted.
One could also use the Desktop ArcGIS Pro application to export PDFs. Then after ...
2
votes
Accepted
Extracting polygon features based on single layer attribute polygons using ArcGIS Pro
Steps:
Create a Spatial Join. Target Features: points - Join Features: polygons - Join Operation: Join one to many - Match Option: Within.
Use the Split by attribute geoprocessing tool on the newly ...
0
votes
Accepted
Using ArcGIS geostatistical wizard for Kriging in ArcPy
Thanks to bloigge for pointing me in the right direction. The post linked in their comment explains how to manipulate the XML model template in order to optimize any new models created from the ...
1
vote
Least cost path from single source to single destination without cost distance (calculating accumulative cost)
To compute least cost path algorithm does calculate accumulative cost => backlink table => path. Yes, no need to memorize cost distance and backlink table when you dealing with single pair:
...
1
vote
Selecting All Features within Feature Dataset in ArcSDE Database using ArcPy
There is a typo in the code when trying to select the layer.
Make Feature Layer code:
arcpy.MakeFeatureLayer_management(aoi_fc_select, "selected_aoi_lyr", user_AOI)
Selection code:
...
2
votes
How do I adjust a layout's zoom level before exportToPNG?
I use data driven pages (DDP) to export certain parts of dataframe. Perhaps it will work for you because I don't think that you have 1k of layers, rather 1k polygons sitting in single feature class.
I ...
Top 50 recent answers are included
Related Tags
arcpy × 10004arcgis-desktop × 1461
python × 1007
arcmap × 999
cursor × 946
arcgis-10.1 × 752
arcgis-10.2 × 714
arcgis-pro × 664
arcgis-10.0 × 636
arcgis-10.3 × 427
python-script-tool × 395
raster × 372
spatial-analyst × 327
modelbuilder × 300
layers × 292
field-calculator × 285
python-toolbox × 274
enterprise-geodatabase × 261
python-2.7 × 235
python-addin × 235
fields-attributes × 227
error-000732 × 216
select-by-attribute × 206
shapefile × 200
arcgis-server × 197