All Questions
116 questions
23
votes
5
answers
27k
views
Obtaining extent of each polygon in shapefile using ArcPy with ArcMap
In ArcGIS 10 and Python I want to get the extent (xmax, ymax, xmin, ymin) info of each of the polygons in a shapefile.
I can get the extent of the whole shapefile using
file=r"D:\SCRATCH\ARCGIS\...
8
votes
4
answers
12k
views
Debugging RuntimeError: workspace already in transaction mode from arcpy.da.UpdateCursor and ArcSDE feature classes?
I am making my first attempt at editing an ArcSDE feature class with python through a da.UpdateCursor. I'm essentially taking code I've written for a file geodatabase feature class and applying it to ...
11
votes
6
answers
17k
views
Moving / offsetting point locations using ArcPy or ModelBuilder?
I have a number non-georeferenced CAD layers (see this question) that have text annotation features. I have created a model to convert the text to points, but after converting the annotation to a ...
24
votes
3
answers
6k
views
Exporting table to XYZ ASCII file via ArcPy?
I'm looking for a way to export an ArcGIS table (created with the Sample tool) to a text file via ArcPy.
I can do this in ArcGIS via the context menu by right-clicking the table, but have not found ...
7
votes
2
answers
4k
views
Using UpdateCursor for joined field in ArcPy?
I have a huge point vector data (around 3 million point; in a gdb) with attributes and I have table (created with Near analysis.). I want to copy one of the field values to data. So I joined the table ...
7
votes
2
answers
5k
views
How to create an offset polyline in arcpy?
I am trying to create an offset polyline using arcpy, identical to the function in ArcObjects (constructoffset). After trying to access ArcObjects in arcpy, which I found difficult for those not well-...
6
votes
3
answers
11k
views
Auto-incrementing in Python Script with ArcPy cursor?
I want to autoincrement values in a field within a Python script. I've done this using Field Calculator and the code referenced here. I tried using this code in the Python script below but it is not ...
6
votes
4
answers
10k
views
Accessing attribute table within shapefile and replace values?
I would like to find a Python script that will access an attribute table within a shapefile and either update or replace records inside a field column. More specifically, I would like to use the ...
1
vote
1
answer
354
views
Updating Z values with geometry of multipart and donut polygons with ArcPy?
I am trying to update Z values of polygon features with point features.
The code is (found on GIS Stack Exchange) working good if no 'interor ring' or 'multipart' features are present in the polygon ...
9
votes
4
answers
27k
views
Using arcpy.da.InsertCursor to insert entire row that is fetched from search cursor?
This is a simple process using the legacy cursors, but I cannot figure out how to do it with the newer Insert Cursor from the Data Access module. I basically want to take the entire row from a Search ...
8
votes
1
answer
3k
views
Why del cursor/row objects of ArcPy?
Can someone help me understand what the last 2 lines of this code does:
import arcpy
arcpy.env.workspace = "c:/esripress/python/data/exercise07"
arcpy.env.overwriteOutput = True
copy = arcpy....
5
votes
2
answers
6k
views
ArcPy Insert Cursor not inserting all rows?
I have a script here that takes data from a cross-tabulated non-spatial dataset where monthly values are stored in a single table row for a given year and linearizes those data so that each monthly ...
5
votes
1
answer
3k
views
Need to find max value among fields and print field name
I have a Census dataset that contains eight fields with percentages. I would like a python script that finds the highest value between the eight fields, but also tells me which field the highest ...
3
votes
2
answers
8k
views
Selecting points within polygon and updating attributes using ArcPy?
I have two feature classes, a polygon of sales areas for a city, and point layer of addresses. I want to select the addresses based on the sales area they are in and update their attribute table to ...
3
votes
2
answers
4k
views
Using Select By Location to update field in feature class using ArcPy?
I am using Arc 10.1 and I am working on a script that takes a value from a field within one shape file and updates a field in another shape file based on its location. Basically I have smaller parcels ...
1
vote
2
answers
209
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
2
answers
4k
views
Comparing field values of two feature classes using ArcPy?
I have an intermediate fc #1 that contains data that I would like to append to my production fc # 2(final output). When working with the data, I would only like to append data from my fc # 1that is ...
19
votes
2
answers
3k
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
...
8
votes
5
answers
1k
views
How to access adjacent rows with cursor?
In the attached screenshot, the attributes contain two field of interest "a" and "b". I want to write a script to access the adjacent rows in order to make some calculations. To access a single row, ...
8
votes
1
answer
7k
views
Selecting specific row in attribute table using ArcPy (without iterating through whole table)? [closed]
I am using ArcGIS 10.2 and have assumed until now that it is possible to select a specific row in an attribute table. However, I can't seem to find a way to do this. The only available methods seem to ...
8
votes
3
answers
6k
views
Is it possible to sort an arcpy.da.UpdateCursor()?
I have an ArcPy Data Access update cursor that I would like to sort before making updates to it.
The cursor makes updates if I don't sort, but if I add a sort to the cursor I get an error, "...
7
votes
3
answers
5k
views
Cannot get rid of lock on file geodatabase and feature class created in Python script
I have a python script, (for ArcGIS 10), that creates a new file geodatabase, creates a new feature class in that file geodatabase and then reads data from an SDE feature class to populate the new ...
7
votes
2
answers
622
views
Removing duplicates from field using ArcPy with ArcMap
I am using ArcPy with ArcMap.
I need to remove duplicates from a field named "Intersecti"
Here is my code. I used list..set. It's not removing any duplicates.
import arcpy
duplicates = &...
7
votes
1
answer
15k
views
Using ArcPy update cursor to replace <Null> value?
I have been combing the help associated with (None) values in arc, and have not been able to solve the following problem:
I have a a field with mixed Null and integer values:
0
100
I would like ...
5
votes
3
answers
6k
views
Use Python to Find duplicate values in a feature Class and populate a field
So I found this python script on another post here and was trying to adjust it for my needs. I'm a very novice python user so I'm struggling with how to modify the script. I have a Feature Class ...
5
votes
4
answers
7k
views
Getting values of last row in table with ArcPy/SearchCursor?
I would like to base my query on the last row of a table? I know the basic syntax/functionality for my search cursor, how do I query only the last row;
Below is an example of my search criteria, ...
3
votes
2
answers
2k
views
Using Select Layer By Attribute in for loop with ArcPy?
I'm trying to iterate through a feature class and select each feature one by one by using the OBJECTID field. When I use a single value, the SelectLayerByAttribute works, but how do I compare the ...
3
votes
3
answers
5k
views
How to update the Z value using an UpdateCursor?
I have created the following script to mimic the ArcGIS 3D Analyst tool, FeatureTo3DByAttribute, which creates a 3D copy of a 2D feature class and sets the Z to a specified attribute.
import arcpy, ...
2
votes
0
answers
194
views
Compare two fields in different feature classes using ArcPy
I am trying to make an automation script to evaluate the distance and compare attributes between an incoming layer and another existing layer in the database.
I made this script to say:
If the ...
2
votes
2
answers
1k
views
Change specific rows in attribute table using Arcpy in ArcGIS 10.3
I need to change values in field "name1" (string field) in specific rows: 70-72 into "no land use" value. I search Arcpy code to do it.
i red How to select specific row in attribute table using ...
2
votes
1
answer
628
views
Combining wildcard command along with %s in where clause statement for ArcPy?
I am trying to write a script where the user can search for a five digit zipcode using an input statement and a search cursor. The zipcodes in the file though are nine characters long (i.e. xxxxx-xxxx)...
2
votes
2
answers
2k
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.
...
2
votes
1
answer
781
views
arcpy.da.UpdateCursor with sql_clause for artifically inverting cursor loops
Why is row not recognized within my update cursor?
The data is stored in a file geodatabase.
I am using ArcGIS Desktop version 10.1 ArcInfo License.
The screen shot shows the data "ORDER BY X ASC" ...
1
vote
2
answers
2k
views
Calculate Fields with Null Values using arcpy.da.UpdateCursor of ArcGIS for Desktop?
How do you calculate fields with null values? I have multiple fields that may have null values, that aren't being calculated in the third field.
import arcpy
with arcpy.da.UpdateCursor(r"...gdb\test....
1
vote
1
answer
194
views
Arcpy to append results of pivot table
I have a script that does some processing but the main part are two things
run a multiple ring buffer using arcpy.MultipleRingBuffer_analysis and four rings
do some zonal statistics using arcpy.sa....
1
vote
1
answer
694
views
Deleting the cursor object
Can someone explain why you need to delete the cursor objects and the iterator when you use for example:
arcpy.UpdateCursor(blah)
I've checked the esri docs and there doesn't seem to be an ...
0
votes
1
answer
512
views
Using LIKE clause in update cursor gives syntax error?
I am trying to write a second update cursor within one script. This requires a LIKE condition to look up a value within the same layer to identify rows to update the field within that layer (first ...
16
votes
1
answer
33k
views
How to delete selected rows using ArcPy?
I want to delete all rows in a feature class but remain rows 1 to 5. In other hand I want to remain first five rows and delete others. I know that I have to use search cursor and update cursor but I ...
11
votes
4
answers
7k
views
ArcGIS Python SearchCursor file locking?
I have a script that gets a value from a shapefile's field to return to the user.
It seems that only when the arcpy.SearchCursor is called ArcMap 10.0 locks the file and it doesn't get removed ...
10
votes
3
answers
15k
views
Creating polygon feature class from X,Y coordinates using ArcPy?
I am trying to 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 )....
10
votes
5
answers
1k
views
How to improve performance when using ArcGIS cursors in Python with big tables?
I have a pretty big point feature class in a file geodatabase (~4 000 000 records). This is a regular grid of points with a 100m resolution.
I need to perform a kind of generalization on this layer. ...
8
votes
2
answers
8k
views
Calculating XY coordinates in Decimal Degrees from projected dataset in model or script?
Is it possible to calculate points XY coordinates in Decimal Degrees in model or script when a feature class is in projected coordinate system?
It's easy when a FC is in geographic coordinate system:
...
8
votes
1
answer
2k
views
How to improve performance of nested search cursors?
I have three nested SearchCursors. It works correctly but with slow performance. There are some solutions to improve the searchcursor performance like dictionary but i don't know how to use it with ...
8
votes
2
answers
3k
views
Getting unique value of second field using arcpy.da.SearchCursor?
I have a feature class and using arcpy.da.SearchCursor I'm getting unique values of a field (e.g. Name). How can I use this method to get the associated row value of a different field (diff field = ...
6
votes
1
answer
2k
views
How to add Attributes to a polygon with arcpy
I have a question about arcpy. I want to create a polygon FeatureClass with attributes. The code below is just test-code that generates some polygons for speed testing. I want to add some additional ...
6
votes
3
answers
15k
views
Iterate through features to use selection as input for ExtractByMask
I need to iterate through each of the features of a feature class successively to use each one as the mask to extract from a raster with the ExtractByMask tool. Basically I'm looking for the "Iterate ...
6
votes
3
answers
9k
views
Extracting data using arcpy.da.SearchCursor?
I have a shapefile of point features showing fire locations in a given year. One of the fields is named "YYYYMMDD" and indicates the corresponding date that that fire happened. In Python, I am trying ...
6
votes
2
answers
6k
views
Does arcpy.GetParameterAsText() have a data type?
import arcpy
# Retrieve input parameters
inX = arcpy.GetParameterAsText(0)
inY = arcpy.GetParameterAsText(1)
inDescription = arcpy.GetParameterAsText(2)
incidentsFC = "C:/Data/Yakima/Incidents.shp"
...
5
votes
2
answers
3k
views
Using GROUP BY clause in arcpy.da.UpdateCursor
I need to specify a "group by" clause for UpdateCursor arcpy.da. From here I found out that it's possible to do using an optional pair of SQL prefix and postfix. But there are no examples and I'm ...
5
votes
2
answers
1k
views
Is it a bad idea to convert a File Geodatabase table to a dictionary?
First, what am I trying to do?
I am building a Python script that should be called from an ArcMap 10.0 toolbox. This scripts uses (among other inputs) data contained in huge gdb tables. It processes ...