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

Select By Location and Calculate Field in ArcPy

I have a point shapefile and a polygon shapefile and want to set the field "Present" to 1 if it intersects with the polygon in ArcPy, but I am having trouble with the SQL syntax for select ...
0
votes
1answer
43 views

UpdateCursor by unique values from another Field

I am trying to update a field in an attribute table in a feature Layer with arcpy.da.UpdateCursor. I am running the Python script as part of a model in ArcGIS 10.6. But I am lacking some of the basic ...
0
votes
0answers
41 views

Constructing SQL statement for ArcPy SearchCursor

I'm struggling with a real simple cursor problem, and I figure it's probably a syntax issue. But I cannot see what it is. tmpHeader = ['OID@', 'SHAPE@', 'ProjectID','Status','ProjectName','Description'...
1
vote
2answers
92 views

Extracting values of some columns with ArcPy

I've been trying to run some code to extract the values from a column and random sample some of them. The problem is when I try to append values from the cursor to a list. When I append values to the ...
0
votes
1answer
52 views

Python 2.7 stand alone script for compounded with statement. Errors 'column specified does not exist - but it does

I'm writing a standalone Python script to use for labeling ArcMap 10.7 data. (Want to avoid label expressions for portability, etc). I'm attempting to use ID attribute to label based on ADMIN_ORG ...
0
votes
0answers
27 views

Python Calculate Rank in Field Esri

Does anyone know how to calculate the "rank" of a field but within 1-100? For example i have a field called "ValSumBasin" with all these values. I am wanting to rank these values from 1-100. I can ...
0
votes
1answer
38 views

Calculating sum per id using UpdateCursor of ArcPy

I am trying to calculate the SUM value for (VD_SUM) Based on Basin ID and output in the field "VD_SUM_SUM". I am not sure how to write the SUM part at the end. This is what I have so far. import ...
0
votes
1answer
25 views

Insert large list of fields and values into feature class

I want to create a toolbox I have a list of point coordinates, that define a polygon and a list of attributes, that each polygon has. points_list = [(323917.71, 479699.45), (323923.36, 479699.74), (...
0
votes
1answer
24 views

Trouble with syntax of preselection in a cursor

I am trying to determine the maximum values in a column [1] in relation to a column [2]. For this purpose I have written all occurring values of column [2] in a list and now I want to make a selection ...
2
votes
1answer
24 views

StopIteration: iteration not started

I'm trying to update a given field in this case the last one of the table by concatenating all values in the row excepting null values or '' values. So far when execute the code until line: print (...
1
vote
1answer
29 views

Invalid Syntax on Update Cursor update

I'm using a dictionary created by a search cursor from one feature class to update another feature class with an update cursor. I'm getting an invalid syntax error for the cursor.updateRow(row) and.....
2
votes
1answer
70 views

Checking Points within polygon and assigning value using ArcPy

How can I write arcpy code to determine if the points of a point feature class are inside polygons of a polygon feature class and write the result (true/false) to the point FC's attribute field? I ...
1
vote
2answers
42 views

Using arcpy search cursor to relate a .csv and a .shp?

I'm trying to write a script that relates data from a .csv file to a utility pole shape file. Basically, we want the script to iterate through the pole # fields in each table and determine which pole ...
0
votes
0answers
54 views

Iterating through an Index Layer using arcpy ArcGIS Pro

I have one layout and 2 map frames with an index layer. I want to create a map series where frame 1 iterates the odd numbered pages and frame 2 iterates the even numbered pages so it will look like ...
1
vote
1answer
54 views

Using two map frames on one layout in ArcGIS Pro with ArcPy

I want to create a map series that exports two different sheets on one page. For example Page 1 would have sheet 1 & 2 and Page 2 would have sheet 3 & 4. I used to do this with python in ...
1
vote
0answers
16 views

Add Join Management and UpdateCursor in Arcpy

How to join multiple table with shapefile, update cursor specific field of the table in shapefile table and remove the join table? I write some script but it not work, please correct my script. ...
0
votes
1answer
57 views

Making ArcPy code run faster

I have an ArcPy code that I am using to find various characteristics about certain watersheds in Indiana. I start with a shapefile of all 800 watersheds and go through it row by row and perform a ...
0
votes
0answers
22 views

expression for “SelectLayerByAttribute_management” with value of a cursor

I am currently struggling with the correct syntax for a SelectLayerByAttribute_management query, which is created iteratively by a cursor. I want to intersect each municipality from a polygon file ...
0
votes
0answers
29 views

arcpy.da.UpdateCursor with SQL query

I am having issues with my SQL query in the arcpy.da.UpdateCursor(). The code seems to work fine if I remove the SQL query so I am fairly certain that it is the issue. The syntax that I would use in ...
0
votes
0answers
48 views

“IndexError: list index out of range” when trying to add coordinates to an array

I am trying to reconstruct a car's path from some GPS coordinates given in a CSV file. I created an empty array to add the X and Y values (lat, long) and create the lines using it but I am getting an ...
0
votes
0answers
48 views

Use arcpy.da.SearchCursor to iterate through values and count unique values in a Dictionary

I created a dictionary called Zip_Dict_Int and it contains file path strings as keys and zip code integers as values. The zip codes have been reduced to only the first number in the zip code. Below ...
2
votes
1answer
32 views

Joining one field from multiple feature classes to another feature class

I've got 19 feature classes, with a single field in each one that I am interested in. I want to pull that field from each one (index 63 on each feature class), and join those fields to a single ...
1
vote
1answer
37 views

Using row.setValue with arcpy.da.UpdateCursor gives 'int' object has no attribute 'setValue'

I am adding a new field to my attribute table, and trying to populate it with a a section that is already in the attribute table but converted to km instead of inches. My code does not work with ...
1
vote
1answer
39 views

Update Cursor running for 4 hours

I am trying to update one field with values as multiples of five till the maximum for the value in the gridcode. The field I am trying to populate is called Time_min. As I am very new to python, am ...
1
vote
1answer
45 views

How to create 3D parallel lines with Z coordinates as same as Original 3D polyline using Arcpy?

I want to calculate cut/fill cost for road alignments. For this reason i need to create a buffer-like polygon from given road centre-line but this polygon has to have Z-values that are taken from ...
1
vote
1answer
40 views

Insert cursor in ArcPy not inserting

I'm writing a program to count the number of times a polyline self-intersects. I create a new feature class to keep track of the line and the number of intersections. The feature class is created ...
0
votes
1answer
53 views

Using “IN” within where clause of arcpy.MakeFeatureLayer_management

I am using ArcGIS Pro 2.4.0, with Python 3.6.8. I found the following similar posts but could not figure out how to apply them: Using Python Search Cursor results to Select Features by Attributes and ...
1
vote
1answer
30 views

Using a dictionary to find unique values from one field, populate second field with consecutive integers [duplicate]

I have an attribute table with three fields: Id, Name, and Id_2 and 18,701 records. I would like to populate Id_2 with consecutive integers for each unique value in the Name field. Prior to running ...
0
votes
0answers
47 views

Selecting intersecting elements that have same value in another attribute and merging them into one using ArcPy

I have a polyline shapefile "rivers" containing three columns: [Start, End, Meas] [1, 2, 3] [2, 3, 3] [2, 4, 2] [4, 5, 3] [5, 6, 3] What I want to do is ...
0
votes
3answers
29 views

How to use range value in UpdateCursor in ArcMap

I am trying to add range value in attribute tables by using UpdateCursor module of data access (da). import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") lyr = arcpy.mapping.ListLayers(mxd)[0] sql ...
3
votes
1answer
74 views

Insert Cursor Having an Issue With Reading the Syntax of a List

In my code below, how do I get the Desired Output? # Get a list of all 'SITE_NFID' in the dashboard_site_summary table that don't have a match in the nfid_fqn_associations table ...
0
votes
1answer
53 views

ERROR 000732: Layer Name or Table View: Dataset targetAreas does not exist or is not supported Failed to execute (SelectLayerByAttribute)

My goal with this script is to create 9 PDFs and 9 sheets within an Excel workbook. The script utilizes select by location, attributes, and searchcursors to read data to Excel and iterate through user ...
4
votes
2answers
83 views

ArcPy UpdateCursor and Dictionary

I want to update the 'Start_End' field in the following shapefile attribute table: The attribute table consists of 6,134 records. For every unique value in the 'Id' field, I'd like to update each '...
1
vote
1answer
31 views

Populate field based on value within a field in another table [closed]

I have two datasets: dat_1 and dat_2. I would like to populate field_1 in dat_1 based on values within field_1 in dat_2. I don't know if i need it, but they have ogr_ID field in common, with the same ...
2
votes
2answers
56 views

Getting top 1 record from shapefile by descending order using ArcPy SearchCursor

I have a shapefile from the date field in it. I'm looking to get top 1 record date value by descending order. readRows = arcpy.SearchCursor(shapefile, "", "", "Last_Updated" ,"Descending") Is ...
0
votes
0answers
29 views

Using search cursors with SQL in Python

I'm trying to create a search cursor that will list the cities in which the population is greater than 1,000,000. I was able to create a list of the cities and their populations, but unsure of the ...
2
votes
1answer
89 views

RunTimeError w/ for row in cursor

Every time I execute this, I get a runtime error pointing to my "for row in cursor," stating that A column was specified that does not exist. Any ideas how to fix this? import arcpy import os gdb = ...
0
votes
0answers
93 views

Getting “Workspace Already in Transaction Mode” Error when trying to use updateCursor on versioned sde

There are are numerous post on this error, but I can't seem to find a solution for myself. We have a versioned sde and need to add new fields to some of our feature classes and populate them with an ...
1
vote
1answer
34 views

Update field based on values in other fields using search and update cursors

I'm a Python beginner, I'm doing a risk analysis with a point feature, and I'm trying to write a script that allow me to update a field (proximity) based on different numeric values within different ...
2
votes
1answer
81 views

Compare multiple fields using SearchCursor dictionary and UpdateCursor

I have two feature classes. I need to transfer attributes from a point feature class to a line feature class based on a combination of fields. They do not have matching field names. Here is an example ...
2
votes
1answer
58 views

Using arcpy.da.UpdateCursor to populate field with dictionary values

I want to populate a field, named FnotExist, with values from a dictionary. I want to check if the key of the dictionary matches the row value in field FI_PATH and if it does populate the ...
2
votes
0answers
26 views

Transforming descriptive CSV data to known locations in GIS using Python

I have to transfer CSV data that describes a FROM and TO segment into spatial data. The segment descriptions do not follow any logical convention, but rather describe road junctions, places, or road ...
0
votes
0answers
51 views

Compare multiple lists of field names thought to be in shapefile with multiple list of fields found in shapefile

In the code below, I am able to create and print multiple lists that contain field names for each shapefile. This is done by creating a list of file paths, pointing to a shapefile, and looping through ...
2
votes
1answer
41 views

Applying sorted sequential numbers to only certain features using ArcPy [duplicate]

I would like to take sequential numbers up a level and only apply it to features of a certain type. Say I have two feature types, black and white features, and it's denoted by the field "Type". I want ...
4
votes
2answers
364 views

Filling dictionary with list of row attributes using arcpy.SearchCursor

I have a dBase database file and I'm viewing and editing the table in ArcGIS Pro. I want to use the arcpy.da.SearchCursor function to fill a dictionary and create a key-value pair by iterating ...
1
vote
1answer
79 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 ...
3
votes
2answers
92 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
39 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
28 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
34 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
2 3 4 5
18