Questions tagged [cursor]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
75 views

Inserting values with arcpy.da.InsertCursor()?

Building on Standalone Python script to split a polyline with a point layer, I don't think I am manipulating geometry objects correctly. I am splitting an original line, preserving all the ...
1
vote
1answer
37 views

Converting abbreviation street type names to full names using dictionary for Python script tool? [on hold]

I have a data table with a column 'STREET_TYPE' which are street types (RD, LN, ST, AVE etc.). I want to make a custom tool in ArcMap's toolbox that will expand these abbreviations to their full names ...
0
votes
1answer
276 views

Arcpy InsertCursor.insertRow crashes ArcGIS after many (thousands) insertRow calls

I am looping over a quite large feature class (~5million records) While looping using a SearchCursor, I insert new geometries in a FileGeodatabase FeatureClass using arcpy.da.InsertCursor. The ...
1
vote
2answers
37 views

Taking substring of one field and using value to field calculate or update cursor another in ArcPy?

I have a field that has values such as DIMP 1234567 N. Eucla Ave/ W. Bonita Ave or DIMP Seg #1234567- Spinnaker Dr. Ventur or DIMP SEG 1234567 PYRITES AND ESMERALDA. I want to extract only the ...
1
vote
1answer
67 views

Optimizing slow multi cursor approach?

I designed a workflow, that although functional, is very slow and prone to errors. I am sure there is a better approach, but I cannot wrap my head around it. The environment is ArcGIS arcpy (Python 3),...
0
votes
1answer
63 views

Grouping wildfires dates by season and getting sum and count using ArcPy?

I am having some trouble creating a new shapefile and CSV to group wildfires into seasons. What I want to do is to group the wildfires by meteorological season (summer, fall, winter and spring) for ...
1
vote
2answers
57 views

Using Update Cursor within Search Cursor with ArcGIS Pro?

I am new to using ArcPy/Python and I'm running into problems with a script I'm trying to write. I'm using IDLE Python 3.6.8 ArcGIS Pro 2.4.0 Here is what I'm trying to do - I have 2 feature classes: ...
0
votes
4answers
936 views

Creating layers for each attribute value via Arcpy script

I'm having some trouble starting this script. Not sure how to start, as I have to create/output layers for each attribute value from a certain column named that has integers. They are all unique ...
0
votes
1answer
39 views

ArcPy UpdateCursor fails when adding a transform to SHAPE@XY due to type error

I have a Feature class with 285k point features. I am running this code on it: with arcpy.da.UpdateCursor(FeatClass, ["SHAPE@XY"]) as cursor: for row in cursor: cursor.updateRow([[row[0][...
0
votes
0answers
45 views

Using UpdateCursor in the same loop as SearchCursor

I have 2 layers, one with land plots and one with hazard zones. I want to iterate through the layer with land plots and for every plot I want to add 2 (or 3, depending on some variables) fields. Then ...
1
vote
0answers
40 views

Writing more than 1000 rows with arcpy.da.InsertCursor? [closed]

I have a GeoJSON which I'm able to successfully covert to a shapefile via the following process: using arcpy.asShape to find geometry, and inserting this geometry as new fields using cursor insertRow)....
3
votes
2answers
121 views

Removing values from shapefile with ArcPy?

I have a large shapefile with lots of duplicate records. However, each duplicate record has an accuracy rating. I want to remove all duplicate records with a lower accuracy rating. This would be ...
8
votes
3answers
6k 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 )....
1
vote
1answer
37 views

Filter fields by expression arcpy

I have to trasform a script (which I didn't write myself) from QGIS to ArcMap. In the script a filter by expression is used. The function has the input inl (= the layer with the data that should be ...
1
vote
1answer
114 views

Updating Cursor to Include Newly Created Features?

I am using ArcMap 10.1 and python to create cursor that starts at the one and only row of a polyline shapefile, some code runs to create a new feature based on the position of the exisiting feature, ...
1
vote
2answers
45 views

Using SearchCursor and ArcPy to add message?

This Validates that all Polygons have a map unit. verify that the absence of a Map unit is caught by the check... here we test for the empty string or the python "None" type. Verify that this is how ...
-1
votes
2answers
59 views

Updating Z coordinates of points in polygons with ArcPy

I am trying to update Z values of polygon shape with ArcPy. This script is working without error but increasing the first (0 position vertex) vertex twice. I want to update only once. How can I avoid ...
0
votes
1answer
53 views

Getting same result with less code with PythonWin ArcPy? [closed]

I have finished writing code and it does what I need without having any error. However, I am wondering if there is any option to get the same result in fewer lines, pecially the for loop inside the ...
5
votes
3answers
9k 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 ...
0
votes
1answer
53 views

Update Z values of polygon veritices with multiparts and donuts [duplicate]

I am trying to update Z values of the vertices of the polygon shape. The script bellow works for polygons without multiparts and donuts. If I run this script for polygon shape that contains multiparts ...
1
vote
1answer
33 views

ArcPy search data from a list of values

I have a list WRL_ID = ['NW-E8-105151', 'NW-E8-105138'] and I am trying to search these values in a field called ID. If the value exist, print 'It's in SDE', if not, print 'Not in SDE'. Right now ...
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 ...
1
vote
1answer
1k views

Which is the faster way to copy data to another feature class: Feature Class to Feature Class or Insert Cursor

I have a feature class with 1 million records. Which is the faster way to copy data to another feature class: Feature Class to Feature Class or Insert Cursor?
6
votes
3answers
8k 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 ...
0
votes
1answer
43 views

Updating z value of geometry using updateCursor?

I am trying to update the Z value of a polygon using update Cursor and it just doesn't work! I have been exploring this site and trying different codes without success. I have a shapefile with ...
3
votes
1answer
48 views

Insert Cursor Not Filling XY Field

I have a table with a set of original XY values and a set of new XY values. I want to create new points of the new xy's using the insert cursor. My code updates the ID and Sp row but not the XY row. ...
2
votes
1answer
136 views

Using ArcPy to insert new data into shapefile without editing it?

I want to insert new data into a empty shapefile. I have an array with the fields values of each row and I use InsertCursor to add these data to my shapefile. When I run the code if the shapefile is ...
0
votes
1answer
47 views

How can I insert degree symbol to attribute table in feature class?

I am trying to insert a bearing string into an attribute table, I want the string to look like this -> S 58°15'31" W , but what I am getting in the table is this -> S 58°15'31" W The code I am ...
1
vote
2answers
37 views

Use ArcPy for finding value throughout all fields and export to new layer

I need to find a way to find a specific value in the attribute table and then export all rows with said value to a new feature class. Below is the code that I have managed to come up with (using ...
2
votes
2answers
2k views

arcpy.da cursor iteration not started?

I am trying to convert cursors written in 10.0 to use the new arcpy.da module in 10.2.1. If I step through the code in debug mode, it steps into the for loop; however, when I attempt to run the code I ...
0
votes
1answer
51 views

Updating rows based on number and position in table using ArcPy cursor?

I'm trying to update rows using the update cursor, but based on the number of rows in a sequence of three list items. Looking at the list below, it needs to update first four rows to 'B', then the ...
0
votes
0answers
25 views

RuntimeError: Objects in this class cannot be updated outside an edit session

I recieved this error: RuntimeError: Objects in this class cannot be updated outside an edit session while runnng this code: # import modules import arcpy import random from arcpy import env ...
1
vote
1answer
83 views

Getting for loop which stops after first one to iterate properly?

I originally asked UpdateCursor can't acquire lock, but can acquire lock in TestSchemaLock and got some help about why my code wasn't acquiring a lock. My new problem is that my code isn't fully ...
3
votes
1answer
79 views

Adding unique indexes which start with “A” go up to 99 (A1-A99) and then start again “B1” and continue up to B99 and so on? [closed]

i want to add unique indexes which have to start with "A" go up to 99 (A1-A99) once the 99 rows of finished it has start again "B1" and to continue up to B99, so this index system has to continue ...
1
vote
2answers
49 views

Transferring Data From One Table to Another Using Multiple Keys in ArcPy?

I have data in one field and I want to transfer it to a specific field in another table based on specific keys Such as ID, road_type and veg_type. My original table looks like this ID Road_Type ...
3
votes
2answers
48 views

Inserting field values in table?

I am trying to insert Field Values to an empty table. My code by so far: arcpy.CreateTable_management(r"C:\Users\esri\Documents\ArcGIS","test") arcpy.AddField_management("test","total","LONG") arcpy....
0
votes
1answer
6k views

Looping through List With ArcPy Cursor?

My team is working on a python script that does various updating tasks to our streets file. A part we are getting stuck on is trying to update a field. Currently we have a field FEDROUTE that is ...
1
vote
1answer
34 views

UpdateCursor: value from different rows (ArcPy) [closed]

I am new to ArcPy. I have an attribute table with the following columns and fields I want to fill up the column Combined as follows: If number contains 2 categories, "combined" will be A,B. If ...
2
votes
2answers
53 views

Update 1 random value in a group of values

I have an attribute table with a date field and a random field. The date field has three different times for each day. I need to input a '1' in the random field for one of those three times in each ...
0
votes
1answer
41 views

arcpy.da.UpdateCursor not updating [closed]

The script will run without error, but the updatecursor at line 123 does not update the table. the addmessage before and aftr the loop shows right numbers but update does not seem to work. # -*...
1
vote
1answer
29 views

Add date and time to attribute table using ArcPy insertcursor

ArcPy under ArcGIS Pro 2.3.2. I am adding a Python datetime.datetime object to a shapefile attribute table using an arcpy insert cursor. The problem is that when I add the datetime instance, the date ...
0
votes
1answer
43 views

Using Cumulative Geometry Calculation to Add Field in ArcPy

I am using Desktop 10.6, Basic license, Spatial Analyst, Python 2.6, 2019 AD. I have 4 overlapping features in a polygon feature class. I'd like to sort the features by the depth field, calculate the ...
0
votes
1answer
60 views

Using Editor tab Clip function in ArcPy?

I am using ArcGIS Desktop 10.6, basic license, Spatial Analyst, python 2.6, 2019 AD. I have a polygon feature class with representing a lake, with multiple features overlapping (all in the same ...
0
votes
1answer
37 views

Using arcpy.da.SearchCursor to obtain values from field that correlates with “year” field?

I am very new to coding. I am attempting to use SearchCursor to go through the attribute table of a feature class and return a list of unique years from the years field (which I have done). I am ...
2
votes
1answer
26 views

Updating field in geodatabase table depending on other field using ArcPy?

I have a table in a file geodatabase that has "FieldA" and "FieldB". I want to update FieldB with one of two values, depending on if there are one or more records with the same value of FieldA. ...
0
votes
1answer
49 views

Fetching data from ArcGIS attribute tables using ArcPy? [closed]

I want to fetch/extract data from ArcGIS attribute tables (to set some temporal series) using Python. Because of the structure of my tables and their disposition, I thought of using the "division" ...
2
votes
1answer
39 views

Updating arcpy.Array() syntax from Python 2.7 to 3.6.6 for ArcGIS Pro 2.3?

I was working through an exercise designed to teach basic Python skills in ArcMap using Python 2.7. The file below consists of 34 pairs of x,y coordinates. The script creates a new empty polyline ...
0
votes
0answers
15 views

Getting Error for Search Cursor in Arcpy module

I am trying to use Search Cursor on Data. Following code is running for Numeric field without any error. cursor=arcpy.da.SearchCursor("Wells","*",""""Depth"=30""") for i in cursor: print i[1] ...
0
votes
0answers
37 views

Python Code to return column data in multiple feature classes and gdb's

>>> import arcpy ... in_table = r"K:/MAPPING/PA/LEIDY/REPL/0188_18/MDL/GIS/MASTER/0188_18.gdb/DP_Centerline" ... with arcpy.da.SearchCursor(in_table, ["last_edited_date"]) as scursor: ... ...
0
votes
1answer
44 views

UpdateCursor with SelectByLocation for multi polygon

At the end of this script, I have an UpdateCursor that updates the PLOTS field in the Timber_Type_Polygon with the amount of plots that are within the Timber_Type_Polygon. There's 3 polygons within ...