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

learn more… | top users | synonyms (2)

4
votes
1answer
89 views

How to delete rows in attribute table of a shape file based on specific condition?

I want to delete ceratin rows in a shape file if field ID is equal to certain number (say 2). Below is what I am trying, import arcpy shape="C:\Users\Data\Loc.shp" rows = ...
1
vote
1answer
55 views

arcpy SearchCursor always empty at each loop when inserting new rows with InsertCursor

I am inserting new rows into a POINT FeatureClass within a geodatabase. The way I do it is by creating an InsertCursor over an empty FeatureClass and inserting new rows while loopinf through the ...
0
votes
1answer
39 views

Arcpy: Geometry object - distanceTo method in a for loop

I'm new to Python so sorry for this maybe trivial question. I have 4 lines and 4 points, which belong together. I want to get the closest distance from point 4 to line 4, point 3 to line 3, ... . I ...
2
votes
2answers
54 views

Update value in one table (feature class) by coping it from another table. The match between table is done on values from another field

I have two tables (actually both are feature classes in filegeodatabase). They pretty much identical except. one is in lat/lon. second one is projected. both have field line_length and objectid. ...
-1
votes
1answer
43 views

Exporting maps to pdf

I need to create a PDF book of all counties in a counties shapefile. I now have to use a cursor and a for loop to get individual counties, but I'm not sure how to go from there. I'm not allowed to ...
1
vote
2answers
67 views

script to grab value from field and input into SearchCursor then select results for further analysis

The data: PL_Fac -point file - facilities used in service area analysis - contains PNTID in Add_PNTID field PD - polygon - catchment areas assigned to a facility (there can be many polygons ...
1
vote
1answer
47 views

Extract Polygons out of a raster

I want to extract every row from a .shp from a raster (Extract by Mask). With the following code i get 4 output raster, wich concludes every row. import arcpy arcpy.CheckOutExtension('spatial') ...
3
votes
3answers
72 views

How to generate a list of unique years from date field?

I have data that was collected over many years and I'd like to be able to run a python script tool in ArcToolbox (ArcGIS 10.1) to get a list of unique years from the date field. I found an example of ...
3
votes
1answer
49 views

How to slice a list based on row values? [closed]

I'm working with python 2.7 (quite a beginner). I have a list, and I have a feature class with : A = a field that contains values that I would like to use as the start of the slicing B= a field that ...
3
votes
1answer
51 views

ArcPy SearchCursor row format

I set up a script to print some statistics about line segments. The "logfile" is basically the same as "print", but to a textfile instead of on screen only. LogFile("Feature {0} has a length of ...
2
votes
1answer
88 views

arcpy.UpdateCursor updates every row

I would like to update a field with new values. With the code below it assigns the value '2' to all the rows and not just if the field == 2. But by 'print i' and 'print "it is 2"' everything looks ...
5
votes
1answer
128 views

UpdateCursor gives Too few parameters Expected 1?

Can anyone tell me why my script isnt working? I cant figure out where I went wrong. I am working with an access personal geodatabase. Adding a field, then updating that field with yes if the field ...
1
vote
2answers
83 views

Updating firstPoint and lastPoint using ArcPy cursor?

I want to update a Line feature's start and end. I got Point of first and last. BUt, I can't update them. What is wrong ? (I'm using ArcGIS 10.2) rows = arcpy.UpdateCursor(srcFile) feat = ...
4
votes
2answers
89 views

Python script that creates polygon feature class with given coordinates

Write a script that creates a new polygon feature class containing a single ( square ) polygon with the following coordinates: ( 0, 0 ), ( 0, 1,000 ), ( 1,000, 0 ), and ( 1,000, 1,000 ). ...
5
votes
1answer
74 views

Writing points to a file

Trying to write the city name and point coords to a file. The following works with a polygon shapefile but not the point shapefile. I know I'm missing something basic. import arcpy # Set up the ...
3
votes
1answer
116 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 ...
2
votes
1answer
49 views

Add shp attribute data to column with python script

If feature column (feature is the name of the column) in table is ferry crossing in the attribute data then I need to add Yes to the Ferry column that I have already added to the table. If the ...
2
votes
2answers
82 views

Column does not exist - python

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 ...
0
votes
1answer
85 views

Improving processing time of ArcPy script?

Background: I work for an electrical utility, and we have a point feature class called "meters" that contains approximately 35,000 records. These records represent the actual power meter, and contain ...
0
votes
1answer
52 views

replace ü/ ö/ ä / spaces and brackets in Attribute Table [duplicate]

I've got a Polygon Feature Class of communities in switzerland. Unfortunately, the names in the attribute Field "NAME" include spaces, brackets and ä/ ö/ ü characters. For further processing, i need ...
0
votes
0answers
74 views

arcpy UpdateCursor throws exception on geoprocessing service?

I wrote Python code that changes the state of a feature by ID. I am not using a Python Toolbox (.pyt). I wrote a python script and added it into a standard toolbox (.tbx). Using ArcGIS Desktop ...
0
votes
3answers
78 views

Assign Mask From Layer in SearchCursor Loop In ArcPy: Error Accessing Environment

I'm trying to run a loop based on a SearchCursor that selects layers from an input polygon and polyline. I want to select a feature from the polygon to use as a mask for running Euclidean Allocation ...
0
votes
1answer
100 views

Using Update Cursor to update all fields in a feature class based upon another feature class

I have perused GIS stack exchange to find an answer, but haven't quite found what I am looking for. Question: I am trying to update all the fields in a feature class based upon field values from ...
1
vote
1answer
39 views

Updating null values in appended feature class

I am creating a customized script tool that first clips out a line feature from one feature class, dissolves the fields of the clipped feature class so that just one feature is in it, appends the ...
3
votes
2answers
56 views

Fetching single value without Cursor in ArcObjects?

I used the below function to get the single value using ArcObjects. private string getApproverAlias(string checklistId, bool isDeleted) { string approverAlias = ""; var masterTable = ...
1
vote
2answers
54 views

IndentationError: expected an indented block

I am getting the IndentationError in arcpy. I understand this is covered elsewhere but none of the tips appear to be working, I cannot figure out the error. Here is my code; def getCoords(self): ...
3
votes
1answer
137 views

Using Update Cursor, populate field

I am trying to write a script where you preemptively select features and then go to the tool which calls for the feature layer and it populates fields based on certain criteria which I will design of ...
1
vote
1answer
51 views

arcpy SearchCursor is creating a comma within a tuple

I am creating a list of tuples of coordinates of a feature class. Feature class is created as such: inFC = arcpy.GetParameterAsText(0) The inFC is a point feature class. I then have the following ...
1
vote
1answer
178 views

Arcpy SearchCursor (arcpy.da) - Assign cursor value to variable [closed]

I am trying to use arcpy.da.SearchCursor to get the values of two field for each reach record in the DISTRICT feature class. I need to assign these values from the table to a two variables varRegion ...
1
vote
1answer
102 views

Trying to increment a field value for only the repeated records in a feature class using Python

NOTE: If you look at the excel tables just above the comment section it will give a clearer picture of what I want to achieve in my code. So the code below works in doing what I want it to do thus ...
3
votes
1answer
232 views

Selecting rows in a layer using arcpy.SearchCursor

I'm working on a project to identify points that fall along lengths of road. The roads are stored a single featureclass within a file geodatabase, as are the points. I'm using ArcGIS 10.3. I'm trying ...
0
votes
1answer
30 views

UpdateCursor based on results from SearchCursor

i'm kinda stuck with an UpdateCursor. This is what I'm trying to do: each cell of a grid stores multiple answers that were given in a survey. For each cell I must choose only ONE answer, the one that ...
1
vote
1answer
111 views

Arcpy search cursor and update cursor to write values from table A to table B

I'm a python beginner. I`m working with ArcGIS 10.2.2 and IDLE Python 2.7.5 I have two tables, table A (top) and table B. I need to read the attributes for the A-table fields for the selected ...
3
votes
1answer
64 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 ...
4
votes
1answer
65 views

Error saving object from python script using GetParameterAsText

I have a script that takes in a line, and creates a certain polygon based on this. My code obtaining the input information is as follows: inFC = arcpy.GetParameterAsText(0) hasClearway = ...
2
votes
1answer
87 views

Python script outputs polygon feature class with no shape_area or shape_length and therefore doesn't show up in arcmap

I am trying to copy features a number of times based on a numeric field value. The code below works for points when the POINT type is chosen. However, when I switched the feature type to POLYGON it ...
2
votes
1answer
52 views

Convert searchcursor object to variable

Using a python script, i would like to read through a table which features 27 columns. For each row i want to store the value of each column in a variable, so that i can pass the values to a ...
1
vote
2answers
57 views

Update Cursor keeps Crashing and Skipping

I use a 3rd party software that exports the name of JPEG as I collect points, in this case street signs. I know the names stay static and are all unique but different features may have the same JPEG ...
1
vote
1answer
32 views

Converting tuple into records in blank feature class using ArcPy?

Here is the code block that I am using with ArcGIS 10.2 for Desktop, it all works great except for the bottom part. I am not sure how to turn the tuple into records on a blank feature class. The tuple ...
2
votes
2answers
47 views

Delete records in feature class that have same ID in CSV table using arcpy cursors

So I have a csv table with records that have an ID. I want to find the same IDs in a feature class/shapefile and delete those records in the feature class/shapefile using Python. I've messed with ...
0
votes
1answer
62 views

How to append Extent object to existing dictionary key values?

I have a dictionary whose keys are map segment names, and whose value is a list of 3 field values. Using an arcpy.da.SearchCursor on the map segments FeatureLayer, I have extracted the extent object ...
2
votes
1answer
59 views

Complex polyline traversing with searchcursor

I have a very specific question about searchcursor traversing complex polyline. My setup is: I imported public transport routes as a single polyline with length in meters. Along this polyline I want ...
1
vote
1answer
30 views

IfeatureLayer.search() second time return error

I have the following method in my code and have a button that when clicked run this code. In the first click all of code runs without error. but in second run I receive an error on line: ...
0
votes
0answers
37 views

Finding duplicates of same point in feature class and only keep maximum of field using ArcPy?

I have a feature class with fields: Latitude, Longitude, Type, Magnitude, City, State, Comment. If Latitude, Longitude , and Type are the same, I only want to keep the record with the highest ...
1
vote
0answers
24 views

Trying to automate clip for multiple polygons based on unique field ID? [duplicate]

I have two feature classes, one that contains all counties for 5 states and the other contains 90 polygons I need clipped only to their pertaining county boundary, but they overlap/ cross the county ...
0
votes
0answers
24 views

SearchCursor to find a feature that intersects 5 of another feature?

I am using ArcMap 10.2.2. Currently my code looks like this: count = 0 features = arcpy.da.SearchCursor(fc, subtype) for feat in features: if feat == (100161,): count += 1 print count ...
0
votes
0answers
28 views

Looping all features of cursor onto SQL Server feature class?

It might be me but I've been experiencing something weird. (I actually tried what suggested in this thread Arcpy MakeFeatureLayer won't loop with no luck) What I'm trying to accomplish is to use ...
1
vote
2answers
106 views

Error adding row - sequence size must match size of row

I have this table with one row timestamp_pretty 3.1.2014 9:13 timestamp 1,38874E+12 msgid 3 targetType A mmsi 205533000 lat 53.4346 long ...
0
votes
2answers
31 views

What is wrong with this code? my query is not updated with the new value [closed]

query='"depth">1700 AND "depth"<1750' with arcpy.da.UpdateCursor(out_layer,"depth",query)as cursor: for row in cursor: row[0]=0 cursor.updateRow(row)
1
vote
1answer
34 views

Fill a field according to the value of an other field with Arcpy

I am very ill at ease with Python. I am working on ArcGIS 10.3. I am working on a table in a gdb. I want to fill an empty field of this table with an expression (words) according to the value of a ...