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
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
58 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
56 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
114 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
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
219 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
55 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
19 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
45 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
21 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
29 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
47 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
73 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 # ...
0
votes
1answer
31 views

Python batch script to delete Attributes

I currently have a script that will select and delete all the values less than 0.1 in a column. The script below works, however it specifies a specific .shp, I want to batch this so it runs through ...
1
vote
1answer
31 views

ArcPy: Create NDVI with Raster Calculation and Map Algebra

My target is to create NDVI Rasters but I'm stuck with python loops, since I'm new to that, so sorry for a maybe basic question. I have 2 folders, one with rasters (tif) with the red band, the other ...
1
vote
0answers
40 views

Writing more than 1000 rows with arcpy.da.InsertCursor? [closed]

I have a GeoJSON which I'm able to successfully covert to a shapefile via the following process: using arcpy.asShape to find geometry, and inserting this geometry as new fields using cursor insertRow)....
0
votes
1answer
28 views

arcpy.SelectLayerByAttribute_management ExecuteError

This python code works in ArcGIS Pro but Not in ArcMap . I read some issues that mention a get around by making a feature layer. I tried that and I then get an error saying polytest doesn't exist. ...
0
votes
0answers
22 views

Import Arcpy error [duplicate]

I am having an issue with importing arcpy. Initially I thought that it might be that the version of the Anaconda software that I had been running was 64 bit, therefore I changed it to 32 bit to try ...
0
votes
1answer
34 views

Arcpy SDE Connection Getting Invalid Path? [closed]

I literally copied and pasted the file path (r'C:\Users\myName\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\mydatabase.sde'), but after I run my script, I always get the error saying error 267, the ...
0
votes
1answer
133 views

ArcPy tool in toolbox crashes ArcGIS Pro

been writing a toolbox to speed up my work and I've run into a strange issue. My start well tool works fine, but my add surveys tool does not and causes ArcGIS Pro 2.1 to crash. I'll post the code ...
1
vote
1answer
76 views

Comparing a polygon layer within the boundary of a polygon

I'm pretty new to ArcPy and Python. In our database, we have a layer containing parcels (polygons) with a neighborhood code and a polygon layer that contains the neighborhood boundary. Within that ...
2
votes
0answers
42 views

Obtaining extents of each data-driven page using ArcPy?

I have a set of index polygons (rectangles) that vary in size and orientation on which data-driven pages are based. I am looking for a method that would give me extents Xmin, Xmax, Ymin, & Ymax ...
1
vote
1answer
110 views

QGIS plugin creation using ArcPy Model in ArcGIS

I have created a ModelBuilder in ArcGIS 10.3 and exported the Python file. Now I want to use that Python file in QGIS plugin. Can that be done?
1
vote
1answer
21 views

Adding multiple feature classes (everything within gdb) to a group layer in ArcGIS Pro - Python

I am currently trying to add all the feature classes contained within a gdb to a group layer in ArcGIS Pro via a script. I have however not managed to add more than one single feature class at a time. ...
1
vote
1answer
26 views

Setting default value for date columns with FeatureClassToNumPyArray in ArcGIS Pro?

I am reading a feature class into a pandas dataframe using: df = DataFrame( arcpy.da.FeatureClassToNumPyArray( in_table=feature_class, field_names=field_list, skip_nulls=...
3
votes
2answers
121 views

Removing values from shapefile with ArcPy?

I have a large shapefile with lots of duplicate records. However, each duplicate record has an accuracy rating. I want to remove all duplicate records with a lower accuracy rating. This would be ...
0
votes
0answers
28 views

Creating raster from grid algebra expression using point attribute values?

I have a point shapefile representing groundwater production wells with annual pumpage values distributed over a general area. I'd like to create a raster layer with each cell representing the ...
1
vote
2answers
76 views

Printing error message to console or log file in ArcPy? [closed]

My code is as follows: Essentially, I have one table in my database that is not able to convert into my FGDB. When I run on command line, I am able to get an error message of: WARNING: Failed to ...
8
votes
3answers
6k views

Creating polygon feature class from X,Y coordinates using ArcPy?

I am trying to write a script that creates a new polygon feature class containing a single ( square ) polygon with the following coordinates: ( 0, 0 ), ( 0, 1,000 ), ( 1,000, 0 ), and ( 1,000, 1,000 )....
4
votes
2answers
883 views

Arcpy to get ArcGIS Application Data folder (My Toolboxes folder)

Is there a way (enviromental variable) in arcpy to get access to ArcGIS Desktop AppData (per user) folder. For example, I need to access this folder in 10.2: C:\Users\MyUserName\AppData\Roaming\ESRI\...
1
vote
1answer
37 views

Filter fields by expression arcpy

I have to trasform a script (which I didn't write myself) from QGIS to ArcMap. In the script a filter by expression is used. The function has the input inl (= the layer with the data that should be ...
1
vote
1answer
114 views

Updating Cursor to Include Newly Created Features?

I am using ArcMap 10.1 and python to create cursor that starts at the one and only row of a polyline shapefile, some code runs to create a new feature based on the position of the exisiting feature, ...
1
vote
1answer
223 views

Getting ERROR 999999 when trying to use arcpy.UploadServiceDefinition_server()?

Here is my code def upload(name, client, working_dir): arcpy.env.overwriteOutput = True arcpy.SignInToPortal('https://www.arcgis.com', username, password) outdir = working_dir + "\\PROJECTS\\" +...