Questions tagged [cursor]
Cursors are used by database programmers to process individual rows returned by database system queries.
1,039
questions
0
votes
2
answers
47
views
Selecting records after using insert cursor
Using ArcPy and on the same script, I would like to perform a SelectLayerByAttribute tool to select the features created with the InsertCursor tool.
coords = [1, 2, 3, 4]
pointlyr = 'point'
Sr = ...
0
votes
1
answer
35
views
Search cursor skipping every other row
I am trying accomplish something which should be fairly straight forward. I am trying to merge snowfall events within 4 hours into a single event so. The end of the entire event, and the name of the ...
1
vote
1
answer
44
views
for loop with a cursor only iterating once [closed]
I am running a search cursor with the code below (part of it) and my code is only yielding the first iteration. There isn't any selection on the FC prior.
Why is it stopping at the first iteration?
...
1
vote
1
answer
35
views
Select points by polygon and update attribute field
For each record in the pointLayer, I'm trying to see where they are located using the polygonLayer. Then, update this location information to the "SWPsubwatersheds" field from the pointLayer ...
0
votes
1
answer
72
views
Calculating SUM of multiple fields into new field using ArcPy
I have 4 fields (STREAMS, SLOPE_ASPECT, FIRES, TREES) that are assigned either a 1 or a 0 based on whether they exist or not.
The goal: Create a new field "ranking" the best locations (...
0
votes
1
answer
39
views
arcpy.da.UpdateCursor() on field values in rows that meet "where_clause"
I'm looking to copy the values from the "Layer" field to the "COMMENTS" field... then change the string value in the "Layer" field to "Fiber Cable". The feature ...
0
votes
2
answers
80
views
Only want to updated first 26 records in a table using UpdateCursor
I'm trying to updated values for records in an attribute table. All records have a quadrant number (in field "Quadrant") and a random integer (in field "RandomSeg") assigned to ...
0
votes
0
answers
53
views
Update field using dictionary and list
I have two layers, layer A and layer B. I need to update the SC field on layerA from layerB SC_1 field. I have the following that does a spatial join, then use a Distinct list to populate the SC_1 ...
0
votes
0
answers
78
views
Getting assettype and assetgroup field values from feature class with domain using ArcPy
I am trying to get the field values of assettype and assetgroup from a feature class but I am not able to get the values there are subtypes assigned to those fields and also values are domain coded ...
1
vote
1
answer
47
views
Python-code "max value among fields and print field name" working in ArcGIS Pro command line, not in script-tool
I tried this code in ArcGIS Pro.
I am getting the code to work great in command line. However, trying to script a tool out it in ArcGIS Pro.
Getting an error:
File "", line 13, in ...
1
vote
1
answer
91
views
TypeError: cannot update branch versioned table
I have several editors making edits to a branch versioned, sde referenced layer on ArcGIS Portal. As part of the work flow, I want editors to open their ArcGIS Project saved with their edit version of ...
0
votes
0
answers
95
views
How use multiprocessing with function arcpy.da.InsertCursor
I'm working with a table in the database that has more than 1 million records and a total load of this table takes about 8 hours because it has geographic data, the table is a featureclass. Basically, ...
2
votes
1
answer
67
views
How can I loop through features in layers to create an individual geodesic viewshed raster for each feature?
What I have:
1/3 Arc Second DEM for the extent of my AOI
Feature class containing ~16 observers with fields for 'observer_offset,' 'outer_radius,' 'horizontal start angle,' and 'horizontal end angle'
...
0
votes
1
answer
39
views
arcpy.SearchCursor and unexpected results
I'm stuck on results that arcpy.SearchCursor is outputting. I'm accessing a table on a database connection. When I run this, it crashes with an error:
argument of type 'Row' is not iterable
I ended up ...
2
votes
1
answer
60
views
Shapefile not Z-enabled although the environment is Z-enabled in ArcPy
My attempt is to view raster values in the command window. The follwing code is thought to do this by converting the raster to a point feature file and by successively scanning the values at the ...
2
votes
2
answers
74
views
Update specific row based on string
I'm new to ArcPy. I am attempting to find the string 'Unknown' and update the 'Comments' field, that indicates which field contains the 'Unknown' string for that row. I was attempting to use ...
1
vote
1
answer
32
views
Calculating individual Sum of multiple fields
I am trying to calculate the sum in each field in my list:
Cost_Adders = ["RR_CROSSING", "INTERSTATE", "RIVER"]
for Cost in Cost_Adders:
where = f"Cost_Adders = {...
2
votes
1
answer
97
views
Changing value of layer attribute based on geometrical conditions of line elements through ArcPy in ArcGIS Pro
I have a feature class layer that comprise of line elements. For my purpose, I needed the start and end point coordinates of each line, so I added new columns with add field and use calculate geometry ...
0
votes
0
answers
36
views
Retrieving range of values in feature class in ArcGIS Pro using ArcPy [duplicate]
I wanted to access the range of values in an attribute of my feature class data in ArcGIS Pro using Python code. I used below syntax but I got the error message:
'int' object is not iterable
The ...
1
vote
0
answers
25
views
Calculate distanceTo between points consecutively and use an update cursor to fill in a new field in an attribute tablea
I have a shapefile that I need to update with the distance between its points in the order they appear in the attribute table. I've been instructed to do this by using an Update Cursor and the ...
0
votes
1
answer
34
views
How to extract field values from one layer, add them together, and insert them into a field in a nearby layer? [closed]
I'm working with two different point layers (layer1 and layer2). Layer1 will have a field (field1) that contains four possible values (a, b, c, d) and another field (field2) that contains a given ...
0
votes
1
answer
86
views
Find duplicates and merge attributes arcpy
I have a point shapefile which has duplicate points based on an "ID".
ID1 + permit1 + resources associated to permit
ID1 + permit2 + resources associated to permit
ID2 + permit1 + resources ...
1
vote
0
answers
101
views
arcpy.da.SearchCursor is skipping rows when selection is "large" [closed]
In ArcMap 10.6.1 I have a script Python (2.7.14) in a simple ArcToolbox that uses an arcpy.da.SearchCursor to iterate through the selected point features (poles) to produce an Excel report. The cursor ...
1
vote
0
answers
57
views
Flip line only on selected rows with arcpy.da.UpdateCursor and calculate new line bearing on it
I'm trying to use arcpy.da.UpdateCursor to flip line only on selected records in shapefile that are greater than value 180. Then I would like to recalculate Line Bearing on the attribute called "...
1
vote
1
answer
80
views
Flipping line that touches certain points using ArcPy
I have a layer of points and a layer of lines (shapefiles), that have been split so the lines have 2 vertices.
I would require to change the direction of those lines (flip), only if they touch (...
0
votes
1
answer
71
views
Using Search/Update cursors to find the max value in a field and replace negative numbers in same field with max value + 1
I am a bit rusty with Python, I know conceptually what I need to do but am not sure of the syntax/formatting.
The table I'm working with has an id field with negative and positive values and null ...
0
votes
1
answer
84
views
Using Python dictionary to update street type in another field in ArcGIS Pro
I am using a dictionary to update street type in another field in ArcGIS Pro 3.0.3
I am a novice python user and I am having problems updating a string field with a dictionary.
I am joining ...
0
votes
1
answer
382
views
Use arcpy.da.UpdateCursor in ArcGIS Pro to update a field with a NULL value
I would like to search a specific field within an attribute table in ArcGIS Pro using ArcPy and find all the null values and change the null value to the value above it. For example:
ID | field1 | ...
0
votes
0
answers
135
views
Edit attribute tables with another table in ArcGIS Pro using ArcPy
I have two tables and I need to update one based on the other. For this, I need to take two columns (idscap and spardcode) as the initial reference value and thus modify all the columns of the table.
...
0
votes
1
answer
69
views
ArcPy SearchCursor : AddMessage with field value
I'm trying to get a message in ArcMap dialox box showing the features IDs that have null value in attributes X, Y, or Z.
myFeatureClass
ID_FIELD
X
Y
Z
101
140160
350350
450
102
140165
350348
103
...
2
votes
1
answer
96
views
Adding geometry to a db table using ArcPy from an existing points dataset
I am attempting to write an ArcPy script to add the geometries of a points data set to records in a db table. Each record in the db table has a field containing a date, and an associated numeric value ...
1
vote
2
answers
388
views
Update cursor not working but with no errors
I want my code to find the maximum value of a field from attribute table and return that as a the value for another field in another attribute table, trying to do this with search cursors and update ...
0
votes
1
answer
129
views
Updating 3 million rows in file geodatabase
I have a GDB which has 3 million annotation data, then I would like to modify some filed values based on csv table
I'm using the following ArcPy scripts now, but it's too slow
import arcpy
import ...
1
vote
1
answer
129
views
Creating shapefile from text file using ArcPy
Fourth update, per suggestions from comments and professor. Still getting the "takes no arguments" error "Traceback (most recent call last):
File "C:\Pythonpro\pythonProject2\...
0
votes
1
answer
52
views
Looking for PyQGIS equivalent of ArcPy "SearchCursor" class [closed]
How can I consult and use shapefile attributes without reflections on the map? Like a 'Search Cursor object' from ArcObjects. Also using a query expression to filter data.
0
votes
2
answers
124
views
Inserting geometry objects into existing layers with ArcPy
I'm trying to add new features to a layer based on geometries created from a list of WKTs. The code I have so far:
Creates a polygon layer and sets the projection (NAD83)
Creates a geometry object (...
0
votes
0
answers
23
views
how to compare all the fields of two feature class with 0 in one file and null value in another file and change it to the same value as of first file
need to search the inputpolygon and checkpolygon and update the value to check polygon
with arcpy.da.SearchCursor(Inputpolygon,['market', 'type', 'latitude','postalCode'])as Cursorop:
with arcpy.da....
1
vote
1
answer
124
views
Copy geometry only from one feature class to another based on condition
I'm trying to use ArcPy to copy only the geometry from one feature class to another based on a certain condition. Here is my code so far:
source_fields = ['contition_field', 'SHAPE@']
icursor = arcpy....
0
votes
1
answer
200
views
Expected field not found using SearchCursor and SelectLayerByAttribute tools in ArcPy ArcGIS Pro 3.0.0
ArcGIS Pro 3.0.0 - using ArcPy
First, I'm very new to coding with Python, so there may be a few mistakes in my code that I am not catching. I'm trying to select each row in a table (line feature class)...
1
vote
2
answers
58
views
Using row.setValue in ArcPy with ArcMap [closed]
This is my code:
#-*- coding: utf-8 -*-
# Import system modules
import arcpy
import pandas as pd
### ROTINA MÁQUINA INTERNA PERIODICIDADE: 1 DIA ###
print ('Script Rotina da Maquina Interna - ...
1
vote
0
answers
35
views
Updating a field values based off of values in the same column
I am struggling with the concept of this code and am not sure if this is even something I can do.
I am using a gdb with a feature dataset and a number of feature classes. I have a feature class "...
0
votes
2
answers
49
views
Deleting geometries in feature layer based on unique field values
I have a building feature layer for a county. Some parcels have more than one building, so the buildings in these parcels all have the same TMS number in the "TMS" field. I only want my ...
1
vote
0
answers
90
views
Cursor script runs but not updating value
I have a script I wrote to use an update cursor to change any records in a feature class that has a field set to 'N' to 'Y'(coded domain values). I have ensured that the database connection file is in ...
2
votes
0
answers
76
views
QGIS 3.22.10: problems with cursor, while writing a filter
I just remarked a problem in QGIS 3.22, I never had before. When I write a filter for a layer, then the cursor is several millimeters right of the place where I write. This makes it difficult to write ...
-2
votes
1
answer
85
views
Time difference between two string fields with microsecond (or seconds) resolution using, Arcpy, datatime and UpdateCursor
I am trying to calculate (using Arcpy) the time difference between two fields that are in string data type and they have the following time format "YYY-MM-DD HH:mm:SS.sss"
I have achieved ...
1
vote
3
answers
135
views
Auto Incrementing ID based on repetitive sequential ID and conditional parameter (ID based on two fields - arcpy) - Update Cursor
I am currently trying to generate an ID based on two conditions but I am having troubles to achieve that since I am failing to make my script work. Below the explanation and my code, I apologies if ...
1
vote
2
answers
268
views
How to use ArcPy SearchCursor, with a where clause, to return string formatted response with values
I am using an ArcPy Search Cursor to return the rows of a specified field within a shapefile.
The for loop iterates through the feature class and returns the value of the rows in a formatted string as ...
0
votes
0
answers
335
views
Using Search Cursor results to Select Features by Attributes
I've been working on automating the workflow with Python for a product that I create on a weekly basis. Where I'm stuck now is I have a filtered point file which I want to use its attributes to filter ...
1
vote
2
answers
510
views
ArcGIS Pro Field Calculator: Updating each row with a minute added to previous time
I'm trying to update each row in my point shapefile with a date. What I want is the first row in my below table to read 7/14/2022 12:00:00 AM, second row to be 7/14/2022 12:01:00 AM, third row to be 7/...
0
votes
0
answers
55
views
SearchCursor is outside tuple range despite having multiple fields in the parameter
In the below script, I get an error on line that starts with insertRow that says IndexError: tuple index out of range.
outputLocation = arcpy.GetParameterAsText(0)
nullPntFc = arcpy.GetParameterAsText(...