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

learn more… | top users | synonyms (2)

0
votes
1answer
102 views

Having arcpy.da.SearchCursor access 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
1answer
47 views

ArcObjects in ArcMap 10.2.2 UpdateCursor refer to a calculated field value in the same Cursor

Is it safe to calculate a field value inside an update cursor and refer back to this calculated value to change another field value of the same row? I think some code will actually explain my ...
1
vote
0answers
67 views

Cursor help on large spatial query in PostgreSQL

I have two very large tables on which I want to perform a spatial query. UPDATE table_a SET att_1 = b.att_1, att_2 = b.att_2 FROM table_a AS a JOIN table_b AS b ON ...
1
vote
1answer
58 views

updating field based on another field with arcpy.da.updateCursor

My code is very simple and it should work, but it doesn't. Perhaps another set of eyes can solve my issue... I created new field (this part works), then look up value of another field and depending on ...
0
votes
0answers
41 views

To get field value from a first table and search it in a second table

I create a script that allow me to display field values from my first table. How can I get value display with print in order to serach it in a second table. If values displayed using print doesn't ...
0
votes
1answer
63 views

Python Calculate Cumulative Polygon Areas (Basins)

I've been asked to automate the calculation of cumulative polygon areas within a basins shapefile. The calculation will take the area of the upstream basin and add it to the area of the downstream ...
0
votes
1answer
38 views

Problems passing where clause as variable?

I'm having trouble passing my where clause for arcpy.SearchCursor as a variable. The following code successfully generates a query for me: PolyList = "C:\\Users\\korora912\\Desktop\\polygons.shp" ...
1
vote
2answers
45 views

Cannot insert data into my feature class

I'm using Arcgis 10.1 and I created my script for inserting data in my feature class but I got this error message: Traceback (most recent call last): File "C:\SIG_AS\Shapefiles\Projet2\MyScript\...
0
votes
1answer
138 views

arcpy.da.UpdateCursor updating field based on the previous row

I am quite new to python. As you can see from the image attached to this post. I have polylines with From junctions (fnode) and to junctions(tnode) field. My goal is as following: To update draw ...
2
votes
1answer
40 views

Deleting Duplicates from Multiple Tables in a GeoDatabase

I'm having trouble deleting duplicates from multiple tables in a geodatabase. I have a field "facility_id" which should be unique, but I have multiple entries and need to delete all but one. I've ...
0
votes
1answer
69 views

Writing attributes and associated feature class name from file geodatabase to CSV?

I need to write a csv file that lists every record from an ID field across all feature classes in a gdb. The code I have written below does that fine, but I also need to write in the second column of ...
1
vote
2answers
61 views

Looping fields in an update cursor

I'm running an update cursor on an in_memory feature class to remove blank (but not null) values as part of a larger process. I wanted by update cursor to loop through my list of fields and if the ...
2
votes
2answers
61 views

Creating a list using an attribute query with arcpy.da.SearchCursor

I have a shapefile of a river network containing the following fields: toJunction, fromJunction, Int_DAM (which indicates free-flowing status) and Strahler. I'm trying to create a list of the rows ...
4
votes
3answers
372 views

Why [0] is needed in row[0] when using ArcPy (Data Access) cursors?

when running the following 2 sample codes, "[0]" is needed to be added after "row" in order to make code run well. I was confused. can anyone help explain? I know that it might be too easy for most of ...
1
vote
1answer
70 views

Arcpy get values in the 2nd field of every table in a geodatabase

I have a geodatabase in Oracle with around 50 tables. I want to get the values in the 2nd field of every table in my geodatabase. I will be using the values in the 2nd field as an input for a ...
1
vote
0answers
24 views

Cursor update row operator [closed]

This is a find and replace script I have been working on. I feel I am very close, as the script does everything but actually change the values, leading me to believe there is an operator issue. I have ...
2
votes
2answers
120 views

ArcPy Calculate Null Values to Zero in Multiple Fields

I have a table that has Null values and I would like to insert a portion in my script to calculate these Null values to 0 in only a few of my columns in my table. Here is my script so far: with ...
3
votes
1answer
53 views

Calculating summary statistics and access resulting value in table using ArcPy?

With arcpy, I want to calculate the mean value of a specific field in a shapefile and print the resulting value for the user. I use the Summary Statistics tool and it works, but the resulting value ...
1
vote
2answers
99 views

How to keep a parameter blank in a script tool?

I've developed a sort of find and replace script tool that functions. But I'm not able to figure out how to find empty cells in fields and replace them.For the "Find" parameter, I have tried entering "...
2
votes
1answer
29 views

Problems with insert cursor

I am counting the number of features in a geodabase. I am triying to insert the feature name and the count inside a dbf table which has only two fields: "FEAT" (Text field which containts the feature ...
2
votes
1answer
77 views

Developing find and replace script tool?

I'm being tasked for developing a script tool that can find ultimately needs to be able to find any string and replace it with another string in an attribute table. Below is what I have so far, and it ...
1
vote
1answer
63 views

Insert (or Update) Cursor setting value to None not honored when field has a default value

To set a field to null, the InsertCursor or UpdateCursor is setting the value to None. Here is a sample for the UpdateCursor: with arcpy.da.UpdateCursor(test_fc, ['SERVICEINDICATOR'], """"OBJECTID" =...
1
vote
1answer
62 views

How to update new column in attribute table with same values but different field type?

I am struggling a bit with debugging my code, over something that seems very simple. I am using an update cursor to copy and convert existing string data into a new float column of my shapefile's ...
0
votes
1answer
48 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 ...
2
votes
1answer
44 views

Arcpy “print” works only the first time [duplicate]

I am running this extremely simple code using the ArcGIS python environment: import arcpy test = r"C:\....\New_Shapefile.shp" #test contains several fields, including one called "Number". ...
1
vote
1answer
30 views

Replace Statistics_analysis with SearchCursor?

I'm using ArcGIS 10.3, 64bit with an advanced license. I have the following code, that runs just fine. It goes through a table that contains a large number of entries with zip-codes and population ...
0
votes
0answers
29 views

Trying to delete specific features within feature class

I am working with arcmap 10.2. I have a database that has a few feature classes in it. Within these feature classes, they have a field labeled as Height. Height is a string field that houses numbers (...
4
votes
1answer
48 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
1answer
101 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 = arcpy.UpdateCursor(...
1
vote
1answer
60 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
77 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
72 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
45 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
75 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 assigned ...
1
vote
1answer
57 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
77 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
57 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
61 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 {1}...
2
votes
1answer
102 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
200 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
99 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 = row....
4
votes
2answers
129 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
89 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
121 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
1answer
55 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
98 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
97 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
58 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
77 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
97 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 ...