Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
24 votes
3 answers
6k views

Exporting table to XYZ ASCII file via ArcPy?

I'm looking for a way to export an ArcGIS table (created with the Sample tool) to a text file via ArcPy. I can do this in ArcGIS via the context menu by right-clicking the table, but have not found ...
Toni's user avatar
  • 243
23 votes
5 answers
27k views

Obtaining extent of each polygon in shapefile using ArcPy with ArcMap

In ArcGIS 10 and Python I want to get the extent (xmax, ymax, xmin, ymin) info of each of the polygons in a shapefile. I can get the extent of the whole shapefile using file=r"D:\SCRATCH\ARCGIS\...
GeorgeC's user avatar
  • 8,298
19 votes
2 answers
3k views

How is the data access cursor performance so enhanced compared to previous versions?

The data access module was introduced with ArcGIS version 10.1. ESRI describes the data access module as follows (source): The data access module, arcpy.da, is a Python module for working with ...
Aaron's user avatar
  • 51.8k
16 votes
1 answer
33k views

How to delete selected rows using ArcPy?

I want to delete all rows in a feature class but remain rows 1 to 5. In other hand I want to remain first five rows and delete others. I know that I have to use search cursor and update cursor but I ...
BBG_GIS's user avatar
  • 5,835
14 votes
5 answers
3k views

Looping through 16 million records using ArcPy?

I have a table with 8 columns and ~16.7 million records. I need to run a set of if-else equations on the columns. I've written a script using UpdateCursor module, but after a few million records it ...
cpt_python's user avatar
12 votes
3 answers
2k views

Deleting cursor used in SearchCursor within dictionary comprehension?

If it is best to open cursors using a with statement to ensure it is deleted, like so: with arcpy.da.UpdateCursor(fc,fields) as cursor: Then, if a cursor is used as the iterable in a comprehension ...
J. Flann's user avatar
  • 278
12 votes
1 answer
2k views

Fastest methods for modifying attribute tables with Python?

A while ago, I wrote a quick Python function for converting an attribute table to a python dictionary, where the key is taken from a user-specified unique ID field (typically the OID field). ...
nmpeterson's user avatar
  • 8,393
11 votes
6 answers
17k views

Moving / offsetting point locations using ArcPy or ModelBuilder?

I have a number non-georeferenced CAD layers (see this question) that have text annotation features. I have created a model to convert the text to points, but after converting the annotation to a ...
RyanKDalton's user avatar
  • 23.2k
11 votes
4 answers
7k views

ArcGIS Python SearchCursor file locking?

I have a script that gets a value from a shapefile's field to return to the user. It seems that only when the arcpy.SearchCursor is called ArcMap 10.0 locks the file and it doesn't get removed ...
Justin's user avatar
  • 3,398
10 votes
5 answers
1k views

How to improve performance when using ArcGIS cursors in Python with big tables?

I have a pretty big point feature class in a file geodatabase (~4 000 000 records). This is a regular grid of points with a 100m resolution. I need to perform a kind of generalization on this layer. ...
Stéphane Henriod's user avatar
10 votes
3 answers
15k 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 )....
Staley's user avatar
  • 279
10 votes
2 answers
10k views

Calculating Date Field with today's date from datetime.date.today()?

I'm working on part of tool that will use arcpy.CalculateField_management to add the current date to the attribut table. I've wandered far and wide on the interwebs and can't seem to find the ...
fathom analytics's user avatar
9 votes
4 answers
27k views

Using arcpy.da.InsertCursor to insert entire row that is fetched from search cursor?

This is a simple process using the legacy cursors, but I cannot figure out how to do it with the newer Insert Cursor from the Data Access module. I basically want to take the entire row from a Search ...
jread's user avatar
  • 93
9 votes
2 answers
9k views

insert cursor "Row contains a bad value"

I'm having a problem copying data from a shapefile to a feature class using an insert cursor. Here is the part that is causing trouble: newRows = arcpy.InsertCursor(Target) sourceRows = arcpy....
fomafomich's user avatar
8 votes
5 answers
1k views

How to access adjacent rows with cursor?

In the attached screenshot, the attributes contain two field of interest "a" and "b". I want to write a script to access the adjacent rows in order to make some calculations. To access a single row, ...
Aaron's user avatar
  • 51.8k
8 votes
1 answer
3k views

Why del cursor/row objects of ArcPy?

Can someone help me understand what the last 2 lines of this code does: import arcpy arcpy.env.workspace = "c:/esripress/python/data/exercise07" arcpy.env.overwriteOutput = True copy = arcpy....
Gabe 's user avatar
  • 127
8 votes
3 answers
6k views

Is it possible to sort an arcpy.da.UpdateCursor()?

I have an ArcPy Data Access update cursor that I would like to sort before making updates to it. The cursor makes updates if I don't sort, but if I add a sort to the cursor I get an error, "...
TurboGus's user avatar
  • 932
8 votes
1 answer
2k views

How to improve performance of nested search cursors?

I have three nested SearchCursors. It works correctly but with slow performance. There are some solutions to improve the searchcursor performance like dictionary but i don't know how to use it with ...
BBG_GIS's user avatar
  • 5,835
8 votes
1 answer
7k views

Selecting specific row in attribute table using ArcPy (without iterating through whole table)? [closed]

I am using ArcGIS 10.2 and have assumed until now that it is possible to select a specific row in an attribute table. However, I can't seem to find a way to do this. The only available methods seem to ...
songololo's user avatar
  • 1,724
8 votes
4 answers
12k views

Debugging RuntimeError: workspace already in transaction mode from arcpy.da.UpdateCursor and ArcSDE feature classes?

I am making my first attempt at editing an ArcSDE feature class with python through a da.UpdateCursor. I'm essentially taking code I've written for a file geodatabase feature class and applying it to ...
Emil Brundage's user avatar
8 votes
2 answers
3k views

Getting unique value of second field using arcpy.da.SearchCursor?

I have a feature class and using arcpy.da.SearchCursor I'm getting unique values of a field (e.g. Name). How can I use this method to get the associated row value of a different field (diff field = ...
artwork21's user avatar
  • 35.2k
8 votes
3 answers
454 views

What technology is used behind ArcPy cursors?

I'm using ArcGIS Server 10.0. I have a geoprocessing using arcpy search, update and insert cursors. I'd like to know more about the technology behind these cursors. Does it use any driver or pool to ...
yo_haha's user avatar
  • 1,137
8 votes
2 answers
8k views

Calculating XY coordinates in Decimal Degrees from projected dataset in model or script?

Is it possible to calculate points XY coordinates in Decimal Degrees in model or script when a feature class is in projected coordinate system? It's easy when a FC is in geographic coordinate system: ...
Marcin's user avatar
  • 1,821
7 votes
3 answers
14k views

row.getValue() doesn't work but row[1] does

for some reason I can't get row.getValue to work properly... my script will only work if I use row[0] and get the value manually but I am sure the location/order of my fields will change from dataset ...
user30312's user avatar
7 votes
2 answers
1k views

Does arcpy.da.SearchCursor store the results in an array?

When performing a query like this: var = 2 with arcpy.da.SearchCursor(in_table="table", field_names=['c1','c2'], where_clause = '[c1]' + '=' '\'' + str(var) +'\'') as cursor: I've just simply been ...
shane's user avatar
  • 83
7 votes
2 answers
622 views

Removing duplicates from field using ArcPy with ArcMap

I am using ArcPy with ArcMap. I need to remove duplicates from a field named "Intersecti" Here is my code. I used list..set. It's not removing any duplicates. import arcpy duplicates = &...
sys's user avatar
  • 145
7 votes
3 answers
1k views

Counting in for-loop using ArcPy Cursor?

When using the UpdateCursor, is there a "built-in" way to count within the loop? In the moment I am using a variable i and add 1 after each iteration: cur = arcpy.da.UpdateCursor("points.shp","ID1") ...
Christoph's user avatar
  • 169
7 votes
2 answers
4k views

Using UpdateCursor for joined field in ArcPy?

I have a huge point vector data (around 3 million point; in a gdb) with attributes and I have table (created with Near analysis.). I want to copy one of the field values to data. So I joined the table ...
Gary's user avatar
  • 540
7 votes
1 answer
15k views

Using ArcPy update cursor to replace <Null> value?

I have been combing the help associated with (None) values in arc, and have not been able to solve the following problem: I have a a field with mixed Null and integer values: 0 100 I would like ...
Sarobinson's user avatar
7 votes
1 answer
274 views

ArcPy UpdateCursor auto pausing after every 1000 records

I have an update cursor running that updates a field based on a lookup table (Python dictionary). The cursor completes fine, but seems to pause and hold after each 1000 records - I have a test in it ...
dklassen's user avatar
  • 2,920
7 votes
2 answers
5k views

How to create an offset polyline in arcpy?

I am trying to create an offset polyline using arcpy, identical to the function in ArcObjects (constructoffset). After trying to access ArcObjects in arcpy, which I found difficult for those not well-...
ndimhypervol's user avatar
7 votes
3 answers
5k views

Cannot get rid of lock on file geodatabase and feature class created in Python script

I have a python script, (for ArcGIS 10), that creates a new file geodatabase, creates a new feature class in that file geodatabase and then reads data from an SDE feature class to populate the new ...
Jeff Berry's user avatar
  • 1,820
6 votes
4 answers
10k views

Accessing attribute table within shapefile and replace values?

I would like to find a Python script that will access an attribute table within a shapefile and either update or replace records inside a field column. More specifically, I would like to use the ...
galindo's user avatar
  • 193
6 votes
3 answers
11k views

Auto-incrementing in Python Script with ArcPy cursor?

I want to autoincrement values in a field within a Python script. I've done this using Field Calculator and the code referenced here. I tried using this code in the Python script below but it is not ...
Patty Jula's user avatar
  • 1,083
6 votes
2 answers
6k views

Does arcpy.GetParameterAsText() have a data type?

import arcpy # Retrieve input parameters inX = arcpy.GetParameterAsText(0) inY = arcpy.GetParameterAsText(1) inDescription = arcpy.GetParameterAsText(2) incidentsFC = "C:/Data/Yakima/Incidents.shp" ...
Salman's user avatar
  • 736
6 votes
3 answers
2k views

Zero filling attributes using ArcPy/Python?

I am just learning python and I need to convert a 2 digit numeric attribute in a table to a 2 digit zero-filled attribute in a script. For example, 9 needs to be 09.
Giuseppe Filoso's user avatar
6 votes
2 answers
361 views

Finding common Intersection area of each pair of rectangles with circle buffers inside each one using ArcPy with ArcGIS Pro

I'm in ArcGIS Pro environment and for this case a simple Intersect tool is not enough, so I'm trying some Python scripting. Below is the rectangles and the circle buffers that I need their pair ...
Gustavo M.'s user avatar
6 votes
3 answers
15k views

Iterate through features to use selection as input for ExtractByMask

I need to iterate through each of the features of a feature class successively to use each one as the mask to extract from a raster with the ExtractByMask tool. Basically I'm looking for the "Iterate ...
Yan Hildebrand's user avatar
6 votes
1 answer
2k views

How to add Attributes to a polygon with arcpy

I have a question about arcpy. I want to create a polygon FeatureClass with attributes. The code below is just test-code that generates some polygons for speed testing. I want to add some additional ...
gnurrr's user avatar
  • 61
6 votes
3 answers
9k views

Extracting data using arcpy.da.SearchCursor?

I have a shapefile of point features showing fire locations in a given year. One of the fields is named "YYYYMMDD" and indicates the corresponding date that that fire happened. In Python, I am trying ...
Julio Castillo's user avatar
6 votes
1 answer
273 views

Update Cursor skipping last row?

I have created a python function within field calculator to calculate the time difference between a timestamp (yyyy-MM-dd HH:mm:ss) in a row and the row after (the interval field in seconds). I have ...
Will's user avatar
  • 151
6 votes
2 answers
5k views

Calculating field in ArcGIS Desktop using ArcPy cursor?

I'm trying to calculate a field based on the values of others in the same layer in a calculation. I can't work out why its not working. I've even cut everything down to just be based on one field and ...
Nevu's user avatar
  • 429
5 votes
3 answers
474 views

UpdateCursor RuntimeError: An invalid SQL statement was used

with arcpy.da.UpdateCursor(inFeatures, "[TDS_Name]") as change_cursor: for x in change_cursor: if x[0] == None: x[0] = x[0] else: x[0] = x[0]....
Griffin Johnson's user avatar
5 votes
4 answers
7k views

Getting values of last row in table with ArcPy/SearchCursor?

I would like to base my query on the last row of a table? I know the basic syntax/functionality for my search cursor, how do I query only the last row; Below is an example of my search criteria, ...
Geoffrey West's user avatar
5 votes
2 answers
4k views

ArcPy Data Access Insert Cursor not writing geometries to feature class?

I'm using PyScripter and running ArcGIS 10.2.1. I am having troubles with the Insert Cursor in the arcpy module. I have an empty feature class in my geodatabase and have created the short script ...
David's user avatar
  • 135
5 votes
2 answers
1k views

Is it a bad idea to convert a File Geodatabase table to a dictionary?

First, what am I trying to do? I am building a Python script that should be called from an ArcMap 10.0 toolbox. This scripts uses (among other inputs) data contained in huge gdb tables. It processes ...
7hibault's user avatar
  • 265
5 votes
2 answers
5k views

Setting values in feature class attribute table to null

I've created a point-data feature class (fc) containing data from a simple .txt file using ArcPy as follows: arcpy.CreateFeatureclass_management(out_path= outPath, out_name= 'fcTest', geometry_type= &...
Hans Roelofsen's user avatar
5 votes
3 answers
3k views

Creating Where Clause from user input via Python list with ArcPy

I am trying to perform a query based on values in a Python list. The where clause will then be used in an Update Cursor, so that the rows NOT equal to the values in the list will be deleted. This is ...
dubch87's user avatar
  • 337
5 votes
2 answers
933 views

Python error in Update Cursor for ArcGIS: " 'int' object has no attribute 'type' "

I am fairly new to python and am trying to make a script that looks through an ArcGIS feature class and updates <null> values to 'tbd' or 99999 based on the field type (string, double/integer). ...
Gsci's user avatar
  • 71
5 votes
1 answer
727 views

UpdateCursor gives Too few parameters Expected 1?

Can anyone tell me why my script isn't working? I can't figure out where I went wrong. I am working with an Access personal geodatabase. Adding a field, then updating that field with yes if the field ...
Colin's user avatar
  • 139

1
2 3 4 5
21