Cursors are used by database programmers to process individual rows returned by database system queries.

learn more… | top users | synonyms (2)

0
votes
0answers
23 views

NameError when attempting to auto increment field with python script [on hold]

I am getting the following error when trying to run my code and I am not sure why: NameError: global name 'rec' is not defined Here is my code: field = "id_num" rec=0 def autoIncrement(): ...
1
vote
1answer
66 views

how to skip creating an empty feature class using featureclass to featureclass in arcpy

I have a script that finds points outside of selected areas and creates a feature class in a file geodatabase. However, sometimes there are no points outside of the selected area. Currently, the ...
0
votes
1answer
21 views

Script with searchCursor crashing arcmap

I was trying to make a script that counts the max lenght found in each field of a table with data in it, but it immediately crashes arcmap upon executing I know there might be a tool available on the ...
1
vote
1answer
316 views

How to auto-increment attribute fields using cursors and conditional statements?

I am trying to create unique IDs for an attribute named "FACILITYID" (str) and have got a ton of help from related posts and online python tutorials. I selected the rows I wished to create unique ID's ...
0
votes
2answers
281 views

Can I use my SearchCursor in Select by Location

I am trying to select the largest polygon that contains each feature in a feature class but none of the features in another feature class. I have written the code that seems logical to me but (of ...
0
votes
1answer
28 views

UpdateCursor not filling correctly with conditional statement

I am attempting to update a table so that a field, "ALLREADY", fills with "Y" or "N" depending upon if "dmready" equals "total_records" AND if "dm_stat" is equal to "Ready for DM". When I run my ...
0
votes
1answer
576 views

Polygon Neighbors Analysis script (ArcPy 10.1) producing erroneous results?

I'm struggling with a python script that is supposed to calculate a field for a polygon feature class. The calculation is of the average of a field value (P_TOT_DEV) for each of a given polygon's ...
1
vote
2answers
59 views

Removing duplicate pairs in Near Table

Generate Near Table or Near can be used on a single Feature Class to find the nearest feature to each feature. arcpy.GenerateNearTable_analysis(featureClass, featureClass, pairsTable) This ...
0
votes
0answers
25 views

Using UpdateCursor to populate new field based on conditional statement not updating field [closed]

I am attempting to populate a new field with a "Y" or "N" based on whether two integer fields are equal. My code seems like it should work, but when I run it, it does not update the field (the field ...
0
votes
0answers
14 views

How to concatenate column attributes into a single column where we don’t know the number of columns or the names via arcpy? [closed]

I have lots shapefiles all with different columns except for a standard ‘name’ columns. Since the other columns are all different, I want to dump them into one large text column. It would be nice to ...
0
votes
0answers
180 views

Can I do full SQL expressions through the “WHERE” clause in UpdateCursor? [closed]

Run as a standalone python script for a shapefile in a toolbox on ArcMap. For example: psql_url_pop = '''SELECT shapefile.NAME_# + shapefile.WIKI_URL FROM public.shapefile''' rows = arcpy....
0
votes
1answer
37 views

Combining two search cursors (one for table and other for feature class)?

I have a problem from combining two search cursors (one for a table and other for a feature class), there are missed records in the first table, that have not been considered by the first search ...
1
vote
2answers
29 views

TypeError: list indices must be integers, not str when trying to calculate new records in several fields

I am trying to calculate new records in several fields by looping through each field in a list and dividing the value of each record by its shape area. My code is as follows: inFeature = outFeature ...
0
votes
1answer
63 views

Calculating well densities in selected counties using ArcPy?

I'm new in python and I have no clue how to do this. I am trying to calculate: total numbers of wells that fall into each county in a shape file, and update the county table with the total count. ...
1
vote
2answers
129 views

Editing and manipulating tables with ArcPy? [duplicate]

I’m new to ArcMap and was wondering if anybody could help me out. I have a shapefile with counties and wells in that county. In the table I’m trying edit it so that for each county calculate the total ...
2
votes
2answers
3k views

Reading Null values in field using ArcPy SearchCursor?

I'm using a Python script with ArcGIS 10 to count the number of unique string values in a feature class. My script works if there are values in the field but if there are any NUll values in the field ...
14
votes
2answers
1k views

How is the data access cursor performance so enhanced compared to previous versions?

The data access module was introduced with ArcGIS version 10.1. ESRI describes the data access module as follows (source): The data access module, arcpy.da, is a Python module for working with ...
-2
votes
1answer
37 views

Printing rows from table but getting error? [closed]

Here is my code. I have no problem printing out one column from a a table but can't seem to get it right in printing two. fc = "C:\Users\Brett\Desktop\lesson_5\Lesson5_Data\Lesson5_Data\COUNTIES.shp" ...
1
vote
2answers
92 views

Using 2 with statements with arcpy da search cursor

I often see code that is comparing 2 shapefiles where there needs to be 2 with statements in the same loop. In my head I always thought both with statements should be placed first before starting ...
3
votes
2answers
121 views

Debugging RuntimeError: A column was specified that does not exist from ArcPy?

My goal is to count the number of wells in each county. I've verified the columns are correct as listed in the attribute table. Do I have a typing or formatting error? I wanted to pull county names ...
3
votes
1answer
31 views

ArcPy UpdateCursor appears to not Update field in open Attribute Table?

I have been trying to get Update Cursor to update a field in my attribute tale. import arcpy fields = ['STATE_ABBR','Last_Update'] fc = "C:\Users\sword\Desktop\GIS Web Course\PersonalProject\...
5
votes
1answer
74 views

Update from/to Z from attributes using arcpy Update Cursor

Trying to update Z values onto some point and line features from the level attributes on each feature. My script works fine on points - the previous Z values of 0 now have the same values as the ...
2
votes
1answer
7k views

Using arcpy.UpdateCursor to delete rows does not delete based on counter?

I am trying to delete rows from a shapefile using arcpy.UpdateCursor. The first thing I did was get a unique list of values from the key field "PolyGUID", then I iterate that list doing a arcpy....
2
votes
1answer
290 views

Using Nested For Loop in ArcPy?

I have two vector layer files, 'hausnummer_cropped5' and 'gebaudepoints_cropped5 - Kopie2'. Both have a point geometry and I am trying to shift the locations of the gebaudepoints_cropped5 points onto ...
2
votes
0answers
38 views

Using Arcpy.UpdateCursor to delete adjacency rows based on a group ID

I have this sample file shown in the picture 1 below. it is a sample data set of a phone survey of drivers. I am trying to find out when those drivers started to drive. My main goal is to build a ...
0
votes
1answer
13 views

Using cursors to summarize per group

I want to summarize fields per Group with python and need help to get unstuck. I'm trying to get the code below to produce a Dictionary of Groups and their total shape areas, like {'Group1':123456, '...
1
vote
1answer
149 views

Arcpy.da.SearchCursor() help when attribute doesn't exist

I'm updating text elements off of an arcpy.da.SearchCursor script and needed to construct the script to return a response for when the attribute does NOT exist. Here is the snippet of the code THAT ...
1
vote
0answers
39 views

Calculating polygon width ArcGIS 10.4

I am trying to calculate an average width of a large set of polygons. I found the script below researching the topic. The function is: def add_average_width(featureClass, averageWidthField='Width'): ...
0
votes
0answers
41 views

postgis iterate over rows (cursors)

I need to repeat the same set of operations for each road polygon by using an id (road_id): I have tested my code only on one polygon of geometry using a series of functions inside a WITH query: ...
0
votes
2answers
79 views

Creating a value-counting table with search- and update cursor

I'm a python beginner. I`m working with ArcGIS 10.2.2 and IDLE Python 2.7.5 I have a shapefile with around 20 fields, each attribute has a value between -3 and 3. This would look like this: I ...
0
votes
1answer
33 views

Can't get new rows added with Arcpy / InsertCursor

I'm not getting any errors but can't seem to get these rows added. Everything else in the script works fine. I only dabble with Python occasionally so please forgive me for missing anything obvious ...
0
votes
1answer
95 views

Update Cursor from TEXT to DATE field

I have column that contains dates that are created from a numpy array to fc, since numpy doesn't handle date types I have had to create another field to update the rows. When using this script in the ...
0
votes
1answer
41 views

Finding field with maximum value and field name using ArcPy cursor?

I was wondering if an equivalent of summary statistics exists for finding such statistics across fields rather than records in a table. For example, of several fields, I wanted to find which one has ...
0
votes
3answers
1k views

Sum fields from ListFields - RuntimeError: A column was specified that does not exist?

Does anyone have a suggestion on how to otherwise solve the problem ... The need to automatically generate all the columns from the table, the calculation of the sum, the results are updated in the ...
0
votes
1answer
2k views

ArcGIS 10.1, Python 2.7 “RuntimeError: A column was specified that does not exist. ” [closed]

When this error is returned, a problematic column must have been encountered. I would like to know WHICH non-existent column has been "specified". How do I obtain this apparently obvious piece of ...
8
votes
2answers
2k views

Calculating Date Field with today's date from datetime.date.today()?

I'm working on part of tool that will use arcpy.CalculateField_management to add the current date to the attribut table. I've wandered far and wide on the interwebs and can't seem to find the ...
0
votes
2answers
70 views

Creating a dict with Search Cursor

I need to find how many routes are assigned to each account number in a feature class. I'm using search cursor twice, first to build a set of account numbers, second to get the number of times a route ...
1
vote
4answers
62 views

Iterate through a list to use then use SearchCursor to populate new list

I have a featureclass of buildings. Each one has a unique number ("BO_UNIQ"). I create a list of these unique numbers (1251 elements). I then want to iterate though this list and get facility names ...
1
vote
0answers
47 views

Pycharm cannot find reference 'SearchCursor' in 'arcpy.da'

Whenever I try to use a search cursor from arcpy in pycharm, I get this unresolved reference error. I should note that it was working fine earlier in the night, I have no idea what happened. I've ...
3
votes
3answers
3k 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
2answers
2k views

ArcPy Data Access Insert Cursor not writing geometries to feature class?

I'm using PyScripter and running ArcGIS 10.2.1. I am having troubles with the Insert Cursor in the arcpy module. I have an empty feature class in my geodatabase and have created the short script ...
2
votes
2answers
1k 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 ...
2
votes
1answer
28 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 ...
0
votes
3answers
101 views

Use if statement to delete row data, ArcGIS 10.3.1, Python 2.7

I have a indoor positioning shp file. I need to do the data cleaning for the further analysis. and here is the attribute table: Field(Sheet1_minor) is the name of beacon, and Fields(Beacon_41_B1,B2,...
1
vote
1answer
576 views

ArcGIS 10.1 arcpy Update Cursor is returning a list instead of a row

I keep getting the following error: Traceback (most recent call last): File "R:\GIS_ScriptsandTools\PullHotParametersLabel.py", line 16, in TitleLine = ""+row.getValue(IDfield)+" ("+ ...
0
votes
2answers
349 views

Same python code works in arcgis python window, but fails in pyScripter

This code works in the arcgis python window but in PyScripter, this warning message had been written: Traceback (most recent call last): File "", line 16, in File "C:\Program Files (x86)\...
2
votes
1answer
68 views

ArcPy Insert cursor losing vertices when writing Polygon features?

I'm currently trying to code a geodesic buffer from points (the one that is implemented in ArcGIS is very slow). The idea is to calculate 100 point coordinates (P_Buffer) around an initial point (P) ...
2
votes
1answer
31 views

Adding values from list into Attribute with UpdateCursor?

I have a list of values of buildings total height and want to update the corresponding field in the shapefile. fclass is my shapefile totalh is the field which i want to update totaheight is a list ...
0
votes
1answer
70 views

Using arcpy.SearchCursor() for multivalue field?

I need to make a multivalue field to be selected as:   Input_Features = arcpy.GetParameterAsText (0) Num_Pop = arcpy.GetParameterAsText (1) #(It contains population data for the periods 2020, 2025, ...
0
votes
1answer
35 views

Holding onto row values while using cursors

I'd like to be able to use an update cursor to go through rows in a table, holding onto the previous rows value, and comparing it to the current row value, to populate a new field with this value. ...