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
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
48 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
0answers
40 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 ...
2
votes
3answers
39 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
19 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
42 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
716 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 ...
1
vote
1answer
25 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
21 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
104 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
39 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][...
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
156 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
16 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 ...
1
vote
0answers
24 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
165 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
117 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
111 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
29 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 ...
2
votes
1answer
56 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
55 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 ...
0
votes
1answer
29 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
96 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(...
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
50 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
68 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
28 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
218 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
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
52 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
105 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
45 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 ...
0
votes
1answer
24 views

Script that works in Python Toolbox not working in Standard Toolbox?

This script does not work in a Standard Toolbox but it works in a Python Toolbox. Do I need to delete all the parameters from the script? import arcpy, os, sys, shutil class Toolbox(object): ...
0
votes
0answers
44 views

Using UpdateCursor in the same loop as SearchCursor

I have 2 layers, one with land plots and one with hazard zones. I want to iterate through the layer with land plots and for every plot I want to add 2 (or 3, depending on some variables) fields. Then ...
0
votes
0answers
14 views

Missing area when using tabulate area in ArcPy?

I create a polygon layer including 80 buffer areas (they are not overlapping) and want to get the area of each value of a raster file for each buffer area. I can use the tabulate area to realize this ...
1
vote
0answers
19 views

Updating text elements not working when using APRX path vs “CURRENT”

I am beginner in ArcGIS Pro and I am trying to expand into using python with ArcGIS Pro. I have a working script that will update a specified text element in all layouts in ArcGIS Pro, in my case it's ...
2
votes
1answer
54 views

Getting parameters of Python Toolbox tool to appear in ArcGIS Pro?

I can't get the parameters of my tool to show up in ArcGIS Pro 2.1 Because of my work I can't put my exact code here, but I'll put the skeleton of what I'm doing and hopefully someone can see what I'...
0
votes
2answers
28 views

ArcPy: Select_Analysis Invalid Characters

The following script produces the ERROR 000210: Cannot create output... .shp and ERROR 000354: The name containts invalic characters Failed to execute (Select.). The line with arcpy.Select_analysis ...
0
votes
1answer
46 views

Projecting many raster files in folder and then putting them into ArcGIS Pro project using ArcPy?

I want to project many raster files in a folder (but they appear in the content of my ArcGIS project). Here is the screenshot. These raster files have an unknown coordinate system. When I try to ...
0
votes
1answer
46 views

Multiple selections with a python loop

I am very new to Python and have no idea about how to write a python loop to do selections for ArcGIS. I already finished writing selection codes with different conditions. Is there anyone helping me ...
-1
votes
2answers
69 views

Merge and save results after selections using loop

I want to merge shapefiles after selection inside a loop and then save results to excel files. However, the codes could save the last result to excel files and can not save each merge file. import ...
3
votes
2answers
3k views

Calling variables within ArcPy functions using Calculate Field tool?

I have a defined function (ex. def my_function(x,y)). def my_function(x,y): """algorithm""" my_variable = my_function(filex, filey) How can I call this variable within the code block section of ...
2
votes
1answer
383 views

Using MakeFeatureLayer in ArcPy?

I am trying to add a feature layer to my map document as the output from my python script. The goal is to limit the number of fields in the attribute table to a pre-defined list. I am able to add ...
0
votes
0answers
20 views

Snapping together lines within certain tolerance with ArcPy and Basic level license?

I have a GIS layer of bike lanes I created using an open-source GeoJSON which I converted to a shapefile using ArcPy. The end result looks pretty good, with one exception: there is some small gaps ...
0
votes
0answers
32 views

WindowsError: [Error 32]

I get a windows error when trying to run my tool again in the same arc project. It does run again once I shut down ArcMap and reopen and run the tool. Any Ideas? import arcpy, os, shutil, sys # ...