7
votes
Accepted
Turning off layer visibility in ArcGIS Pro with Python
I expect that your for loop never runs, because there is no layout element that matches your "Layer" wildcard.
You should be getting your layers from the map, not from the layout. Use m....
6
votes
Accepted
How to add a custom tool to ArcGIS Pro tab/ribbon
Watch the video I have prepared below, this is how you create custom ribbons with all the tools you want. I show a custom python script tool being added but it could also have been a standard UI tool ...
5
votes
Accepted
Search cursor skipping every other row
for row in sCur: is iterating over the cursor, i.e. requesting the next item.
Then below that, you request the next item again by using sCur.next(), thus advancing the original iterator.
So the ...
5
votes
Accepted
Using search cursor or select for related table data in ArcPy
Instead of all that, let's try using the FREQUENCY Statistics Geoprocessing tool, operating over the BLOCK data, with the zoneID as frequency field and SUM(population) as the computed sum field:
arcpy....
4
votes
Accepted
Importing CSV file in ArcGIS Pro ArcPy script using relative paths
This:
scriptsPath=os.path.dirname(os.path.realpath(__file__))
will give you path to toolbox (works with tbx), so join 'data' and scriptsPath to get location of csv file.
4
votes
Accepted
Using page query with python
Use Python CIM access as described below. A handy way to see what you want to update is to set it manually, then export the layer to lyrx and open the lyrx in a notepad to view the JSON.
## access ...
4
votes
Accepted
Running Python Toolbox in Background
The simple answer is canRunInBackground doesn't do anything in ArcGIS Pro, because as you point out from that article, there is no separate background process to run in. So it doesn't matter if its ...
4
votes
Accepted
Unable to remove "SHAPE" from field list
As commented by @MichaelStimson - case is important, use .upper().
Try the following instead to use a list comprehension and save using a loop block:
deleteFields = [f.name for f in arcpy.Describe(...
4
votes
"AttributeError: ArcSDESQLExecute: StreamExecute ArcSDE Extended error 900 ORA-00900: invalid SQL statement" error when running SQL query via ArcPy
With the current code, this isn't a case of a SQL statement not being valid but of passing a non-SQL statement to a method expecting a SQL statement. The error message returned will be the same in ...
3
votes
Accepted
How to increase line width?
Checkout the Esri docs for Python CIM here.
I'm assuming it's ArcGIS Pro and version 3.0+
Here is an example. The definition described below is like JSON. I reccommmend setting symbology manually and ...
3
votes
How to add a custom tool to ArcGIS Pro tab/ribbon
If your tools and script are stored in a toolbox you need to add the toolbox to your project before trying to personnalise (in the catalog pane navigate project>toolbox right click and choose add a ...
3
votes
arcpy.mapping ListLayers to arcpy.mp listLayers
You are trying to listLayers on the list object of maps. You need to select a map from that list.
Example:
dfList = aprx.listMaps()[0] #First map in list
3
votes
Accepted
Delete MS Word-Object in Dataview with ArcPy (ArcMap)
I don't think arcpy exposes any methods that allow you to delete OLE objects inserted into a data frame. You can automate this using ArcObjects.
So in screen shot below I have a polyline layer, ...
3
votes
arcpy.SelectLayerByLocation_management() in standalone script
The FIDSet returns the selected features of a layer, but if you are working directly on a featureclass, there is no such thing as a selected feature. It should probably work if you create a ...
3
votes
What function in ArcGIS Pro Python replaces the ArcMap data frame method zoomToSelectedFeatures()?
I don't know of a direct equivalent in ArcGIS Pro. However, the code below is similar to what I do for zooming to a list of layers' extents, taking into account selected features. It's a fairly ...
3
votes
Move an existing layer into a group layer using ArcPy in ArcGIS Pro
You want to use addLayerToGroup... see attached example code...
aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.listMaps()[0]
#mp = aprx.listMaps("Specific Map Name")[0] Use ...
3
votes
Accepted
How to move a layer to a group using Python code in ArcGIS Pro?
The help file states that listLayers() - Returns a Python list of Layer objects that exist within a map.
So in your code lyr_to_move is a list object.
To retrieve the layer from the list to feed into ...
3
votes
Accepted
AttributeError: 'ArcGISProject' object has no attribute 'listStyleItems'; ArcGIS Pro 3.1.4; Python Notebook
I would assume the listStyleItems method was added to ArcGIS Pro 3.2 and does not exist in 3.1.
If you use the drop down at the top of the page you reference (https://pro.arcgis.com/en/pro-app/latest/...
3
votes
Accepted
AttributeError: DescribeData: Method spatialReference does not exist when iterating listLayers()
The map object method listlayers() returns all sorts of layers, not all of them are spatial so the describe doesn't have a spatialReference property when used on them. Just to be sure you could check ...
2
votes
Accepted
Adding data to existing .aprx layout and zooming to extent of new data using ArcPy with ArcGIS Pro
It's unclear from your question what your actual problem is, but I can see one issue in the code...
In ArcGIS Pro, updating the map's camera extent, doesn't update the camera extent of the map frame ...
2
votes
Accepted
Select Layer by Attribute not working with variable, but doesn't give errors using ArcPy
Check that you're formatting your parameter into the selection string correctly. I'd guess looking at this that your query ends up looking for a parcel who's id are the string "param0" ...
2
votes
Accepted
Getting SQL that defines Query Feature Class using ArcPy with ArcGIS Pro
The Python CIM access - ArcGIS Pro | Documentation allows for one to get the SQL query for a Query Feature Class directly from Layer - ArcGIS Pro | Documentation without having to save the layer to a ...
2
votes
Determining if no features in layer are selected using ArcPy
Looking at Layer - ArcGIS Pro | Documentation and Layer - ArcMap | Documentation, there is a layer method that can be called directly to get selection information: getSelectionSet().
Calling layer....
2
votes
arcpy Geometry pointFromAngleAndDistance method
If I use your code, but tweak it to
Remove prettytable
Specify the XY resolution of the SpatialReference
Remove the unimplemented 'PRESERVE_SHAPE'
it looks like this:
import arcpy
maxDistance = 100....
2
votes
Accepted
ArcPy intersection method passing in two polygon features returns an inaccessible line feature object
You have explicitly requested a Linestring result by specifying
intersection = geometry_a.intersect(geometry_b, 2)
when you should have specified:
intersection = geometry_a.intersect(geometry_b, 4)
...
2
votes
WKT Conversion: Object: Error in executing tool
If you take a look at tool reference for Create Feature Class you can see that the:
first parameter is: path,
second: name,
third: type and
fourth: template
So you are passing spatial_reference as ...
2
votes
Moving points based on updated x,y values
I'll guess that:
You have a way to select the points where the new coords are needed.
You have two columns with coords.
If thats the case do:
Filter the data
Get the coords, create Geometry
Make ...
2
votes
Accepted
gdal projection string not recognized by arcpy.SpatialReference()
Try creating an osr.SpatialReference() object from the GDAL WKT, then using MorphToESRI() to make any WKT it spits out ESRI-compatible.
Should look something like this:
from osgeo import osr
...
2
votes
Setting up parameters for linear referencing tools in ArcPy
A simple solution is to run the tool from toolbox in ArcGIS Pro on some sample data then go to history and right click on the run tool and choose copy python command and paste that into your IDE, you ...
2
votes
Is it possible select a field if it contains specific text in ArcGIS?
Regarding the question, "Is it possible [to] select a field if it contains specific text in ArcGIS?" The short answer is "yes," while the longer answer is to a slightly different ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
arcpy × 10618arcgis-desktop × 1449
arcmap × 1168
python × 1070
cursor × 1002
arcgis-pro × 1001
arcgis-10.1 × 754
arcgis-10.2 × 712
arcgis-10.0 × 644
arcgis-10.3 × 426
python-script-tool × 420
raster × 396
spatial-analyst × 361
layers × 315
modelbuilder × 313
field-calculator × 301
python-toolbox × 294
enterprise-geodatabase × 279
fields-attributes × 238
python-2.7 × 238
python-add-in × 236
select-by-attribute × 222
error-000732 × 222
shapefile × 209
parameters × 205