Calculating fields using a list of features
I’ve written some basic code which creates a new .dbf and adds two fields to it: 1 for today’s date, another which should contain the names of shapefiles located in another folder. What I’d like to do...
View ArticleArcPy inconsistently accepts SQL queries for MakeFeatureLayer or...
I need to buffer a subset of features in a particular feature class. To do this, I am first creating a feature layer (using a SQL query to select only what I want), and then running Buffer. So my ArcPy...
View ArticleSave fails on raster object created from NumpyArrayToRaster
I am trying to save an ESRI grid built from a numpy array and am getting an error I’ve never seen before: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly...
View ArticleHow does the deactivate function of an ArcGIS Python Add-in Tool work?
I have not been able to figure out how the deactivate function of a Python Add-in Tool works in ArcGIS. The help page that mentions the function, and that it ’causes the tool to no longer be the active...
View ArticleTIN to Raster – specify raster's origin
How could I specify raster’s origin, while using arcpy.TinRaster_3d?
View ArticleImporting external bookmark (.dat) files into many MXDs using arcpy?
Does anyone know any python script to use for arcview to import a bookmark (saved as a .dat) that was created and saved externally using ArcMap? I tried with this script but without a result: import...
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 Articlearcpy.AsShape function returning RecordSet not Geometry
I have the following code: feature_geometry = arcpy.AsShape(json_string, esri_json=True) print feature_geometry print type(feature_geometry) >>><geoprocessing record set object object at...
View Articlequeue.empty error when using search cursor
I’m having trouble with an error message and can’t seem to figure out the reason which, I’m sure is something simple. I have a bit of code listed below: insertPts = arcpy.da.InsertCursor(newFC, (...
View ArticleArcGIS Erase Function in Python
Aplogoises if this has already been solved but I’m having problems using the Erase function in ArcGIS. I have had problems using the normal function, as it throws a Error9999 Topology error amongst...
View ArticleWhat causes ValueError: I/O operation on closed file?
I obtain the following error message: ValueError: I/O operation on closed file Here is my code (It selects each polygon contained in the shapefile “selected_polygons.shp” and builds the least-cost path...
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 ArticleUpdating file geo database table
I have an input csv file that I process using a python script and generate a new output csv file. I then, in the same python script use Table to Table (Conversion) in order to store the data from the...
View ArticleRunning ArcGIS Data Reviewer using ArcPy?
I want to run the ArcGIS Data reviewer in Python code, to check domains. My scenario is check the attribute values if its meet the domain value. Is it possible to run ArcGIS Data Reviewer in Python...
View ArticleClip a shapefile based on raster extent with high accuracy
I am trying to clip a shapefile based on the extents of a smaller raster. I find the extent of the raster using this code: Extents = arcpy.sa.Raster(MyRaster).extent` Then, I use these lines to make a...
View ArticleControlling page count increment of Data Driven Pages using ArcPy?
I was wondering if there is a way to add coding to Data Driven Pages with python. I would like to be able to take the “Data Driven Page with Count” and increment the count by one or in some cases two....
View ArticleSpecify a GDB feature class using Python Tkinter dialogue box
I tried to specify a feature class from a GDB dataset through Python Tkinter tkFileDialog.askopenfilename. Below is the script. It worked for me in the past when I was dealing with .txt or .las files....
View ArticleChange sde connection parameters with ArcPy
I know you can create a database connection with Arcpy using the CreateDatabaseConnection_management function. I am wondering if anyone knows a way in which to change the parameters of that file. For...
View ArticleCalculate field using variables as fields
When I calculate a field like this: field_0="field_name0" arcpy.CalculateField_management("Layer", field_0, '!field_name1! / !field_name2!', "PYTHON_9.3") It works! The field “field_name0″ in the...
View ArticleBatch enabling MapTips
In the layer properties of each layer there is an option “Show MapTips using the display expression” that is by default disabled and I would like to find out if there is a way to enable this option by...
View Article