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
0answers
40 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
39 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)....
1
vote
1answer
36 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
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 ...
0
votes
1answer
51 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 ...
-1
votes
2answers
56 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
51 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 ...
0
votes
1answer
57 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 ...
0
votes
1answer
40 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 ...
2
votes
1answer
135 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 ...
3
votes
1answer
45 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. ...
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 ...
0
votes
0answers
22 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
2answers
48 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
47 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....
1
vote
1answer
33 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
44 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 ...
0
votes
1answer
40 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
26 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
41 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
54 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 ...
2
votes
1answer
25 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
37 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
3answers
58 views

Using field in place of value in WHERE clause of arcpy.da.SearchCursor()? [closed]

I am developing an ArcPy script in ArcGIS Desktop 10.7 and using a file geodatabase feature class. I have a field called facility_id. I have tried using this field as a string field or as an integer ...
0
votes
1answer
43 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 ...
0
votes
1answer
30 views

What are row.Object and row.Text in Arcpy?

I'm trying to understand an arcpy script and I'm stuck with the following lines: cur = arcpy.SearchCursor(Tabelle) row = cur.next() while row: text1 = row.Objekt text2 = row.Text As far as ...
-1
votes
1answer
30 views

Using Field Calculator for subtracting values with same ID in ArcPy? [closed]

I have a line shapefile that used for some calculation. One of the calculation is subtracting values with a same group ID. The shapefile has a filed called LineID that consists of 2 lines with Side 1 ...
1
vote
1answer
35 views

ArcPy updating fields from another table

I'm trying to update missing values in one .shp from another .shp. I'm using SelectLayerByLocation to identify the properties which lie within the boundaries of a suburb and then using a UpdateCursor ...
0
votes
1answer
33 views

ArcPy Update Cursor Not Populating Field?

I recognize similar questions have been asked but I have yet to see what my code is lacking in any of their answers. I am trying to use the code below to periodically update attributes in a Feature ...
1
vote
0answers
52 views

Making ArcPy script quicker? [closed]

The script below is used to update a shp which is missing values from another .shp using a spatial reference. It's taking about 19 minutes to run through ~53,000 rows. Any ideas on how I can make it ...
1
vote
1answer
21 views

Extracting field value from Info table( .info ) in ArcGIS

I am working on a Python snippet try to use arcpy.da.SearchCursor() to extract value of certain field from a Info Table which generated by executing arcpy.Statistics_analysis().Here's my code: arcpy....
0
votes
1answer
76 views

Taking data from a CSV file to create points on a shapefile [closed]

I am trying to import data from a CSV file and write a script that will generate points on a new shapefile. I am running into issues for when I try to update the InsertCursor. I get an error of "not ...
0
votes
1answer
24 views

UpdateCursor giving ValueError: need more than 1 value to unpack?

I am writing a script assigning the ADMINAREA value to the empty LOCALITY fields from TWB_Suburbs to TWB_Property layer. I am getting: ValueError: need more than 1 value to unpack Is anyone able ...
1
vote
1answer
26 views

Using Update Cursor to categorize crash ratios? [closed]

I'm new to coding and I need to somehow use an Update Cursor that I can convert the rates of crashes in a block group into 3 separate categories. The crash rate is the difference between the number ...
0
votes
1answer
71 views

Parsing CSV data and updating a dictionary and creating a polyline

I am a little stuck on my code. I am new to Python and am learning as I go, but have usually been able to figure it out till now. The code was working up till I put the dictionary part in and now ...
2
votes
1answer
40 views

Checking field is empty and then adding new row with zeros?

I created a table with three fields but there are no values in these fields. Here is the screenshot of these fields. I want to add a new row with zeros for all these three fields. Here is my code. ...
1
vote
0answers
61 views

Accessing additional CAD annotation fields

I'm trying to read certain values from the annotation layer of a CAD file (MicroStation.dgn). It seems like for certain entities (Cell) the text isn't stored in the field 'TxtMemo' or 'Text'. When I ...
0
votes
0answers
30 views

Compare Specific Points of Line Features in two Feature Classes using FeatureClassToNumPyArray

I am looking to compare the first and last point between features in two different feature classes. The features share a common ID. My thought was to create two arrays via FeatureClassToNumPyArray. ...
6
votes
1answer
89 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 ...
1
vote
2answers
73 views

Search Cursor to apply summarize statistics to all the row in a column

I use the following logic in ModelBuilder to get a result as seen below: A feature class has a Column with the name "Value" which is passed through to the Summary Statistics Tools which calculates ...
0
votes
2answers
183 views

Switching from Nested Search Cursors to Dictionaries

I'm working with a table that has in excess of 800K records and my method of using nested cursors is not practical. I've been reading and it looks like I should switch to dictionaries, but after much ...
0
votes
2answers
58 views

Using cursor.next() is resetting “row in cursor” causing it to skip every other row

I'm trying to update a column based on the value in the next row, but cursor.next() is giving unexpected behavior. When I identify the next_row using cursor.next(), it is resetting my row in cursor! ...
1
vote
1answer
82 views

Add point to shapefile / “IndexError: tuple index out of range”

I'm trying to add to a shapefile a point that is a (x-y) distance away from another point (city). None of the cities in the shapefile have x-y coordinates in the attribute table; I've added them for ...
-1
votes
1answer
20 views

Insert a point into feature class based on another point [arcpy] [closed]

My assignment is to insert (using insertCursor) a new city at 0.02 decimal degrees east and 0.03 decimal degrees south of another city. The cities shapfile did not originally have x-y coordinate ...