Using a Search Cursor with a list
I’m hoping someone knows the answer to this as I am pretty new to Python. What I’m attempting to do is create a list of .dbf tables using a wildcard which I’ve managed to do. From there my goal is to...
View Articlearcpy: changing lyr data source (raster layers)
I am trying to create a lyr file for each raster file in a folder. To get exact same display settings I thought I would create a lyr file, then, using arcpy copy-paste it for each file in folder and...
View ArticleArcpy Subtracting rasters error – TypeError: 'unicode' object is not callable
I have a script which subtracts 2 versions of the same raster from each other (one newer than the other) and then extracts the additions & deletions that have happened. I created a simple test...
View ArticleArcGIS arcpy code fails in Toolbox mode
This code executes correctly in Python window but fails with ERROR 000732: Input Table: Dataset JHJ does not exist or is not supported # Import ArcPy and other required modules import arcpy from arcpy...
View ArticleHow to get the name of a subtype field in a feature class in Python?
I have a geodatabase with many feature classes. Some of the feature classes have subtype fields. Their names vary feature class by feature class. I now want to find the names of those subtype fields....
View ArticleArcGIS 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_ScriptsandToolsPullHotParametersLabel.py”, line 16, in TitleLine = “”+row.getValue(IDfield)+” (“+...
View ArticleHow is the data access cursor performance so enhanced compared to previous...
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 data. It...
View ArticleWhat's the best way to get the OBJECTID name?
What’s the best way to get the OBJECTID name of a feature class? I know you can use “OID@” in a cursor to get the field, but can you get the name from that as well? I’m writing a script, and need to...
View ArticleHow to copy selected features from one sde feature class to another with...
I am new to Arcpy scripting, I need help on copying the features to SDE feature class. My Scenario: We have 2 Geo databases running on Oracle 11g ArcSDE 10.2 . I have been asked to write the python...
View ArticleHow to get Last ObjectID of feature class using ArcPy?
I have a feature class and I need to know the ObjectID of its last record. What is the best way to find out last ObjectID? Opening a search cursor and reading all the records is one way, but is there...
View ArticleHow do I change graduated color class values with python?
I am trying to use python to adjust my graduated color symbols’ class breaks and labels. The layer is a query layer tied to an SQL DB and I want to be able to execute my python (after the database has...
View ArticleHow to merge Shapefiles from multiple folders into Geodatabase Featureclass?
I have a question regarding the merge of a lot of folders, which has a lot subfolders, which has the shapefiles stored. I would like to merge all those in one geodatabase. So I thought to use a Python...
View ArticleHow to generate automatically the name of output parameters in a python...
I have some Python script tools in ArcGIS for Desktop. I need to reproduce what all geoprocessing tools do when the first input parameter is introduced: autogenerate a workspace and basename for the...
View ArticleHow to resolve ERROR 010271: Raster does not have an attribute table?
From my code which builds least-cost paths between several polygons by using the functions “CostDistance” and “CostPath” of ArcGIS , I obtain this error message: ExecuteError: ERROR 010271: Raster...
View ArticleHow to turn on all fields before appending?
I’m using append on model builder, no test schema type. In order that field will match they need to be at the same order, and visble. How can I turn on all fields of input layer before appending inside...
View ArticleUsing Alter Field tool of ArcGIS for Desktop on shapefile?
According the ArcGIS 10.2.2 help this should work: inZoneData = sys.argv[1] # This is a shapefile fieldList = arcpy.ListFields(inZoneData) for field in fieldList: if field.name.upper() == 'STATUS': #...
View ArticleUsing da.SearchCursor to get count of unique values in a field
Is it possible to use arcpy.da.SearchCursor() to get a count of unique features in a field without a dictionary? So, by this I mean if I have a field called TEXT which contains 10,000 rows populated...
View ArticleCopy multiple features in feature class, update field value based on number...
I have created a field which will indicate the records I want to alter. What I want to do is then cycle through these records, each will contain sum values in a field.Based on the sum I want to copy...
View ArticleCause of Error 000308: Invalid Field Type when batch running ArcPy script?
This is my first post on this site. I am using ArcGIS 10.2 for Desktop. I wrote a simple script in the form of a python toolbox to calculate the speed of travel between consecutive entries of a point...
View Articleraster to polygon conversion
I ‘m trying to automate the conversion of raster to polygon and the rasters files are in “TIF” format which is a “unsigned integer”. I have the code below. However, I ‘m getting an error while...
View Article