Questions tagged [arcpy]

A site-package created by Esri to expose ArcGIS Desktop (ArcMap and ArcGIS Pro) geoprocessing, mapping, etc, to Python.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

Deleting Picture Element using ArcPy in ArcGIS 10.3 Desktop?

I'm trying to delete a Picture Element from 45 MXDs. This code is a start for me: import arcpy from arcpy import env env.workspace = r"G:\PROJECTS\landuse\gis" for mxdname in arcpy.ListFiles("*.mxd")...
0
votes
1answer
110 views

ExecuteError: ERROR 000539 while running expression rcexec()

from arcpy import * arcpy.CheckOutExtension('Spatial') arcpy.env.workspace=r'D:\work\USA' #pathway to all rasters in workspace directory rasters = arcpy.ListRasters('*.tif') # Local variables: ...
1
vote
3answers
2k views

Selecting maximum value in attribute table using Python code?

I saw a lot of posts about how you select maximum value in the particular field and I've been trying to use that query in a python code, but none of the posts really helped me solve my problem. There ...
2
votes
1answer
46 views

Creating and calling virtual environment to run ArcPy script?

I'm getting a new computer and am trying to set up my virtual environments the right way. In the past, I've just been using PyCharm and running everything through "C:\Python27\ArcGIS10.6" so it's a ...
0
votes
3answers
85 views

Going back in for loop at the end of a while loop in ArcPy?

I'm quite novice in Python and ArcPy. I have a river network with Strahler orders (starting from 1). I want to create a new network where the new streams will start from order 1 till the outlet. (so, ...
0
votes
0answers
29 views

Compute polygons (Data Driven Pages) main angle when having ArcGIS Basic license

Is there a way we can calculate or when rotating polygons, actualize/update our "Angle" field in the attribute table by using Python? There is a tool in ArcGIS "calculate Polygon Main Angle" but is ...
1
vote
2answers
24 views

Batch importing same layer into multiple mxd files using ArcPy?

I am new to python. Will someone help me with the code to import the same layer into all the arcmap files in a folder on my desktop? I used the code below to import the layer into one map but I ...
0
votes
1answer
28 views

Looping through two raster folders to perform raster calculation

I have two geodatabases with rasters containing information about "treecover" and "loss". The file names are slightly different but can be matched based on the last 8 characters (the coordinates of ...
0
votes
0answers
20 views

Joining a Pandas dataframe feature classes in ESRI geodatabase [on hold]

I have a pandas dataframe, what I wish to join to 3 different feature classes in an ESRI geodatabase. I need to open up the GDB, join the dataframe to each of the feature classes, one at a time, ...
2
votes
3answers
36 views

Check in all tables in database if two fields are not null, with ArcPy?

I would like to check two fields in each tables which name start with X_ into a database ! I've started to write something like : arcpy.env.workspace = "C:/myWorkspace.sde" tables = arcpy.ListTables(...
0
votes
0answers
17 views

Convert to separate feature classes

I have an input CAD file with different layers, need to convert each layer into separate feature classes. By the code below, I am able to convert single CAD layer to feature class at a time. Now ...
1
vote
1answer
37 views

ArcPy from points to lines keeping points attributes?

I have a script in ArcPy that read a CSV file like this: FID,LonDD,LatDD,Length,Depth,Type,Label,Date/Time 1,-1.090261,59.887594,,5,A,Text,041100ZAUG19 1,-1.090261,59.854044,,5,A,Text,041100ZAUG19 1,-...
1
vote
2answers
2k views

Using ArcPy to Rename Feature Class by Field?

I made a little model and at the end I want to rename the feature class file to something based on the fields in that feature class. I want to rename that feature class by the date the data was ...
2
votes
1answer
714 views

Altering graticule intervals logically in varying map scales using ArcPy and/or Data Driven Pages?

This question appears on many sites and I was wondering if there was a script that is now available that resolves it? Please also upvote the ArcGIS Idea that Reference grids/graticules should be ...
0
votes
0answers
24 views

Downloading ArcGIS Online Feature Service to local Geodatabase using ArcPy?

I want to grab some feature services from ArcGIS Hub and put them on a GDB on my local PC. Here's the code that I've got so far: import arcpy # Set project directory proj_dir = 'C:\\Users\\rhard2\\...
-1
votes
0answers
22 views

Addin to Style Legend

I created an arcpy script to apply a style to my legend from my style template and it works when using the module within arcmap. But i want to add it as an addin button. import arcpy import Python ...
1
vote
1answer
23 views

Adding attributes to OutTable of Check Geometry tool using ArcPy?

I am writing a script that checks the geometry of all point, lines and polygons in a gdb. I used a script provided by Esri and it works fine, however it only returns the name of the featureclass, ...
0
votes
1answer
20 views

Selecting columns in from an attribute table in ArcPy using a list (rather than slices or indices)?

I have seen this answer to Calling specific columns of attribute table using ArcPy?, but it uses a slice to select columns. I would like to select them using a list. Example code that doesn't work: ...
2
votes
1answer
101 views

Distinguishing between Layers and TableView using ArcPy?

I am working with ArcMap and am using ArcPy. My task is to loop through mxds and find broken data sources. My code is: mxd = arcpy.mapping.MapDocument(fullPath) brknMXD = arcpy.mapping....
0
votes
1answer
37 views

ArcPy UpdateCursor fails when adding a transform to SHAPE@XY due to type error

I have a Feature class with 285k point features. I am running this code on it: with arcpy.da.UpdateCursor(FeatClass, ["SHAPE@XY"]) as cursor: for row in cursor: cursor.updateRow([[row[0][...
0
votes
0answers
28 views

Merging two feature classes in geodatabase and dropping them into different geodatabase using ArcPy? [on hold]

I'm trying to merge 2 feature classes in one gdb file, and want to drop them into a another gdb file. So I have something like this: Merge these 2, from: O:\AM_ML_mainlines_v.0.1\container_2.gdb\...
0
votes
1answer
17 views

Spatial join by attribute using ArcPy? [on hold]

So I have 3 layers: parcels, buildings, and address points. If I do a spatial join so that the parcel ID attribute (represented by Orange/Blue color) is added to both address points and buildings, you ...
8
votes
4answers
9k views

Trying to extract a list of Unique Values from a field using python

I have a number of columns in a number of tables withinh a FGDB where I need to extract the unique values for each column. For Example: the values may be [1,2,2,2,3,4], and I am trying to return [...
0
votes
1answer
146 views

Iterating folder of shapefiles using ArcPy and exporting mxd to PDF

I'm new to Python and just created a hard coded script for the process I want, and it works. Right now it calls on the one of three shapefile I have in this map document. I want it to do the same ...
0
votes
0answers
15 views

Automate subtype and domain creation in ArcGIS

I am creating a point feature class in a file geodatabase to use a template so users can create standardized data. I have successfully created subtypes and domains for the database with a Python ...
0
votes
0answers
26 views

Creating new .lyr file and retain metadata using ArcPy?

I'm creating a Python Toolbox using ArcGIS 10.5 that ultimately creates a new feature class and .lyr file from the layers in a current .mxd table of contents. I need the new feature class and .lyr ...
1
vote
0answers
22 views

arcpy.Integrate_management failing?

I cannot get arcpy.Integrate_management to work. I can run as a standalone process in ArcMap just fine, and if I copy the result as a python snippet I get: arcpy.Integrate_management(in_features="...
0
votes
1answer
164 views

Distinguishing between invalid raster files and valid ones at using arcpy functions

I am trying to move raster files from one location to another. By using the function: ListRasters (arcpy), I can get the list of rasters to be moved, but the problem is that even corrupted rasters ...
0
votes
1answer
110 views

arcgisscripting module not found in Python 3.5 in Spyder IDE

I am running ArcGIS Pro 2.2 and I have cloned my conda environment from Python command prompt. When I activate this environment and attempt to run Python 3.5 from the terminal, I can load arcpy as the ...
0
votes
1answer
108 views

Preventing ModelBuilder model from working on/after particular date?

I am working in ModelBuilder in ArcGIS Desktop. I want to stop models from working when the current Time is greater than the project over time. Below snap showing where I am making a mistake please ...
0
votes
2answers
28 views

Using variable (input parameter) as out_name to create feature class?

I have a dilemma, I am trying to create a new feature class, but I want the user to be able to input the name of the new fc. I have created the variable 'newFC' as getparameterastext(2), but how do ...
0
votes
0answers
13 views

Changing multiple info from table to shape using ArcPy? [closed]

I need to change some data which is in a table (Excel) that has an old numeration and new numeration (it is highlighted in the old one) to a new one (column 1 to 4, column 2 to 5, column 3 to 6) in ...
2
votes
1answer
53 views

Can arcpy read dynamic text as appeared in ArcMap?

Just wondering if we can read dynamic text in arcpy? For example, assume we have a Text Element called myText which contains a piece of dynamic text Map <dyn type="page" property="index"/>. ...
5
votes
2answers
7k views

Importing arcpy in Spyder

I can't import arcpy in spyder but I don't have any problem when using PyScripter. The error that I get is: ImportError: No module named 'arcpy' I would prefer using Spyder, if I can solve this, any ...
0
votes
2answers
47 views

Copying feature service to local geodatabase using ArcPy and ArcGIS API for Python?

I am trying to export/copy a feature service to a local geodatabase where I can work on it locally. I have provided the code below. I keep getting an "Object: Error in executing tool" for the last ...
1
vote
1answer
26 views

Value Error when adding adding a layer in ArcGIS Pro arcpy script

In a script, I'm creating a feature layer and trying to add it to a map in ArcGIS Pro 2.3.0. When I try to add it though, I get a ValueError. Any ideas why and how to fix it? m is the map object. The ...
1
vote
1answer
93 views

Error when clipping multiple rasters

I am trying to clip about 36 rasters by a polygon. However, I am running into an error. It isn't a coding problem with the loop because I receive the same error when I run the function on a single ...
2
votes
1answer
112 views

What permissions needed to add an index with a protected version?

Using arcpy and ArcGIS 10.1 SP1 (Build 3143) against an Oracle 11g enterprise geodatabase, I am trying to add an index to an existing attribute in an existing feature class: arcpy.AddIndex_management(...
7
votes
3answers
2k views

Creating fishnet from template feature class using ArcPy?

I can’t use the tool arcpy.CreateFishnet_management because define the parameter “templateExtent” with a shapefile it is not filling automatically the parameters “originCoordinate” and “...
2
votes
1answer
28 views

Text element not updating in arcpy.mapping?

I am trying to get a text element to input an address using the below code. It seems that the code picks up the right elements, is finding the text elements I want to change but isn't able to actually ...
2
votes
1answer
41 views

Iterate a clip over multiple feature classes using Model Builder or ArcPy

I have multiple feature classes (buildings, airport, land, roads etc) that I would like to clip using a Local Authority boundary. I am trying to create a process in model builder or Arcpy that will ...
0
votes
2answers
67 views

Shift in raster in python 3.6

I have a python script for a color anomaly detection study. I am attempting to create two rasters each with three classes: one raster representing a "target" and the other representing "background", ...
0
votes
1answer
25 views

ArcGIS geoprocessing DomainToTable_Management script crashing

I needed to dump all of the domains in my file geodatabase so missing values can be identified. The script runs fine if the domain name has no spaces but, unfortunately this one has many multi-word ...
0
votes
1answer
216 views

Zonal statistics error in arcpy

I'm trying to get the zonal statistics output (mean), do some operations and add to my main archive the output value. I wrote this code, but it's not running, the error message is: Traceback (most ...
0
votes
2answers
43 views

arcpy Polyline.within(Polygon) return False for all lines between pairs of Polygon vertices

I'm trying to develop a function which will find the longest straight line length that can be drawn within any of the polygons in a feature class. (To keep things simple, I'm only including lines ...
0
votes
1answer
53 views

Get list of editable fields while also adding 'SHAPE@' to the end [closed]

I need to get a list of field names that only includes editable fields and not the geometry field, but then add the geometry field back to the end of the list as SHAPE@ token. I have code that runs ...
1
vote
1answer
51 views

Raster Combining in batch using ArcPy?

I am trying to combine two different raster files using a loop, with the following script. import arcpy import os thectr = 0 ws = arcpy.env.workspace = r'D:\BRB Snow Cover\Sample\TerAqua' ...
1
vote
1answer
104 views

How to bring over only 2 fields from the join feature class when using “SpatialJoin_analysis” and set up a merge rule?

I'm trying to understand how to use FieldMap and FieldMappings. I know very little about objects plus I'm finding the explanations on ESRI website not very good and far from comprehensive. All I'm ...
0
votes
1answer
16 views

Arcpy UploadServiceDefinition ignores folders and groups

I am using Esri's guidance for arcpy.UploadServiceDefinition_server (http://desktop.arcgis.com/en/arcmap/10.6/tools/server-toolbox/upload-service-definition.htm) I can successfully upload a service ...
2
votes
2answers
44 views

Drawing shapes like rectangle, polygons on fly using ArcPy in ArcGIS Pro?

I am trying to write a Python script that when imported into a toolbox can be used to draw user defined shapes on fly by clicking mouse points on the screen inside a GIS program. The motto of drawing ...