Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [arcpy]

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

-1
votes
1answer
19 views

Insert a point into feature class based on another point [arcpy] [closed]

My assignment is to insert (using insertCursor) a new city at 0.02 decimal degrees east and 0.03 decimal degrees south of another city. The cities shapfile did not originally have x-y coordinate ...
1
vote
1answer
33 views

ArcPy rollback update / insert cursors if error occurs

Is it possible to rollback an update made with an update cursor or an insert made with an insert cursor if an error occurs? I need to go through a feature class and break numbers up into 100 groups. ...
1
vote
0answers
29 views

ArcPy failed to draw?

My ArcMap 10.6 Python code for creating a specific raster isn't working. The code is fine but the output keeps saying failed to draw. import arcpy from arcpy.sa import * arcpy.env.workspace = r'C:\...
3
votes
1answer
34 views

Calculating acreage as a percentage in ArcPy

I am struggling to calculate the acreage as a percentage in Calculate Field Management, but I am getting this error message: "ValueError: could not convert string to float! BufferAcreage! arcpy....
0
votes
0answers
31 views

Why is Python toolbox receiving 'none' as a GPDataFile parameter?

I'm building a widget in a WAB template that sends a geotagged photo to a Python toolbox GP service to create a point with the coordinates and attach the photo. I send the request to upload: var ...
1
vote
1answer
40 views

Modifying null values in ArcPy for ArcGIS Pro?

How can I say in ArcGIS Pro if the field (String) is Null, then replace it with "No"? I was trying this: database_field.replace("Null","No") No error occurred, but the null values did not change...
2
votes
1answer
23 views

If/Else in ModelBuilder not showing the correct True/False outcome

I'm creating a model that queries the number of features in a feature class and runs one of two scripts depending on if the feature class is empty or not. I'm using Get Count to calculate the number ...
3
votes
1answer
20 views

Changing metadata using ArcPy of ArcGIS Pro?

Is there any ArcPy function or classes which allow us to change map and layout metadata within ArcGIS Pro?
2
votes
1answer
26 views

Exporting to PDF using ArcPy of ArcGIS Pro?

I have a weird issue in exporting the layout to PDF My code is really simple and I have tried in ArcGIS Python IDLE but I have came across the problem. My Code and error is : Code: aprx = arcpy.mp....
0
votes
1answer
47 views

ArcMap Raster Calculator with Python code

I'm trying use raster calculator that can export a raster to do different average values for for multiple layers. For example, I want to do averages for only the values and layers that are greater ...
3
votes
2answers
50 views

Merge Multiple feature classes based off name

Trying to write a script to merge feature classes based off their name. Steps are as follows - In the original geodatabase, find polygon feature classes that end with a particular suffix ( ie *15_AM)...
1
vote
0answers
24 views

Creating Near Table between points in one layer that share an attribute with points in another layer?

I am trying to calculate the distance between some geographic features (point layer) and the capital of the country that they fall in. I have a shapefile of "features" and a shapefile of "world ...
0
votes
1answer
33 views

Writing Python script to delete multiple fields in multiple files but keep certain fields?

I am needing to be able to run a python script on a folder full of shapefiles to delete multiple fields in the attribute tables. But I want to be able to keep 3 fields (Crop_Type, Acres, and ...
1
vote
2answers
25 views

Joining selected fields from table to shapefile using ArcGIS Pro?

I have a line shapefile with 100+ fields and a separate dbf file with 100+ fields. I'd like to programatically (using arcpy and Python 3) eliminate all but 3 fields in both shapefile and the dbf, and ...
1
vote
1answer
21 views

Add and Calculate Fields of Iterated Annotation Classes

I'm have difficulty with my script Arcmap v10.5.1. I get a syntax error on line 8. My question is: Can I calculate the Added field from an existing field within an iterated value? If so, what's my ...
1
vote
1answer
15 views

Using arcpy.mp to edit TEXT_ELEMENTS with no success

I'm attempting to take a user input in a script tool to modify the text within text elements on a layout. The following is the code I am using: aprx = arcpy.mp.ArcGISProject(r"S:/Initiatives/Mailings/...
1
vote
1answer
13 views

Export Rasters from geodatabase containing specific words in title

I have a file geodatabase containing +200 rasters. I want to export a selection of these based on words in the middle of the file name. Example file names below: Bat_day_male Bat_night_male ...
1
vote
1answer
32 views

Solve Esri Toolbox produces empty Shapefiles (make route layer)

I am making a Toolbox for finding the best Pizzaroute between 7 Pizzastops. We used the make.routelayer from ArcPy. Our Pizzaroutetime expressed not our expression, rather all Firestations (station 1-...
1
vote
1answer
22 views

Adding tile size and compression type for ArcPy code?

I have to add tilesize and compression type to the following code import arcpy arcpy.CopyRaster_management("c:/data/background.tif", "c:/fdgb/CpRaster.gdb/fgdbRD","...
1
vote
0answers
17 views

Getting error from Arcpy Tabulate_area

I am trying to get the area of land use in each pixel of the fishnet file. I used the following script: arcpy.gp.TabulateArea_sa("fishnet_layer","FID","lulc.tif","Value","lulc_tab","1.1E-3") Here ...
1
vote
1answer
31 views

Solving ERROR 000732: Input Raster: Dataset Con( does not exist or is not supported in for loop? [duplicate]

I'm trying to reclassify rasters based on standard deviation. I created this code, but I think I'm wrong using "Con". I would like to assign value 1 to rasters >= to threshold and rasters <= to ...
1
vote
1answer
33 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"/>. ...
0
votes
1answer
25 views

Controling or modifying FID order using arcpy.AddXY_management

Using arcpy with slightly modified code from created by Felix Creating parallel line in ArcGIS Pro using ArcPy I made four parallel lines. I then used arcpy.AddXY_management to extract the vertices ...
0
votes
1answer
46 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 ...
1
vote
2answers
46 views

Add Path to JPGs in Attribute Table based on Unique ID

I've been tasked with updating attribute table fields with file paths to image files in a folder based on a unique ID. I'm having trouble thinking up a script that will do this? I'm working on a ...
3
votes
0answers
39 views

Comparing tables

Its been years since I last had to code, so please excuse the following. The idea here is that a user inputs their work and it checks for missing expected data. (I've taken out other code that works ...
1
vote
1answer
39 views

Creating points with attributes from coordinates in ArcPy

I know how to create points by coordinates with arcpy using the following code: import arcpy ptList =[[20.000,43.000],[25.500, 45.085],[26.574, 46.025], [28.131, 48.124]] pt = arcpy.Point() ptGeoms =...
0
votes
1answer
29 views

Using keyword in SelectByAttribute expression?

I've used SearchCursor to return the single value of a record (8 digit number) for row in arcpy.da.SearchCursor(table, ['PID']): if row[0] is not None: ID = row[0] break Now I would like ...
2
votes
2answers
114 views

Adding Coordinates to shapefile using ArcPy?

I want to add latitude and longitude column and their values in decimal degrees to my shapefile (fishnet). How to use ArcPy for that? I have added lat and long using arcpy....
2
votes
0answers
17 views

arcpy.ArcSDESQLExecute with UPDATE and OUTPUT

Is there a way to get OUTPUT through arcpy.ArcSDESQLExecute? Whatever I do I get only True. When running UPDATE through MS SQL Server Management Studio I get OBJECTID of all updated features (rows): ...
0
votes
0answers
47 views

Using output layer names from Select By Location

This is kind of from memory as I cannot access my specific code… I am using 10.3.1 and this will be run inside ArcMap. Overall goal: Find which layers in my active dataframe intersect a specific ...
1
vote
0answers
22 views

Creating loop in raster algebra which compares each cell to values of other rasters in time series?

I have a list of rasters representing NDVI values (and plan to do similar thing with some other index values as well) and in that raster I also set all values representing clouds to NoData. Now, for ...
1
vote
0answers
35 views

ArcPy Script Tool multi-value re-order buttons

I'm trying to set the values of one control (Multi-value, data type: string ) to another parameter control (Multi-value, data type: "any value" which produces a drop down with grid for items entered ...
1
vote
1answer
32 views

Use Python to import MXDs into an ArcGIS Pro Project and add the MXD file name to the imported maps

The method of importing an MXD to an ArcGIS Pro project has already been asked as Importing MXD to ArcGIS Pro programmatically? and it goes like this: workspaceMXD = r'FOLDER CONTAINING MXDS' ...
2
votes
2answers
53 views

Understanding arcpy.CalculateField_management with Join?

I am using arcpy.CalculateField_management to fill a column field with another column values. I have two shapefiles, fishnet.shp and new_run.shp. First I joined both using arcpy.AddJoin_management as ...
1
vote
1answer
61 views

How do I insert a list of values into individual rows using Python?

I have a dataset that contains a field with a range of numbers (e.g. 1, 2, 3-6) as well as other fields. I've used python to expand the range field into discrete numbers (e.g. 1, 2, 3, 4, 5, 6) stored ...
0
votes
0answers
57 views

Debugging Python script using Visual Studio in ArcGIS Pro?

According to these links, one can debug a Python script using Visual Studio in ArcGIS Pro. Debug Python code—ArcPy Get Started | ArcGIS Desktop ArcGIS Pro and Python - YouTube I am using ArcGIS ...
1
vote
2answers
39 views

Reading CSV in loop stops at row that does not match?

I am trying to read a CSV then iterate through an sde to find matching features, their fields, and then print them. There is a table in the list and I'm not able to skip over it and continue reading ...
0
votes
0answers
15 views

arcpy.Project_management - different results from python shell and python command line

I am trying to transform a number of shapefiles by script using a self-defined custom transformation. When I transform the shapefile using my script in the python shell of the ArcGis GUI everything ...
0
votes
1answer
36 views

Removing layers and schema locks with ArcPy?

I am creating a code that adds fields to a large set of shapefiles. I want to be able to open these shapefiles and edit the fields and then have them removed from the map document. I would like this ...
0
votes
1answer
37 views

Getting ERROR 000840 from arcpy.SelectLayerByAttribute_management?

I am trying to select layer by attribute and for that, I am using arcpy.SelectLayerByAttribute_management function . My command is as follows: arcpy.SelectLayerByAttribute_management(union, '...
-2
votes
1answer
32 views

Filling value in field of attribute table using ArcPy? [closed]

I need to put a value of 1 in a field of my shapefile's attribute table. How to do it using ArcPy? I have already added a new field using arcpy.AddField_management and now I want to fill 1 in the ...
0
votes
1answer
103 views

Getting AttributeError: 'module' object has no attribute 'CalculateGeometryAttributes_management'?

I am trying to calculate the area for my grid cells. For that, I give the following command arcpy.CalculateGeometryAttributes_management(union, "AREA") Here, union is my grid and I need to make a ...
1
vote
2answers
80 views

Python crashes after reading a certain number of mxd files

In one of my work, I need to go through about a few thousand mxd files, get some information from each MapDocument object (scale, printing paper size, map title, etc.), and write those information to ...
1
vote
1answer
32 views

How to convert a raster to a array CSV file?

I have a raster file and I would like to convert it to an array and then save it as a csv file with using arcpy. The reason is that I want to do some statistical analysis over each row and column in ...
0
votes
1answer
47 views

Creating points using ArcPy?

I'm new to ArcPy. I have coordinates of points 70°8'12.938"E ,25°26'11.569"N 79°10'33.945"E, 25°43'58.898"N 80°25'46.695"E , 16°45'15.907"N 70°6'57.527"E , 17°10'51.245"N I tried below code:...
0
votes
2answers
46 views

Iterating through geodatabase with multiple feature datasets using ArcPy? [closed]

I am trying to create a Python script that batch projects every shapefile in a geodatabase to a temporary geodatabase that I created. I realized that this script that I created does not iterate ...
0
votes
1answer
58 views

Calculating volume between polygon and raster?

I want to calculate the volume between a route alignment and a raster. I have the centerline of the route. The centerline is between point A and B as it is presented in the figure below. Point A and B ...
0
votes
0answers
32 views

Modifying representation properties with ArcPy?

I am working with Representations. According to the Modifying representation properties help, I can manually change any FeatureClass properties such as rotate or change it's offset. I want to rotate ...
0
votes
0answers
35 views

Applying graduated color symbology using arcpy.mapping?

I am trying to apply a graduated color symbology from one layer to another. The script adds a layer to an mxd but foes not apply the symbology from the symbology layer. Can someone tell me what I am ...