Questions tagged [cursor]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
92 views

Using searchCursor to add to a File Geodatabase Table

I'm trying to add some raster data to a File Geodatabase Table and export it to an excel file. The problem is that it wont print it to the file automatically, I have to create the file first by ...
3
votes
2answers
551 views

Save a selected row into a new shapefile with arcpy

I have a shapefile with 100+ rows. What I like to do is to select each row and export all its data to a new shapefile. I tried using the arcpy.da.SearchCursor as follows: with arcpy.da....
1
vote
1answer
583 views

sql_clause ORDER BY in da UpdateCursor

I'm using the following code in my ArcMap python window and it's throwing an error. I'm trying to sort by two fields, one ascending and the other descending. The error seems to be indicating a typo ...
1
vote
3answers
3k 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 ...
2
votes
2answers
538 views

Iterating through records specific number at a time using ArcPy?

I'm working with a table that has over 180,000 records. My code searches through the table and pulls field values (meeting a SQL statement) into a list. This list is used as part of a Search by ...
1
vote
1answer
48 views

Using Update cursor from data access module? [closed]

I am currently attempting to use an update cursor from the data access module to update the PPCVal field based on a certain a set of conditional logic rules that I've laid out below. I've included ...
-1
votes
1answer
96 views

Count and sum unique values with domain coded value

I have written a code for count and sum unique values. I am getting the unique values count on Field "SubtypeCD" by using following code only if I am using "row[0]" instead of "desc_Domain[row[0]]]"....
0
votes
1answer
37 views

Search Cursors Inside of Loops Throwing Runtime Errors?

I am attempting to create a function to use a search cursor and associated list to get the unique values of a specified field and then use that list of unique values to loop through each value, create ...
1
vote
2answers
65 views

Arcpy: How to use da.cursors to 'pivot' one table into another

Let say I have a table that looks this: State--City TX--Houston TX--Dallas OK--Stillwater And I want to insert it into a table that looks like this: State--City1--City2--City3 For results that ...
1
vote
3answers
176 views

Using field names on output filename in arcpy

I am trying to write a loop in arcpy that will first make a selection by attribute in one feature class and then make a selection by location on another. Then I want to copy the selected features into ...
0
votes
1answer
680 views

StopIteration: iteration not started error in arcpy.da.UpdateCursor

I cannot figure out why I keep getting this "StopIteration: iteration not started"error. I have confirmed the feature class 'vriTHLB_eliminated' exists and has records and all required fields. Here ...
0
votes
1answer
36 views

looping over feature classes

I have the following script which selects the row with the maximum value in a specified field, and then deletes that record. This works when specifying a single input fc. I am working with ArcGIS 10.5....
0
votes
1answer
59 views

arcpy.da.Editor not saving edits to base Oracle Spatial tables

Can't post code because of Fed policy, so I will ask the question here. We are working on a series of polygon feature classes that are used to define large activity areas. These polygons are modified ...
-2
votes
1answer
373 views

Search Cursor to count not null values records?

I am trying to achieve print all featureclass, total count, notNullvalues. I am trying hard on this code. but getting Error: suggest how can I code better and working. I am not regular python user. ...
3
votes
1answer
211 views

Float not iterable

import arcpy arcpy.env.workspace = "c:/esripress/python/data" fc = "Hawaii.shp"     cursor = arcpy.da.SearchCursor(fc, ["OID@","SHAPE@"])   for shape in cursor:        print "Total area: {}"....
0
votes
2answers
121 views

UpdateCursor only updating last row [closed]

I am working with ArcMap 10.2. In the following code, I have a function, build_dictionary, that builds a dictionary that will be used to populate a field within another layer. With the second function,...
1
vote
1answer
4k views

Python Error: “ValueError: need more than 1 value to unpack”

Can someone help me figure out what is not working in this piece of code: import arcpy import fileinput import os import string from arcpy import env env.workspace = "C:/EsriPress/Python/Data/...
2
votes
1answer
138 views

arcpy.da.UpdateCursor gives SyntaxError? [closed]

I'm trying to use Python to: Do a union between 2 layers (LandTrust and Precincts) - this works Create a field called "Overlap - this works Create a da.UpdateCursor to populate the fields with values ...
0
votes
1answer
215 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 ...
1
vote
1answer
102 views

Assigning fishnet attributes by row instead of by column with ArcPy?

I created a fishnet grid and assigned numeric attributes 1-16 to a new field using the arcpy.da.UpdateCursor function. It however assigned the attributes north to south (see image). How can I change ...
1
vote
4answers
70 views

Insert cursor only copies 80% of data due to lock?

I have two tables: 1) feature class (i.e. table in code) = sites under "SiteID" and mean july data under "JulyMean". The sites have duplicates, therefore there are several groups of same sites. There ...
0
votes
0answers
35 views

Selecting features from another shapefile using ArcPy cursors and SelectLayerByLocation?

Having the code below im trying to select all the table features from an school_enroll.shp that are within each bigger zones from the hs_bndy.shpwhen i use the arcpy.SelectLayerByLocation_management ...
0
votes
1answer
113 views

Arcpy query String field

I have numerous shapefiles with two fields, "ID2" (Integer) and "FILENAME" (String). Using arcpy I'm trying to query the attribute table for rows that have a certain value ("SCN_TCV_001_2002") in ...
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....
0
votes
1answer
186 views

Iterating field name in UpdateCursor?

I have a series of fields to check for a certain value, then calculate other fields with using UpdateCursor. Fields are: SPECIES_CD_1, SPECIES_CD_2, etc.. up to SPECIES_CD_99 Here is the general ...
1
vote
1answer
122 views

From List into ArcPy Feature Class with InsertCursor

I am parsing an NMEA file to be able to import it into an ArcGIS with arcpy. I finalised the parsing part and also created a list with the appropriate form. But if I'm trying to insert the List into ...
1
vote
0answers
113 views

Iterating through a Feature Class

I am using ArcGIS Desktop 10.4. I am trying to iterate a process through a Feature Class to calculate individual (and unique) values in a particular field. I can calculate the field just fine, but ...
0
votes
1answer
45 views

Extract Specific Raster Cells From Gridded Shapefile

I have a raster image with a corresponding shapefile grid in which I am looking to extract an individual piece of that image using a single grid of the entire shapefile. The gridded shapefile is ...
1
vote
2answers
111 views

Changing field values with ArcPy cursor?

I would like to change the value of one field in the table base on the value from another table This syntax does not work. Parsing error SyntaxError: invalid syntax (line 6) fc = 'Dudley_vehicles'...
0
votes
2answers
107 views

Updating z values from joined table using ArcPy?

I have joined two tables. The first table includes the current z values, while the new table includes new z values. I first tried to snap, but this didn't update the Z values, only X and Y. How can I ...
1
vote
1answer
124 views

Use UpdateCursor in combination with .distanceTo method in ArcPy

In a given city a line is constructed, and for every building in that city it is required to know the distance to that line. Therefore the .distanceTo method from the ArcPy Geometry class is used. It ...
1
vote
1answer
50 views

update cursor inputting the same values [duplicate]

I've got a numpy array and need to sum the values in the rows. Then use the Update Cursor to update a field with this value. However the update cursor is updating the field with the same values. tbl =...
2
votes
2answers
179 views

Converting shp file to wkt polygon string using ArcPy?

I used the following code to convert .shp file to .wkt. The code was successful but where can I find the .wkt file (the print row ouput)? Is it possible to add a path for the wkt files to be ...
0
votes
1answer
34 views

Populate a value in one feature class from value in another feature class using SearchCursor

I have two feature classes: COH_Address (points) TAXLOTS_NOAT (polygons) I am trying to find the best code for using a cursor to run through TAXLOTS_NOAT, grab the value for TLNO, and populate the ...
3
votes
2answers
364 views

How to add vertex on the center of a polyline object?

I've got an arcpy.Polyline() object and I have to insert a new vertex in it, which has to be placed on a center of a line. Right now I can calculate the center point coordinates but how to add it to ...
0
votes
1answer
89 views

Snap point features based on attributes of another feature class - ArcPy

I am trying to snap a point feature class to another point feature class based on matching attributes. I have a script tool built and it works for a sample area where all records match, however when ...
0
votes
1answer
82 views

Calculate the area in sqkm across UTM zones using arcpy cursors

I am trying to update the area field in sqkm of my table using Search and Update cursor from the arcpy library. The area needs to be updated using the different utm zone. I intersected my shp (that I ...
0
votes
1answer
85 views

arcpy.da.SearchCursor feature orders mixed up in Oracle enterprise geodatabase?

Something very weird happen when I use a SearchCursor over a feature class in an Oracle Enterprise Geodatabase The order of the features in the SeachCursors changes depending of the field_names ...
-1
votes
1answer
191 views

Counting non-null attributes using ArcGIS Field Calculator?

I have an ESRI featureclass with a lot of records that have been scored to certain criteria, although criteria have been left null for records where they aren't deemed relevant. I'm now trying to ...
3
votes
1answer
61 views

ArcMap CSV Export

I am working on a export from ArcMap 10.5 with a PostgreSQL databse in Arc Server. I have polygons with addresses within it. I am trying to create a CSV Export, for the addresses within that ...
2
votes
1answer
474 views

ArcPy - Strip leading and trailing blank spaces from records in table

I have a feature class in ArcMap which for many rows in numerous fields has records with leading and/or trailing blanks spaces. I want to remove iterate through the fields and rows and remove any ...
1
vote
2answers
483 views

Using ArcPy cursor to concatenate row values?

I am ArcGIS 10 user and I want to create ArcPy script for simple concatenate row values like this tool Concatenate Row Value that works with ArcGIS 10. I have three fields in my shapefile id,field1,...
1
vote
1answer
37 views

Identifying duplicates between two different feature classes

I am trying to identify duplicate records between two feature classes in a file gdb (Arc 10.3). I first create a set of unique IDs present in FC_1, then use an if statement to identify whether the IDs ...
0
votes
0answers
137 views

Running out of memory with arcpy.da.UpdateCursor()?

Could anyone let me know if they see why this would cause a memory issue? The user running the script let me know he got a message that he ran out of memory while the script was running. EDIT: ...
2
votes
2answers
108 views

Identify duplicate attributes and keep value of earliest record

I have rows in a table that have duplicate ID values in one field. I would like to identify these duplicates, keep the ID value of the earliest entry, and null out the ID field for the other ...
2
votes
1answer
206 views

Using SearchCursor - TypeError: Not a Spatial Reference

I am trying to use a search cursor to print three columns of data (out of the existing 10). I run a dissolve early in the code and use raw_input so I can specify which fields to use for the dissolve ...
0
votes
1answer
315 views

Finding matching rows across columns and populating a separate column

I am trying to write a script that recategorizes 70 attributes in to 1 of 5 attributes. I have two tables, each with two columns that I am focusing on. The first table has one column with 20k rows ...
1
vote
2answers
309 views

Update Cursor Script Not Running

I have a script I want to use to update a value for a group of selected features in ArcMap in a string field. I am using the UpdateCursor method but I cannot get the output generated that I want. I ...
1
vote
1answer
476 views

Using dictionary and cursors to calculate a field based on values from another table - KeyError [0]

I'm new to dictionaries and am still a Python beginner. I'm trying to update field(s) based off of field values in another table using the OID field as a key. The search cursor dictionary has been ...
0
votes
2answers
385 views

Selecting table records by attribute if in Python list

I would like to create a subset of a table based on values in a Python list that I created from a search cursor. I have not been able to get the where_clause correct and keep getting errors. Here is ...