Cursors are used by database programmers to process individual rows returned by database system queries.

learn more… | top users | synonyms (2)

5
votes
3answers
3k 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 ...
17
votes
3answers
4k 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 ...
8
votes
4answers
3k 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 ...
6
votes
2answers
2k 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-...
14
votes
2answers
1k 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 ...
4
votes
1answer
5k 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 ...
5
votes
1answer
2k 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, "...
6
votes
5answers
513 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, ...
3
votes
2answers
2k views

Using Select By Location to update field in feature class using ArcPy?

I am using Arc 10.1 and I am working on a script that takes a value from a field within one shape file and updates a field in another shape file based on its location. Basically I have smaller parcels ...
1
vote
2answers
124 views

Editing and manipulating tables with ArcPy? [duplicate]

I’m new to ArcMap and was wondering if anybody could help me out. I have a shapefile with counties and wells in that county. In the table I’m trying edit it so that for each county calculate the total ...
1
vote
1answer
73 views

Deleting the cursor object

Can someone explain why you need to delete the cursor objects and the iterator when you use for example: arcpy.UpdateCursor(blah) I've checked the esri docs and there doesn't seem to be an ...
0
votes
1answer
82 views

Arcpy to append results of pivot table

I have a script that does some processing but the main part are two things run a multiple ring buffer using arcpy.MultipleRingBuffer_analysis and four rings do some zonal statistics using arcpy.sa....
10
votes
5answers
807 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. ...
7
votes
2answers
2k 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 = ...
3
votes
3answers
3k views

SearchCursor() fails to read feature class?

I am very new to ArcPy and Python in general. I want write a script to read attribute table from a feature class and merge some data from a csv file into the table. Right now, I am just playing around ...
2
votes
1answer
7k views

Using arcpy.UpdateCursor to delete rows does not delete based on counter?

I am trying to delete rows from a shapefile using arcpy.UpdateCursor. The first thing I did was get a unique list of values from the key field "PolyGUID", then I iterate that list doing a arcpy....
4
votes
2answers
437 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 ...
4
votes
2answers
3k views

Getting values from attribute table and inserting another table using ArcPy?

I have line feature class of a river network and “FromTo” table. Lines are dissolved so they are not segmented from junctions. I need to write a Python script in ArcGIS to do following: Begin from ...
2
votes
2answers
1k views

Use updatcursor to replace values in multiple fields

I have spent a couple days digging through forums here, ESRI help and elsewhere and each variation of the codes I have tried has not worked. As best as I can tell this is due to my attempt to loop ...
2
votes
1answer
838 views

Only perform Near analysis on selected rows

I am writing a Python script to perform a near analysis on features from two different shapefiles with common attributes. This is happening in a Search Cursor. However, whenever I tried to use the ...
2
votes
1answer
716 views

How to use InsertCursor to add points to a point feature class?

I am struggling with a very simple task of inserting "SHAPE@XY" into a point feature class. Following is what I have: xy = [(361087.15436001675, 198747.07296730898), (361530.56426259346, 198976....
1
vote
2answers
749 views

Calculate Fields with Null Values using arcpy.da.UpdateCursor of ArcGIS for Desktop?

How do you calculate fields with null values? I have multiple fields that may have null values, that aren't being calculated in the third field. import arcpy with arcpy.da.UpdateCursor(r"...gdb\...
1
vote
2answers
603 views

How to get a search cursor on a particular version in arcpy

I have a versioned database in ArcGIS and I am wondering how can I tell arcpy what version to query. The closest I have got to an answer has been building a particular connection file that specifies ...
1
vote
2answers
115 views

How to keep a parameter blank in a script tool?

I've developed a sort of find and replace script tool that functions. But I'm not able to figure out how to find empty cells in fields and replace them.For the "Find" parameter, I have tried entering "...
6
votes
1answer
564 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 ...
5
votes
1answer
288 views

need to find max value among fields AND PRINT FIELD NAME

I have a Census dataset that contains eight fields with percentages. I would like a python script that finds the highest value between the eight fields, but also tells me which field the highest ...
4
votes
1answer
419 views

Counting and storing events contained within polygon using ArcPy?

I have a fairly large project and I would like to automate some tasks using Python. Problem is, I don’t have any experience with Python for ArcGIS. And I rarely use ArcGIS until something big like ...
4
votes
3answers
4k views

How to extract 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 ...
3
votes
1answer
308 views

Alternative to an arcpy script for points to lines to polygons?

I'm relatively new to arcpy and python, so I feel like I could be missing something obvious in regards to tool options for what I'm trying to achieve. I have a script that creates triangular ...
3
votes
2answers
2k views

Moving cursor backward i.e. opposite of row = rows.next()?

Can anyone tell me if there is a way to go up one row in python cursor? i.e. opposite of row = rows.next()
3
votes
1answer
993 views

Zoom to Shapefile attribute table row feature

I am working with the python code below in ArcGIS to zoom into a shapefile's attribute table row features without selected until the end of table one by one. I am trying to use this code but this one ...
3
votes
1answer
80 views

Updating attribute information

I need to write a script that updates the "LOCALITY" field in a feature class if it is empty with the suburb it is in. I have identified the number of properties with select by location and the ...
2
votes
1answer
2k views

Incorrect field name resulted in RuntimeError: ERROR 999999 (Also, better code for adding and calculating fields)

This is the bottom half of my code (and it's been edited somewhat to share publicly). The code works perfectly fine when the fieldList has only three fields in it, but when I populate it with all 108 ...
2
votes
2answers
1k views

GROUP BY clause in the UpdateCursor arcpy.da

I need to specify a "group by" clause for UpdateCursor arcpy.da. From here I found out that it's possible to do using an optional pair of SQL prefix and postfix. But there are no examples and I'm ...
2
votes
2answers
82 views

Update Cursor for automation of tedious data entry which keeps crashing ArcMap

I coded the Update Cursor for automation of tedious data entry where I am applying a previous Survey Company Identification Data to STRUCTURES_15096.shp from "OFFICIAL_STRUCTURES2015.shp" and it keeps ...
2
votes
1answer
79 views

Developing find and replace script tool?

I'm being tasked for developing a script tool that can find ultimately needs to be able to find any string and replace it with another string in an attribute table. Below is what I have so far, and it ...
2
votes
1answer
548 views

Am I over-complicating adding and then calculating fields? Suggestions for a better way? (Python)

I'm attempting to re-position a question I asked yesterday here. I am starting to think that the way I wrote my code just isn't the best way. Am I overcomplicating things? I know for a fact that ...
1
vote
2answers
120 views

Error adding row - sequence size must match size of row

I have this table with one row timestamp_pretty 3.1.2014 9:13 timestamp 1,38874E+12 msgid 3 targetType A mmsi 205533000 lat 53.4346 long ...
1
vote
2answers
262 views

building dictionary from feature class field values, how can I ensure there are no duplicate values per key

I found this code sample that builds a dictionary from two fields; the end result is a concatenation of all values per key to a new field. It's a great tool except that it doesn't account for ...
0
votes
1answer
63 views

Calculating well densities in selected counties using ArcPy?

I'm new in python and I have no clue how to do this. I am trying to calculate: total numbers of wells that fall into each county in a shape file, and update the county table with the total count. ...
0
votes
0answers
157 views

Issue with da.updateCursor on shape

I recently posted answer Determining Y coordinate for Create Fishnet from desired Angle of Rotation in Python/ArcPy? . While working on it I found something weird with da.updateCursor on shape field. ...
0
votes
1answer
78 views

Updatecursor returns with 'variable not defined'

I am fighting a bit with the cursor function since this morning. Thanks to the help of the people here and some tutorials I found I got this far import arcpy arcpy.env.workspace = "C:\\Users\\...
0
votes
1answer
323 views

Understanding UnicodeDecodeError: 'utf8' codec in ArcPy script?

I work with arcmap 10.3 and python 2.7.8. I have more than 500 shapefiles that located in many folders and subFolders. All Sub Folders are located in one large directory. I try with arcpy to detect ...
0
votes
1answer
568 views

Help with Python Update Cursor syntax

I'm having trouble running a loop to update the values in a particular field in attribute table by reading from a csv file. Any input is greatly appreciated. The following is the sample code: import ...
0
votes
3answers
1k views

Sum fields from ListFields - RuntimeError: A column was specified that does not exist?

Does anyone have a suggestion on how to otherwise solve the problem ... The need to automatically generate all the columns from the table, the calculation of the sum, the results are updated in the ...
0
votes
2answers
76 views

Creating a value-counting table with search- and update cursor

I'm a python beginner. I`m working with ArcGIS 10.2.2 and IDLE Python 2.7.5 I have a shapefile with around 20 fields, each attribute has a value between -3 and 3. This would look like this: I ...
0
votes
1answer
115 views

arcpy.UpdateCursor setting value to 0 instead of Null

I'm having issues setting a row value to 0 when joining a csv to a shapefile. When the shapefile value is not in the csv, the row is getting set to 0 instead of null. This is a huge problem as i'm ...
-1
votes
2answers
346 views

ArcPy: (SearchCursor/export to tiff ) with no output [closed]

I'm trying to write a script that uses a search cursor to loop through a field in a .shp file (Incident_Z) find every value that meets a specific condition (zip code=10004) and then at a scale of ...