Error: 'NoneType' object is not iterable (arcpy.ListRasters)
I am trying to extract a raster through a particular shapefile. import arcpy from arcpy import env from arcpy.sa import * arcpy.CheckOutExtension("Spatial") env.overwriteOutput = True #Set the current...
View ArticleUsing arcpy, update value in one field based on value in another
I am creating a level of service tool and I need to update the number of lanes field based on the operation type of the road. What I need it to do is: if the operation type equals 2W, then the number...
View ArticleMultibuffer in arcpy is too slow?
I have to make multibuffer to a several shp’s (30 or +) and with this code the it takes 30 minutes or more. import arcpy,time,glob,os def multibuffer (probe,Zona_trab,nombarch3,recortes2): x=0 bufdef =...
View ArticleCreate Table from Selection
This is a continuation of a problem that was solved earlier this week. The code below performs a select by location and was originally intended to export all feature classes from the SDE database to...
View ArticleSplit one field into 3 fields?
I need to split the values in a field according to what they represent to be able to do a join on the data. As seen above I have a ID field that needs to be split into the following: The ID consist of...
View ArticleAlter Fields in multiple feature classes in multiple workspaces
I have 22 geodatabases all in one folder. Each gdb has two feature classes. For each feature class, I need to rename a few of the fields. I’ve had success with this code, but it only works for each GDB...
View ArticleCreating TIN, Surface Difference python script with ArcPy?
I have been trying to develop a master script to go through a series of geoprocessing tools and executing them. I am trying to generate a TIN and contours from a raw xyz file. Below is a very simple...
View ArticleExporting ArcSDE feature classes into file geodatabase with ArcPy?
I would like to use Windows task scheduler to automatically (monthly) create a new file geodatabase and then export feature classes from SDE into the new file geodatabase. Im using this code, however I...
View Articlearcpy.da.UpdateCursor – How to update last column from Field Name List?
examples: for field in arcpy.ListFields(fc): if field.name != 'Hi': arcpy.AddField_management(fc, 'Hi', 'FLOAT') else: print "kolona Hi vec postoji" with arcpy.da.UpdateCursor(fc, (fieldNameList)) as...
View Articlearcpy.da.UpdateCursor – how to make multiplication of each column with the...
If I have a table with a number of columns [col1, col2, col3 ... col_n] how to perform multiplication of each column with one selected column, for example: multiplication = col1 * col_def, col2 *...
View ArticleMultiprocessing with arcpy and Solar Analyst (spatial analyst)
I need help getting multiprocessing to work with the spatial analyst tool – Solar Analyst. I have tested the multiprocessing bit and it works fine. This sample is passing it a file containing 2 lines...
View ArticleUsing a for loop to execute a query in arcpy
I’m trying to provide the breakdown of fire detection for an area by sorting of confidence levels. The dataset has 12 files (one for each month in a year) with fire records which all have a column...
View ArticleGeodatabase affecting outcome
Why does my naming convention change depending on where the output is saved? When I save this to a .gdb, the name of the output is “tif”, not final_mosaic.tif. When I save the same output to a regular...
View ArticleArcpy if statement to act on layers at the top level of hierarchy
I am about to save copies of all of the layers in my mxd. I only want to save the top level group layers though. I have some group layers within group layers – I dont want to save them individually. So...
View ArticleHow to get layers created in a custom toolbox python script to add to the mxd
I’m trying to create a simple search tool so that my colleagues can easily query a database. My first version is like this. mxd = arcpy.mapping.MapDocument("CURRENT") df =...
View ArticleSearchCursor Index Out of Range
I’m using ArcGIS 10.2 and trying to obtain values in a field using SearchCursor. Would someone help me with this? import arcpy oc = r"C:UsersScratchoc.shp" catchments =...
View ArticleMakeFeatureLayer_management where_clause input by the user
I want to convert a script into a toolbox and one of the parameters is selecting cities with a population > than 500000 hab. I’m using the function MakeFeatureLayer_management. How can I do to...
View ArticleUsing Loop function with arcpy.Exists()?
I have a code snippet using elif that checks if a file exists and continues to check through the letters of the alphabet (for example _A, _B, _C etc). All works fine but I think there must a better (or...
View ArticleHow to write to a single table via Python multiprocessing
A comment in the post Can multiprocessing with arcpy be run in a script tool? got me thinking, as I often need to do exactly this: Just beware of deadlocking situations (two Insert cursors in the same...
View ArticlePython – Projecting different shapefiles in the same folder
I have a few shapefiles in one folder with different coordinate systems but would like to use one of them as a template dataset. Is there a way to use python to filter out the shapefiles already in the...
View Article