A site-package created by Esri to expose GeoProcessing from ArcGIS to Python.

learn more… | top users | synonyms (7)

13
votes
1answer
2k views

Displaying raised error messages to user in ArcGIS Geoprocessing Results window?

Can print statements raised from a custom exception be displayed in the Geoprocessing Results window? I modified a script that I found that takes two inputs from a user, finds the associated feature, ...
13
votes
1answer
1k views

How can I utilize NumPy arrays to optimize big data geoprocessing?

I'm interested in learning how to utilize NumPy arrays to optimize geoprocessing. Much of my work involves "big data", where geoprocessing often takes days to accomplish certain tasks. Needless to ...
12
votes
3answers
1k views

Industry-based examples of using ArcPy in Python for Geoprocessing?

I was asked recently by some students what types of operations GIS Analyst/Developer are usually trying to automate by using Python with geoprocessing in ArcGIS and ArcPy site package. I guess it ...
12
votes
1answer
451 views

Is there ArcPy tool for polygon resizing like Scale tool of Advanced Editing toolbar in ArcMap?

I am writing a python script for ArcGIS 10.3. I know about Scale tool in ArcGIS interface but I can't find such arcpy command. It exists? As you can see on the picture the Scale tool works different ...
12
votes
2answers
1k views

Is there a way to refresh imported modules in a ArcGIS Python Toolbox?

When using a python toolbox (.pyt) in ArcMap, I'll typically follow a pattern where the .pyt file itself is simply a wrapper to collect input arguments and define the tools themselves. Supporting ...
12
votes
5answers
2k views

Efficiently finding the 1st order neighbors of 200k polygons

For every one of the 208,781 Census block groups, I'd like to retrieve the FIPS IDs of all of its 1st order neighbors. I have all the TIGER boundaries downloaded and merged into a single 1GB ...
12
votes
1answer
3k views

Guidelines for organizing Python Toolboxes (.pyt) in ArcGIS

For one of my tasks I need to create a Toolbox with three tools (python scripts). Instead of ordinary tbx I've decided to write it as Python Toolbox (pyt). Everything is clear except the "good" way ...
12
votes
2answers
9k views

How to export only certain columns to a CSV file in ArcGIS?

I've written a python script using arcpy which outputs a polygon feature class into a File Geodatabase. I have added a function to export the attributes to a separate CSV file. I am using the code ...
12
votes
1answer
368 views

ArcPy adds erroneous interior ring when writing adjacent, multipart geometry?

I've run into an odd issue when using Arcpy to write multipart geometry to a shapefile. I am using an InsertCursor to create a multipart feature from a list of parts each with a list of vertex pairs. ...
12
votes
0answers
525 views

Writing Python script for ArcGIS to square polygon corners? [closed]

I'm looking for a script that will square the corners of polygons that are near 90 degrees but not exactly. Near could be dealt with via a variable, for example within 5 degrees of 90 (85 - 95 degrees)...
11
votes
2answers
5k views

How to read Excel sheet in ArcPy script?

I'm writing a python code to convert X,Y points in excel to shapefile. In this process i have toread xy points from shhet1. What is the step i have to include in my process to read data from sheet1 of ...
11
votes
2answers
3k views

Methods for optimizing multcore processing in ArcGIS

I am interested in learning methods to utilize the full extent of multicore processing power available on a desktop computer. Arc states that background geoprocessing allows the user to utilize ...
11
votes
2answers
3k views

How do you delete an in-memory Table View?

In a Python script, I'm cycling through thousands of Excel files and using arcpy.MakeTableView to create in memory table views from the first spreadhseet in each file. How do you delete the reference ...
11
votes
2answers
4k views

Efficiently selecting related records using ArcPy?

Below is the code I'm using to replicate the "related tables" button in ArcMap. In ArcMap that button selects features in one feature class or table based on the selection of features in another ...
11
votes
1answer
6k views

“Field Mapping” in ArcGIS 10 - ArcPy

I've wrote a Python script that does a spatial join and some simple calculations. My problem is with setting the merge rule for one specific field, and leaving the rest of the fields as is. For ...
11
votes
2answers
12k views

Changing data source path involving feature dataset in *.lyr files using ArcPy?

How can one change the source data paths for every layer file in folder X using arcpy? I've followed Updating and fixing data sources with arcpy.mapping as best I can, yet all I get is an unhelpful ...
11
votes
1answer
692 views

Teaching Python to Land Surveyors

Does anyone have any good examples of using Python to automate or simplify common surveying tasks? I'm teaching a Python/ArcPy lab this week for a GIS class. There are a number of surveying ...
11
votes
1answer
7k views

Use python to add layers to TOC

I've been battling with adding layers to the TOC for some time now. I have managed to single layers added but need to loop through a folder and add all layers. Shapefiles I cannot get to add at all. ...
11
votes
4answers
4k views

ArcGIS 10.0 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 locks the file and it doesn't get removed after the ...
10
votes
5answers
11k views

Remove feature layer using ArcPy script?

I have an ArcPy based script where I'm trying to intersect two layers where one layer must have its centroid in the other layer. Since I need to know that one layer (feature_layer below) includes ...
10
votes
2answers
2k views

Why is this simple arcpy script so painfully slow?

I have a simple arcpy script to update a field in a point shapefile with info from the polygon feature that it is within. It takes 9 minutes to do 100 points in arcpy but a spatial join in arcmap is ...
10
votes
3answers
14k views

Creating shapefile from lat/long values using ArcPy?

How can I create a shapefile using Python in ArcGIS 10? I have lat & long. From this I need Python code which will create a shapefile in ArcGIS Desktop 10.
10
votes
2answers
6k views

Creating line of varying distance from origin point using Python in ArcGIS Desktop?

I'm trying to create a line feature from a single point, using a set distance and angle. Using ArcGIS and Python (I hope). I have a point at these coordinates: X = 400460.99, Y = 135836.76 From ...
10
votes
2answers
5k views

Finding mid-point of line using ArcPy?

How can the mid-point of a polyline be calculated using the geoprocessing framework, e.g. in a Python script? The polyline.centroid property returns The true centroid if it is within or on the ...
10
votes
4answers
9k views

Get all the points of a polyline

I have some polyline feature objects in python. Now I want to get all the points of polylines. For example, if a polyline has start point [0,0] end point [5,5]. Result: [1,1];[2,2];[3,3];[4,4];[5,5]...
10
votes
5answers
796 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. ...
10
votes
1answer
3k views

Creating table containing all filenames (and possibly metadata) in File Geodatabase?

I need to create a metadata-table for all files in a File Geodatabase or Spatial Database. Is it possible to automatically be updated with new filenames, and possibly even metadata (as created in ...
10
votes
6answers
1k views

Is there a faster way in python of finding the smallest number in a field?

Using arcgis desktop 10.3.1 I have a script which uses a search cursor to append values to a list and then use min() to find the smallest integer. The variable is then used in a script. The Feature ...
10
votes
2answers
405 views

Create area buffers that are limited by a coastline

I'm trying to use ArcGIS 10.2 to create a buffer of points based on a pre-defined area (e.g 400 sq km). Further to that, the buffers of some of the points are close to the coastline that requires the ...
10
votes
2answers
261 views

Retrieving size of shapefile in ArcPy?

Is it possible to retrieve the size of a shapefile using python and arcpy? If so, how?
10
votes
2answers
1k views

Computing new attribute based on changes in another attribute using ArcGIS Desktop with Python?

I am attempting to classify a set of gps time-encoded point data into behaviors based on different attributes. I have created an attribute that is 0 for home and 1 for away based on location, and ...
10
votes
2answers
3k views

Is there a ArcGIS python script development API?

I'm a somewhat experienced software engineer new to the GIS world. I started working on a GIS project that supports ArcGIS 9.3 and 10.0 and looking through existing code it looks like the main ...
10
votes
3answers
3k views

How to reclassify a very large land cover dataset?

Consider the NLCD2001 Land Cover dataset for Alaska (download link). I need to reclassify this dataset so that only pixels of value 41, 42, and 43 are preserved; all other pixel values should become ...
10
votes
1answer
3k views

How to create sidebar help information for Python script tools of ArcGIS Desktop?

I have been creating custom tools (Python script tools) using Python with the ArcPy module. I can set up the tool successfully with parameters and all, but I cannot figure out how to create help ...
10
votes
2answers
2k views

How to keep spatial reference using arcpy.RasterToNumPyArray?

I am using ArcGIS 10.1, and want to create a new raster based on two preexisting rasters. The RasterToNumPyArray has a good example which I want to adapt. import arcpy import numpy myArray = arcpy....
10
votes
2answers
338 views

Count raster value in a bounding box (spatial extent)

I have simple question: given a bounding box, how can I count the number of specific values (say, I am interested in the number of value == 1 ) in a raster in 1) arcpy, or 2) raster package in R?
10
votes
2answers
2k views

Inserting newlines in Rectangle Text elements via ArcPy causes overlap?

I ran across an issue the other day when I tried to use ArcPython's mapping module to edit rectangle text elements with newlines (\n) in an ArcMap document. Here's what the output looked like: ...
10
votes
3answers
583 views

How to determine storage type (ST_Geom/Oracle) from arcpy/python

We're migrating some feature classes from SDELOB (or some older binary format) to ST_Geometry. As we write our arcpy script to use the ESRI Migrate Storage Tool we'd like to test whether or not ...
10
votes
1answer
248 views

ArcGIS Pro and ArcGIS Desktop on same machine

I'm just trying out ArcGIS Pro for the first time and I had to change my PYTHONPATH to python34 ArcGIS Pro is now working without crashing every time I open the Analysis tab... However now when I try ...
10
votes
4answers
3k views

Inserting points into SQL Server using pymssql?

I am collecting X and Y values from a web service (Twitter) via a python script. In the long run, this will run over a period of months and I intend on stopping at around the 6 million point mark. ...
10
votes
1answer
489 views

Is there a way to use ArcPy and PyGRASS tools in the same Python script?

I´m trying to write a Python script, that includes different ArcPy / ArcGIS commands and want to combine it with GRASS geoprocessing tools. Unfortunately importing the GRASS libraries doesn´t work. ...
10
votes
1answer
1k views

arcpy.geometry __geo_interface__ and AsShape() function: loss of precision and holes

I'm serializing my arcpy geometries as geojson so that I can 'hydrate' them back as geometries later and I'm having 2 problems in the cycle.: PROBLEM 1: Precision R0 = arcpy.SearchCursor(self....
10
votes
1answer
4k views

Python Script to Create Table Using Data Driven Pages

I am trying to convert some python script to display a table (based on a dbf) of features located within a specific data driven page. So far, I have the script successfully able to refresh the map to ...
10
votes
2answers
930 views

Metadata -auto build using python

We have a large (10,000 plus) repository of spatial data (shp/gdb/tab vectors and ecw/tif rasters and also las, xyz and DEM data) where some have metadata records in xml using anzlic metadata editor. ...
9
votes
1answer
4k views

Cast arcpy result as an integer instead (arcpy.GetCount_management)

I am trying to get a number by counting how many points are in a shapefile. And this works (I think), except I then am running into trouble using that number somewhere else. Eventually, I'll be using ...
9
votes
4answers
6k views

How to convert geometry to WKT using ArcPy?

I would like to be able to convert a single feature (or potentially many features) in an ArcGIS layer into Well Known Text (WKT) format during a geoprocessing operation using Python and ArcPy (no non-...
9
votes
3answers
3k views

Defining parameter descriptions for Python Toolbox help?

I'm trying to create some Python Toolboxes for our ArcMap application (e.g. MyTool.pyt) I can see that the help text is defined with the classes self.description attribute. However, once I run the ...
9
votes
2answers
2k views

How to bypass errors in arcpy for/while loop?

I have a handy script tool that loops through a workspace and renames and copies shapefiles to a feature dataset. However, if there is a corrupted shapefile somewhere in the workspace the script ...
9
votes
2answers
2k views

How to access Esri ArcPy modules from Enthought Canopy?

I have ArcGIS 10.1 running on my windows system and I have also installed the new 32-bit Canopy Express Enthought Python Distribution. Is it possible to load and use the Esri ArcPy modules from ...
9
votes
1answer
6k views

How to add feature class to MXD with ArcPy (Python)? [duplicate]

I am using ArcGIS 10.1 and I am trying to add a feature class that I create to an MXD, so that I can join to it. This all needs to be done using Python. Is this possible?