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
26 views

Shortening use of If statements with ArcPy [closed]

New python user here I was wanting to know if what a better way to condense this update cursor script that I'm trying to write. database = 'C:\M2_Q3.gdb\data' attributes = ['S_0__FT_', 'S_1__FT_', '...
0
votes
0answers
49 views

Writing multiple array expression using Python Parser and ArcPy cursor in ArcMap Field Calculator [closed]

What I need is when the SiteID_Species array has an occurrence > 1 then I would like to see if the last two Estimated_Area values have been Zero. If only the last two Estimated_Area values have been ...
1
vote
1answer
57 views

Arcpy RuntimeError: An invalid SQL Statement on UpdateCursor

I'm trying to populate a field based on the values of another field. CalculateField was buggy, so I switched to da.UpdateCursor. This initially worked when I ran it as part of a script tool on ArcGIS ...
2
votes
2answers
71 views

UpdateCursor for field calculation based on unique values

UPDATE TO PREVIOUS QUESTION: I have an address feature class. I want to use an UpdateCursor that focuses on two fields: StreetName and Block_ID. For every instance of a unique StreetName, I want the ...
0
votes
1answer
37 views

Calculate Field - Why does the field populate with the same number, but prints correclty?

Why does the field populate with the same number, but prints correclty? import arcpy import rivers arcpy.env.overwriteOutput = True arcpy.env.workspace = r"C:\Data" import math def sinuosity(shape): ...
2
votes
1answer
25 views

Extracting Summary Statistics value with cursor and assigning it to a variable

I am writing a script (to be used in ArcGIS 10.7.1) that uses a Zonal Statistics tool to create an average of a raster that is beneath a grid. I then use the Summary Statistics tool to take the ...
1
vote
1answer
30 views

Framing argument for insert cursor when writing geometries using ArcPy?

I am writing polygon geometries and I have points holding the geometries that represent vertices of the polygon. When I run the code below I get: TypeError: sequence size must match size of the ...
1
vote
1answer
45 views

Improving ArcPy script for ArcMap to only return rows of selected polygons instead of all polygons in layer

I am debugging a code provided to me that merges two polygons and alters the fields of "FID1' and "CALC_AREA." I have realized that the current code searches every layer in the map document for ...
0
votes
1answer
27 views

Adding current row in arcpy.SearchCursor to selection

I want to make a code that select all unique values of a field in a attribute table. However, while everything in the code apparently works, I don't know how to add the current row in the Search ...
1
vote
0answers
42 views

Using script parameter validation in ArcPy

I am developing a script to Add, Delete, and Update rows within a table. The script basic function works well using InsertCursor and UpdateCursor. My questions or troubles come when I attempt to use ...
1
vote
1answer
28 views

ArcPy Insert Cursor giving RuntimeError: Error in InsertRow

When I run the code snippet below, to create a test table, add a field to it, and populate that field with a value in its first row, I get an error: Traceback (most recent call last): File "C:\Temp\...
0
votes
1answer
38 views

Creating dictionary of link and its adjacent links (having common vertex) in ArcPy

How do I create a dictionary that has the linkID of a link as key and linkID of touching links as values? I have used this code in ArcPy but it takes a very long time. arcpy.CopyFeatures_management(...
2
votes
2answers
38 views

Does ArcPy (Standalone) have option like Spatial filter?

I want to get the polyline features intersecting with a polygon geometry and having a particular field values in ArcPy standalone script. There is another link for similar subject but it is not for ...
1
vote
2answers
30 views

ArcPy update a field based on the value of another field containing wildcard text

I have a file geodatabase feature class (fc). I want to update Field 1 (Colour) with text where Field 2 (Description) contains a certain word. ie. Field 2 contains the string 'the ball is red and ...
1
vote
2answers
68 views

Looping through all rows in single column and altering string values of each element in shapefile using ArcPy

I have a shapefile with an attribute table that partially looks like this: Row | Shape | Date 0 | Poly | 05-Sep-10 16:12:00 1 | Poly | 06-Sep-10 17:23:01 Is there a simple method that I can ...
0
votes
1answer
38 views

Field not updating correctly by updatecursor() method

in my work, I have to find the features having duplicate values of field "ID" and leave just one identical value by updating blank values in rest of the features. My code for an add-in is: import ...
6
votes
1answer
137 views

ArcPy UpdateCursor auto pausing after every 1000 records

I have an update cursor running that updates a field based on a lookup table (Python dictionary). The cursor completes fine, but seems to pause and hold after each 1000 records - I have a test in it ...
0
votes
1answer
38 views

Checking feature overlap using ArcPy cursors

I have a set of geometries that I want to check whether they touch another geometry. I have created a tuple "tiffs" where I want position 0 when touches is true. tif[0] and tif1 are strings. The ...
0
votes
1answer
38 views

Slicing all values in field using arcpy.da.UpdateCursor

I have a folder with a (3) shapefiles. Each shp. has a field titled "country" with a country name. I've already set my desired workspace correctly and everything else in my script works for what I ...
1
vote
0answers
22 views

My UpdateCursor is not working. The attribute table of my new shapefile is not updating [closed]

I am new to arcpy. I am trying to do a few things with a shapefile. First I created a new shapefile with specific dataset that I wanted to work on. So far everything works until the UpdateCursor. When ...
0
votes
3answers
51 views

How to access/manipulate a feature class/dataset in a personal database by using cursor via ArcPy?

I wrote an ArcPy script which uses cursors and it works fine with shapefiles. However, it does not work if I execute the same thing in a personal geodatabase. Should I use different format for a ...
2
votes
2answers
87 views

Add Excel-style row_number and column_name attributes to a Grid Index in ArcGIS [closed]

After using the Grid Index Feature tool it creates a grid polygon layer. The resulting feature class contains a field called [PageName], which displays like A1, A2, A3...etc in each row starting from ...
0
votes
1answer
56 views

For loop with SearchCursor stops after first iteration

I'm trying to iteratively select and export a layer using da.SearchCursor, but the loop stops after the first iteration. Here is the code: arcpy.env.workspace = ScratchGDB # infc= "PA" field = '...
0
votes
2answers
28 views

Update row based on order of parameter

I'm trying to add a field to a created feature class, then create a key based on whether the AccountNo is equal to the imputed Feature1 through 6. For example, if Feature1 is equal to the AccountNo ...
0
votes
1answer
25 views

UpdateCursor not deleting Null row

I am trying to change a title based on a feature class named Subject. They are parcel addresses, and the StrUnit field is the unit number. The issue is, not all of the parcels are apartments, so when ...
0
votes
1answer
97 views

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

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 ...
1
vote
1answer
126 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
2answers
39 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
86 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),...
1
vote
2answers
80 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
1answer
43 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
59 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
57 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
44 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
48 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
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 ...
-1
votes
2answers
64 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
57 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
55 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
73 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
67 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
145 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
54 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
41 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
52 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
50 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
50 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
40 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 ...