All Questions
Tagged with insertcursor or cursor
1,050 questions
4
votes
2
answers
404
views
Create points with attributes from Cursor
I have a table imported from Excel that has three attribute columns (City, State, ZIP) as well as X/Y columns that have been added.
I have a cursor that goes through the records in the table and ...
4
votes
1
answer
5k
views
Insert Geometry and update attribute using arcpy.da.InsertCursor
I'm trying to insert geometries from one feature class into another and then update an attribute associated with the geometry. Only inserting the geometry works fine, but I can't work out how to ...
4
votes
1
answer
547
views
Error when updating arcpy.SearchCursor to arcpy.da.SearchCursor
I'm trying to update a python script to use the arcpy.da.SearchCursor instead of the legacy arcpy.SearchCursor. The cursor searches for duplicate values in a field.
I am getting an error:
...
4
votes
1
answer
106
views
Update row with next row's value
I am trying to extract the endpoint of a line with very fine scale and overlapping GPS data. I would normally just use the locn_id+1 but that doesn't work because the data were originally rarified. ...
4
votes
1
answer
3k
views
Do I need to set arcpy.env.workspace at the beginning of my python code?
I am new to Arcpy and have been doing simple tasks such as AddField_management and updateCursor. However I have been getting error msgs, such as errors 99999 etc. The errors I get are related to ...
4
votes
1
answer
2k
views
Find max and min values from a table based on two fields
I have a geodatabase table with the following fields: County_Name, State_Name, Date_Time, Customers
Example
Alameda, CA, 8/1/2014 12AM, 6
Alameda, CA, 8/1/2014 1AM, 1
Alameda, CA, 8/1/2014 2AM, ...
4
votes
2
answers
4k
views
How to use InsertCursor to add points to a point feature class?
I am struggling with a very simple task of inserting "SHAPE@XY" into a point feature class.
Following is what I have:
xy = [(361087.15436001675, 198747.07296730898), (361530.56426259346, 198976....
4
votes
1
answer
957
views
How to search on values of a value list in python toolbox?
I developed a simple python toolbox that lists values of a table in the value table parameter. The user can rank each row using the Rank field drop down values.Everything is ok untill user selected ...
4
votes
2
answers
813
views
Arcpy Insert.da.Cursor - Issues writing polygon geometry
Currently building a tool that automates the creation of some polygons that we need done quarterly. Below is just a set script I am using that is giving me a similar issue when I try to run the ...
4
votes
1
answer
2k
views
How to extract certain values from a table using the SearchCursor Tool
I am trying to write a python script to extract certain values from a table: the table I am referring to is a big collection of nitrate values for different water depths, which are deposited in the ...
4
votes
1
answer
174
views
Getting count of like features types based on field attributes using ArcPy?
I'm trying to create an update cursor which will take the count of the number of like features in a field and then use that number in a random number generator. The field would look something like ...
4
votes
1
answer
1k
views
Requested operation is invalid on closed state using ArcSDE for Oracle?
I have a version on an Oracle SDE that I am working on using ArcMap / ArcPy 10.2.1.
I started an edit session and inserted a row in to a feature. Saved the edit and stopped editing.
I then tried ...
4
votes
1
answer
875
views
ArcPy script with cursors running slow?
I've got 2 polygons layers (no gaps): IDUs and crops. What I want is to identify the 3 largest crops by % area for each IDU. This seems common enough but I couldn't find a way to do it all using tools,...
4
votes
2
answers
2k
views
Field calculator or update cursor?
I have a feature class in which one field (let's call it "Field_A"), as yet empty, is to be populated by the contents of another field ("Field_B") multiplied by a certain number (I'll call it the "...
3
votes
2
answers
7k
views
Insert.da.Cursor, Error - Sequence size must match size of row
I'm working on this script which creates a table within a geodatabase. It then grabs the unique values from a list and attempts to insert them into the table using an Insert Cursor.
I get the Error
...
3
votes
3
answers
5k
views
SearchCursor() fails to read feature class?
I am very new to ArcPy and Python in general. I want write a script to read attribute table from a feature class and merge some data from a csv file into the table. Right now, I am just playing around ...
3
votes
2
answers
484
views
Calling specific row using ArcPy search/update cursors
When working with search and update cursors, how do I call upon a specific row?
In this example:
import arcpy, os
# I want to find a row where the FID is 10
# print value field in the row where FID ...
3
votes
2
answers
5k
views
How to set NULL value by arcpy.da.InsertCursor on date column?
How to set NULL value by arcpy.da.InsertCursor on date column?
I try insert "NULL", None, '', 0
dictIN= [{'field1':"test1",'date1':'01-02-2015','date2':''},\
{'field1':"test2",'date1':'01-02-2015','...
3
votes
3
answers
2k
views
How to create a copy of a feature class that is vertically and horizontally offset by a given distance?
I want to duplicate a polygon feature class and offset all of the polygons by about 10 feet in both the x and y directions. Is this possible to do using arcpy, or are there any geoprocessing tools ...
3
votes
2
answers
189
views
Using wildcard to find similar values between two fields with ArcPy cursor
I am using ArcMap 10.8. I have joined two street tables and am trying to correlate a couple fields. One field has a full street description ("FullStreet") and the other simply has the street ...
3
votes
2
answers
6k
views
Not Able to Pass Where Clause in SearchCursor in ArcPy
Can you please take a look at this snippet and let me know why I am not able to properly pass the Where Clause ('"[NAME_1]" = Ohio') in SearchCursor?
import arcpy
from arcpy import env
def ...
3
votes
2
answers
3k
views
Use updatcursor to replace values in multiple fields
I have spent a couple days digging through forums here, ESRI help and elsewhere and each variation of the codes I have tried has not worked. As best as I can tell this is due to my attempt to loop ...
3
votes
1
answer
2k
views
Arcpy Update Cursor (arcpy.da.UpdateCursor()) not saving changes to 'SHAPE@LENGTH'
Looked around and found other Cursor questions, but nothing dealing with updating 'SHAPE@LENGTH'. I am running ArcGIS 10.2.1 and have a multipoint shapefile that I am grouping into polygons based on a ...
3
votes
3
answers
884
views
Convert cursor output to list of geometries
I want to convert all the geometries returned by search cursor to a list.
import math
import arcpy
from arcpy import env
env.workspace = r"C:\GIS Data\GIS data_for Maeenul vai"
desc = arcpy....
3
votes
1
answer
157
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
...
3
votes
3
answers
2k
views
Comparing value with value from the next row
I have a table with two elements in this format:
a b b a b c c b c d ....f g g f
I have to analize if the second element is equal to the first element of the following row. If it's true, 1 is ...
3
votes
1
answer
3k
views
'TypeError: 'tuple' object does not support item assignment' when iterating through the rows of a layer
I'm trying to assign a value to the attributes of each feature of a feature layer. To do so I am just iterating through each row using 'arcpy.da.SearchCursor'.
#Import geoprocessing.
import arcpy
#...
3
votes
3
answers
666
views
How to count rows of interest from a field in an attribute table using arcpy.da.Cursor?
How to count the number of records from a field 'COVER' that is neither 'woods' and neither 'orchards'?
fileName = 'C:/gispy/data/ch17/parkCopy3.shp'
fields = ['COVER', 'FID']
count = 0 .
try:
...
3
votes
1
answer
3k
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?
3
votes
2
answers
314
views
Search for textbits in QGIS
Is there a way to search for only parts of text in QGIS.
Imagine I have a field in my attributetable called myField and I have several entries there, something like
This is awesome
Even more awesome
...
3
votes
2
answers
270
views
Update Cursor for automation of tedious data entry which keeps crashing ArcMap
I coded the Update Cursor for automation of tedious data entry where I am applying a previous Survey Company Identification Data to STRUCTURES_15096.shp from "OFFICIAL_STRUCTURES2015.shp" and it keeps ...
3
votes
1
answer
4k
views
arcpy.da.SearchCursor accessing only selected row in attribute table
In ArcMap 10.2, I'm attempting to build a tool that, when run, will iterate through a network of pipes to locate an outfall point. My network is composed of polyline data representing pipe, with input ...
3
votes
1
answer
615
views
Append List not working
Trying to create a list of well counts. In the code below, wellCntList only contains the current county count and not a list of ALL the counts. Sure I'm missing something simple.
for cname in ...
3
votes
2
answers
1k
views
Adding values in X column to list using ArcPy?
My apologies if this question has been asked before. I've spent some time searching for a similar question with no results.
Is it possible to add each value under X column to a list using ArcPy? I ...
3
votes
3
answers
4k
views
Changing cursor shape in PyQGIS
I noticed that PyQGIS has QgsMapToolPan() and QgsMapToolZoom() functions, and the cursor shape on the canvas will change to a hand (for pan), magnifying-glass(+/-) (for zoomIn / zoomOut).
I have a ...
3
votes
1
answer
9k
views
Python conditional on current and previous row?
I need to calculate a new field with a python conditional where some values only occur if a sequence in a separate attribute field (X) occurs.
For instance my data set looks like this. Y is the ...
3
votes
1
answer
639
views
arcpy.da.SearchCursor not work when run the whole scripts in IDLE
I'm using ArcGIS 10.3.1. The code is running in IDLE of winpython 2.7 64bit.
Here is a very simple code which intends to read a shapefile.
import arcpy
from arcpy import env
env.workplace = "E:/"
...
3
votes
2
answers
448
views
Identify duplicate attributes and keep value of earliest record
I have rows in a table that have duplicate ID values in one field. I would like to identify these duplicates, keep the ID value of the earliest entry, and null out the ID field for the other ...
3
votes
2
answers
13k
views
RuntimeError: A column was specified that does not exist
I have a script which reads a geodatabase table and calculate two fields based on existing fields.
This is my code:
import arcpy
from arcpy import env
#overwrite output
arcpy.env.overwriteOutput = ...
3
votes
2
answers
176
views
Using searchcursor and updatecursor
I'm am trying to use a searchcursor to identify a list of ID's from a dataset. Using the list, I am now trying to delete those rows with the same ID's in another dataset.
I'm not sure where I'm going ...
3
votes
1
answer
4k
views
Replace geometry of polygon feature using UpdateCursor and SHAPE@ token - arcpy
Within a Python script, I would like to replace the geometry of all features in Layer A with the geometry of features in Layer B if their ID fields match.
I am not sure how to do this, but the ...
3
votes
1
answer
361
views
Print rasters count in Python
I'm trying to print raster batch count number in PyScripter and ArcGIS 10.3
I'm using the next code:
import arcpy
carpeta = arcpy.env.workspace = r"C:\Base_de_datos\Cuencas_raster"
for raster in ...
3
votes
1
answer
973
views
Debugging TypeError: SearchCursor() got unexpected keyword argument in ArcPy script?
I tried to use SearchCursor(points, fields=fieldname) but I get this error:
TypeError: SearchCursor() got an unexpected keyword argument 'fields'
I'm not sure why this doesn't work.
# Local ...
3
votes
1
answer
266
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.
...
3
votes
2
answers
519
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....
3
votes
1
answer
522
views
Float not iterable
import arcpy
arcpy.env.workspace = "c:/esripress/python/data"
fc = "Hawaii.shp"
cursor = arcpy.da.SearchCursor(fc, ["OID@","SHAPE@"])
for shape in cursor:
print "Total area: {}"....
3
votes
1
answer
838
views
arcpy.da.UpdateCursor "iteration not started" when using pairwise iteration through cursor
Without getting too much into the context of this workflow, I'm trying to find whether a stream segment is flowing in the right direction. If the "FROM_NODE" or the "TO_NODE" values of two adjacent ...
3
votes
1
answer
6k
views
Creating tables on ArcGIS with arcpy?
I'm using python scripts on ArcGIS 10.2 to read excel files with information and put this results on attribute tables of the ArcGIS.
I know how to create a table, add rows, add fields and send ...
3
votes
1
answer
61
views
moving the objects in a feature class by a field within the table of that feature class
I have a feature class and I want to move its objects based on two fields in it I used the following code but get error:
with arcpy.da.UpdateCursor(fc2,["SHAPE@XY","centerpo_4","centerpo_5"]) as ...
3
votes
1
answer
117
views
Calculating one cell from dbf table to another cell in same table using ArcPy?
Am absolutely new to python programming for ArcGIS.
How do I calculate one cell from one field in DBF table into another cell in another field in same table?
Here is what I've got that doesn't work:...