All Questions
1,006 questions
0
votes
1
answer
70
views
SearchCursor inside other SearchCursor
I have two layers. The first is bicycle stations, the second is bicycle rentals on a specific day.
I want to make a selection by station number attribute using the station list contained in the first ...
0
votes
1
answer
138
views
Search Cursor in ArcPy for a range [closed]
I'm getting an error while using the where_clause for a length which has a "float" datatype.
While other variables in a function are working fine, even on ArcMap "length" part is ...
4
votes
1
answer
141
views
Update Cursor - Removing Strings/keywords
I have a mosaic data (over 500k rows) I want to run a UpdateCursor on to clean up a string field which roughly follows this pattern:
1432 Arequipa 92 PRINCIPAL SAT CAPTURE
2235 Pokhara 11 SECONDARY ...
0
votes
1
answer
162
views
Update point fields with fields in intersecting polygon
I get new points (inspections) every day. Each point falls within a polygon (district).
I need to update 3 fields (Week, RecycleRt, RecyCollDay) in the point feature class with the district fields.
I ...
-2
votes
1
answer
177
views
SQL statement (where_clause) does not work for UpdateCursor syntax but same works for SearchCursor syntax
feature class fc1 (daily data) and feature class fc2 (geodatabase) both have unique_id field which will be used to map Col1 rows in fc1 to update corresponding Col2 rows (not all rows) in fc2. Below ...
0
votes
0
answers
178
views
ArcGIS/ArcPy gets XY backwards?
Okay, this has been bugging me for a long time, but I've always been too embarrassed to ask given how basic a question it is. Do the data access cursors get XY backwards when you use tokens like SHAPE@...
1
vote
1
answer
230
views
Use UpdateCursor to update a field based on value in other field
I'm trying to use a codeblock, that I've used in the field calculator of a shapefile before, in an ArcPy script with UpdateCursor.
The code I've used in the field calculator:
Pre-Logic Script Code:
...
1
vote
1
answer
226
views
Sorting by multiple fields SearchCursor ArcGIS 10.6
I want to define the values of first row in a sorted table with search cursor.
My code is working without sorting, but I don't know how can I integrate into sorting.
I would like to see only the ...
0
votes
1
answer
447
views
UpdateCursor with multiple loops in ArcPy
I have a feature class and I need to renumber from 1 and increase by 1 for a group of features. To do that, I need to define these groups (based on atributes of a field) and for each group make an ...
1
vote
1
answer
644
views
ArcPy using SearchCursor with Geoprocessing to perform operations on each row
I have a shapefile, that has lots of individual rows. My goal is simple, to export each row as a raster.
I am trying to use SearchCursor, to select each row and perform a feature to raster conversion. ...
0
votes
0
answers
93
views
StopIteration: iteration not started error using arcpy.da.UpdateCursor Arcpy Pro?
I got error of StopIteration: iteration not started and I don’t know why. I have a shapefile. First I made a layer feature by selecting Side = R from ID : 0 to 99. I would like the code starts from ...
1
vote
0
answers
518
views
ArcPy UpdateCursor - Attribute column not found
I have a rather lengthy script that I'm testing by pasting the code into the ArcGIS Pro Python command window. The script takes a table for geocoding, attempts to fix errors such misspelled cities to ...
2
votes
1
answer
40
views
Replace a field with maximum of it's attribute values based on values repeated on another field's attribute values using ArcPy
So I have performed Spatial Join between a point and line feature class. Now for each point there are several lines. What I want is the maximum count of line features as an attribute value in the &...
4
votes
2
answers
519
views
Error: 'list' object has no attribute 'segmentAlongLine'
I am trying to trim each polyline in a shapefile down to the first 15 feet of each line. The segmentAlongLine method was suggested to me, but this code is getting the AttributeError: 'list' object has ...
2
votes
1
answer
242
views
Remove a Row in an attribute table using UpdateCursor?
I'm trying to create a piece of code to remove rows where the field "State_Name" equals Hawaii or Alaska from my shapefile's attribute table. I've tried two different codes and they both ...
1
vote
2
answers
91
views
ArcPy.da.SearchCursor not cursor-ing
I am using ArcMap 10.8.1.
I have shapefiles that are a series of overlapping polygons of drone imagery footprints. I want to loop through each shapefile, and for every shapefile loop through and ...
3
votes
1
answer
372
views
Using ArcPy to get point from a cursor for input in arcpy.PolyLine()
I am using ArcGIS Desktop 10.8 Basic. I do not have access to a Standard or Advanced license for this.
I want to use a point from a search cursor as an input for the arcpy.PolyLine() method. A second ...
1
vote
2
answers
961
views
Using ArcPy UpdateCursor to Update a field
In my data I have one field (L1_SOILTYP) and a new field I created (SoilClass). I am trying to use update cursor to assign classification values (1-17) based on the values found in the L1_SOILTYP ...
1
vote
1
answer
298
views
ArcPy insertRow asking for a sequence of values
I've got code that pulls the center point from a layer, and places it in a new feature class as part of a more complex analytical process.
I'm trying to get the centroid written to an in_memory ...
2
votes
0
answers
871
views
UpdateCursor cannot acquire lock if attribute table is opened in ArcGIS Pro
I wrote a script tool for someone to allow them to clean all whitespace errors (leading/trailing spaces, 2+ consecutive white spaces, convert empty strings to nulls), and aside from one issue it works ...
0
votes
1
answer
161
views
Accessing single value in field using ArcPy with ArcGIS Pro
I'm pretty new to Python scripting (especially in ArcGIS). I would like to access a single element from a field and modify it. I understand that I can do this with cursors by searching the field ...
2
votes
1
answer
185
views
Keeping alias field names on CSV export using ArcPy
I'm exporting my feature class to a CSV file. I figured how to keep the fields I need on export.
Is there a way to keep the alias field name on export?
I'm also open to writing out the correct headers ...
0
votes
1
answer
687
views
Extracting data from attribute table in one shapefile and use it to populate another shapefile attribute table using ArcPy
I am working on a homework assignment for my coding class, and I am having issues with the last part of the assignment. My job is to create new three shapefiles based on players' positions in a target ...
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 ...
1
vote
1
answer
86
views
Field Calculator python to Python code
I am trying to convert a python code from field calculator to arcpy (pycharm).
All i am wanting to do is convert the below python code into a way python in pycharm will read it.
!Owner_Ab!.title()
...
0
votes
0
answers
165
views
Using ArcPy Update Cursor with ArcMap
I am trying to do an update cursor in my script. Can someone please tell me why when I do 2 IF statements only the second IF statement runs.
For example this runs fine
fc = CAD_WA
fields = ["...
1
vote
1
answer
695
views
Downloading file using URL value in shapefile field accessed via ArcPy cursor
How do I download files through Python using URLs located in a shapefile with ArcPy?
The script needs to read a shapefile, create folders and download images using URLs in more than 1 field/record (...
0
votes
1
answer
44
views
SearchCursor stops after first iteration
I'm working on a script that takes a few feature classes, unions them together and then runs a series of geoprocesses on them and puts it into a single feature class. From that feature class I have a ...
0
votes
1
answer
79
views
Delete row with specific text in a specific field at a specific time
I have a feature class that resides in an Enterprise geodatabase, I need to delete a row that has specific text in a specific field at a specific.
Data is being submitted daily to this feature class ...
1
vote
0
answers
339
views
"RuntimeError: An expected Field was not found or could not be retrieved properly. [temp]" while using SearchCursor
I was trying to convert a .csv table to a geodatabase table and then write some rows that meet some conditions (using sql statement) from the table into a txt file. see the code below.
file_path = r'C:...
1
vote
2
answers
58
views
What are considered invalid fieldnames with arcpy Cursor classes?
Using this code, I get the following error.
infeature = r"C:\pathto\file.gdb\file" #location of feature class
fields = ["Name:", "Location", "Email Address", &...
0
votes
0
answers
797
views
ArcPy script extremely slow with Search and Update Cursor
I have developed a Python script to automatically retrieve the maximum height in a certain distance around my input polygon feature class. The height should be calculated for each 5 meters.
For a ...
1
vote
1
answer
463
views
Updating datefield from a string with UpdateCursor
I have a string I'm slicing and then using UpdateCursor to update rows with the outputs. The string is formatted like this:
Foo_YYYYmmddHM_Xy_Ab_Bar
I'm struggling in getting only the YYYYmmdd part of ...
1
vote
1
answer
846
views
Using SearchCursor and UpdateCursor to get multivalues from one table/field to single value of another table/field?
I'm trying to use a combination of arcpy.da.SearchCursor and arcpy.da.UpdateCursor to read and store a couple of values from Table 1 Field A, then insert those values as a single string within Table 2 ...
0
votes
1
answer
866
views
TypeError with UpdateCursor on a Field with a Coded Text Domain
Trying to run an arcpy.da.UpdateCursor on a field that has a Coded Text Domain.
I keep getting a typeError.
Not sure if there's a certain syntax that I need to be using when trying to update the row ...
1
vote
1
answer
44
views
Incorrect mean calculation with.UpdateCursor ArcPy
I find this code here, but the results of calculation are not correct.
Field list is correct:
[u'T34TET20160527', u'T34TET20160606', u'T34TET20160616', 'Mean_16']
I calculated mean with Field ...
0
votes
0
answers
649
views
Strange "RuntimeError: ERROR 160195: An invalid SQL statement was used". when trying to debug SearchCursor
I'm trying to get a SearchCursor to function in my script. According to everything I could find, this should have worked. The code reads like this:
with arcpy.SearchCursor(sickTrees,'OID@') as cursor:
...
1
vote
1
answer
88
views
Delete fields from a table based on Mean calculation using ArcPy
I have an attribute table with 100 columns (values are float and not NULL; more than 3000 rows). Using ArcGIS 10.6
I want to calculate the mean value of every field in a shapefile separately (like ...
2
votes
1
answer
21
views
Writing program to get datatypes of certain fields and then do some work on that but SearchCursor makes everything tuples
I am trying to write a program to get the datatypes of certain fields and then do some work on that but SearchCursor makes everything tuples.
How do I bypass this situation and get the actual datatype ...
0
votes
1
answer
2k
views
Using arcpy.da.SearchCursor to sort field in attribute table by ascending order
I am using ArcMap 10.6 with Python 2.7.14 with ArcPy.
I want to sort a field named Seq_ID in my attribute table by ascending order using ArcPy.
I believe I have to use arcpy.da.SearchCursor.
Here is ...
1
vote
0
answers
366
views
Why does my arcpy script's da.UpdateCursor get slower the longer it runs?
I have a layer containing pedestrian crosswalks (line features), and two layers containing street data: street segments (line features) and street nodes (point features). Every street segment has a ...
5
votes
3
answers
474
views
UpdateCursor RuntimeError: An invalid SQL statement was used
with arcpy.da.UpdateCursor(inFeatures, "[TDS_Name]") as change_cursor:
for x in change_cursor:
if x[0] == None:
x[0] = x[0]
else:
x[0] = x[0]....
0
votes
1
answer
230
views
Not able to update polyline geometry via update cursor
I am trying to read polyline from the feature class and then add a point to the geometry and the update it in the same feature class....
I am able to read it and add the new point...but not able to ...
1
vote
1
answer
320
views
Python scripting (update cursor, extract previous row values)
I am new to Python scripting.
I would like to use SearchCursor to iterate in each row using the FID as index. Then I would like to evaluate length based on the following conditions:
If the length >...
0
votes
1
answer
240
views
Checking value of field based on conditional if statement using ArcPy cursors
I'm using ArcGIS desktop 10.6 and executing an arcpy script.
I'm creating a script that checks an input shapefiles field values against a set of rules. To do so I've created 2 lists with unique values ...
1
vote
1
answer
91
views
Updating Z values on points using UpdateCursor
I have created the following script, which moves the points from my_input_points_fc to my_output_points_fc by user input
Furthermore, the z-values in my_output_points_fc should also be updated. ...
0
votes
1
answer
649
views
arcpy.da.InsertCursor() Fails with SDE But Works with Local FGDB
I am trying to use arcpy.da.InsertCursor() to insert rows to an SDE table but no rows were added and without any error message. I tried the same code with an exact replica table in a local FGDB and it ...
1
vote
0
answers
98
views
UpdateCursor is only updating the first letter from the value of my dictionary [closed]
I am using an update cursor to update an attribute field with the value of my dictionary. Both the field and the value are strings. I am confused why the update cursor is only updating the field ...
1
vote
2
answers
208
views
Error using ArcPy SearchCursor to get list of unique values in multiple fields
I'm trying to extract a list of unique values in two fields in a shapefile. I think I am misunderstanding how the search cursor works, because I get the same error on which ever variable (x or y) I ...
1
vote
1
answer
629
views
Updating Fields with values from Python list using ArcPy UpdateCursor
I'm currently trying to update the fields of a shapefile, with a list I've compiled outside of the arcpy environment. Trying both UpdateCursor which I can't seem to get to work, and FieldCalculator. ...