Questions tagged [cursor]

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

Filter by
Sorted by
Tagged with
10
votes
6answers
13k 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 ...
7
votes
4answers
10k 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 ...
23
votes
3answers
5k 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 ...
4
votes
2answers
2k 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 ...
7
votes
2answers
3k 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-...
6
votes
4answers
7k 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 ...
5
votes
3answers
10k 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 ...
1
vote
1answer
52 views

Updating Z values with geometry of multipart and donut polygons with ArcPy?

I am trying to update Z values of polygon features with point features. The code is (found on GIS Stack Exchange) working good if no 'interor ring' or 'multipart' features are present in the polygon ...
6
votes
4answers
14k 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 ...
8
votes
1answer
1k 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....
5
votes
2answers
5k views

ArcPy Insert Cursor not inserting all rows?

I have a script here that takes data from a cross-tabulated non-spatial dataset where monthly values are stored in a single table row for a given year and linearizes those data so that each monthly ...
3
votes
2answers
3k 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
2k views

Comparing field values of two feature classes using ArcPy?

I have an intermediate fc #1 that contains data that I would like to append to my production fc # 2(final output). When working with the data, I would only like to append data from my fc # 1that is ...
18
votes
2answers
2k 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 ...
7
votes
1answer
11k 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 ...
8
votes
3answers
5k 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, "...
7
votes
3answers
4k 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 ...
2
votes
2answers
1k views

Update value in one table (feature class) by coping it from another table. The match between table is done on values from another field

I have two tables (actually both are feature classes in filegeodatabase). They pretty much identical except. one is in lat/lon. second one is projected. both have field line_length and objectid. ...
8
votes
5answers
843 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, ...
7
votes
1answer
5k 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 ...
5
votes
1answer
2k 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 ...
3
votes
2answers
6k views

Selecting points within polygon and updating attributes using ArcPy?

I have two feature classes, a polygon of sales areas for a city, and point layer of addresses. I want to select the addresses based on the sales area they are in and update their attribute table to ...
3
votes
2answers
3k views

Use Python to Find duplicate values in a feature Class and populate a field

So I found this python script on another post here and was trying to adjust it for my needs. I'm a very novice python user so I'm struggling with how to modify the script. I have a Feature Class ...
2
votes
1answer
469 views

Combining wildcard command along with %s in where clause statement for ArcPy?

I am trying to write a script where the user can search for a five digit zipcode using an input statement and a search cursor. The zipcodes in the file though are nine characters long (i.e. xxxxx-xxxx)...
1
vote
2answers
1k 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\test....
5
votes
4answers
5k 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, ...
2
votes
2answers
391 views

Change specific rows in attribute table using Arcpy in ArcGIS 10.3

I need to change values in field "name1" (string field) in specific rows: 70-72 into "no land use" value. I search Arcpy code to do it. i red How to select specific row in attribute table using ...
2
votes
3answers
3k views

How to update the Z value using an UpdateCursor?

I have created the following script to mimic the ArcGIS 3D Analyst tool, FeatureTo3DByAttribute, which creates a 3D copy of a 2D feature class and sets the Z to a specified attribute. import arcpy, ...
2
votes
1answer
353 views

arcpy.da.UpdateCursor with sql_clause for artifically inverting cursor loops

Why is row not recognized within my update cursor? The data is stored in a file geodatabase. I am using ArcGIS Desktop version 10.1 ArcInfo License. The screen shot shows the data "ORDER BY X ASC" ...
1
vote
1answer
150 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....
1
vote
1answer
362 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
216 views

Using LIKE clause in update cursor gives syntax error?

I am trying to write a second update cursor within one script. This requires a LIKE condition to look up a value within the same layer to identify rows to update the field within that layer (first ...
10
votes
5answers
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. ...
6
votes
2answers
391 views

Remove duplicates from a field

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 = "G:\\xStreetNew\\Duplicates.shp" ...
8
votes
2answers
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 = ...
3
votes
3answers
4k 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 ...
5
votes
2answers
656 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 ...
3
votes
1answer
3k 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....
2
votes
1answer
9k 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....
1
vote
1answer
1k views

Comparison between two fields of two tables using ArcPy cursors?

I would like to make a comparison between two fields of two different tables with a Python script. Fields for comparison are ROAD_NAME and NAME.ROAD. The idea is to check whether each element of NAME....
9
votes
1answer
15k 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 ...
8
votes
2answers
7k 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: ...
4
votes
2answers
5k 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 ...
4
votes
1answer
617 views

How to search on values of a value list in python toolbox?

I developed a simple python toolbox that lists values of a table in the value table parameter. The user can rank each row using the Rank field drop down values.Everything is ok untill user selected ...
3
votes
2answers
2k 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 ...
3
votes
2answers
2k views

Using Select Layer By Attribute in for loop with ArcPy?

I'm trying to iterate through a feature class and select each feature one by one by using the OBJECTID field. When I use a single value, the SelectLayerByAttribute works, but how do I compare the ...
2
votes
2answers
2k 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 ...
2
votes
1answer
1k 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 ...
1
vote
2answers
108 views

Removing duplicate pairs in Near Table

Generate Near Table or Near can be used on a single Feature Class to find the nearest feature to each feature. arcpy.GenerateNearTable_analysis(featureClass, featureClass, pairsTable) This results ...
1
vote
2answers
1k 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 "...