Questions tagged [arcpy]

A site-package created by Esri to expose ArcGIS Desktop (ArcMap and ArcGIS Pro) geoprocessing, mapping, etc, to Python.

Filter by
Sorted by
Tagged with
74 votes
7 answers
13k views

When to use ModelBuilder over Python scripting and vice versa?

I am new to Python scripting in ArcGIS but not new to ModelBuilder. I would like to know the benefits of Python vs ModelBuilder. When should we write Python script for GIS automation rather than ...
  • 5,795
50 votes
5 answers
10k views

Debugging ArcPy scripts

I have written many Python scripts using ArcPy in ArcMap 10, and so far my only means of debugging is restricted to printing messages to the geoprocessing results window using arcpy.AddMessage(). Are ...
  • 7,315
39 votes
4 answers
7k views

Performance of ArcGISScripting and large spatial data sets

I am currently writing a python script using the arcgisscripting module to process a reasonably large data set (~10,000 records in total) normalised over a small number of tables, 8 in total. The ...
37 votes
2 answers
30k views

Learning ArcPy?

Where can I start to learn ArcPy?
37 votes
3 answers
28k views

What is the proper syntax and usage for ArcGIS "in_memory" workspace?

I am unclear how best to use the in_memory workspace in ArcGIS. The best resource I have found on the subject is from ESRI on Using in-memory workspace. Unfortunately, the help section is not very ...
  • 51.2k
37 votes
2 answers
23k views

Fastest way to count the number of features in a feature class?

With the introduction of the Data Access module in arcpy (30x faster search cursors), I want to know if counting features matching sql criteria is faster than the traditional MakeTableView + GetCount ...
33 votes
6 answers
3k views

Sharing Open Source Python/ArcPy Code and Models for ArcGIS Desktop?

I will be writing scripts for ArcGIS Desktop in Python with ArcPy. Is there a community or open source project where code and models can be shared?
32 votes
2 answers
3k views

Streamlining Python Code for Big Data

I have Python code which is designed to take point shapefiles through the following workflow: Merge points Integrate points, such that any points within 1 m of each other become one point Create ...
  • 51.2k
31 votes
6 answers
54k views

Getting ArcPy to work with Anaconda?

I am trying to follow the step-by-step directions in the answer to "how to separate Python installation with ArcGIS" but cannot find the path file, DTBGGP64.pth, in C:\Python27\ArcGIS10.2\Lib\site-...
  • 695
31 votes
6 answers
4k views

How to buffer raster pixels by their values?

The pixels to the left represent tree locations and their associated crown radii (i.e. pixel values ranging from 2 - 5). I would like to buffer these raster pixels by their crown radius value. The ...
  • 51.2k
30 votes
6 answers
22k views

Ways to Speed Up Python Scripts Running As ArcGIS Tools [closed]

This is a pretty general question. I just wondering what tips and tricks GIS programmers have used to speed up arcpy scripts that you import into the toolbox and run. I work most everyday writing ...
  • 4,377
29 votes
6 answers
28k views

Defining projections for multiple shapefiles in ArcMap?

I have over 100 shape files that don't have .prj file and thus when I bring them into ArcMap 10 they show the coordinate system as unknown. I know all of the shape files coordinate system is GCS WGS ...
  • 1,699
28 votes
3 answers
9k views

Why learn/use Python Toolboxes over Python Script Tools? [closed]

I've written a few Python Toolboxes (which are new at ArcGIS 10.1), but am yet to decide whether/when I should write them rather than Python Script Tools in a standard toolbox. I thought the Online ...
  • 64.5k
28 votes
4 answers
16k views

Making separate Python installation that can call ArcPy?

I see a lot of Q&As asking how you can create a separate Python installation (e.g. the Anaconda or Python XY distribution) that can use arcpy, while not 'breaking' the original ArcGIS python ...
  • 2,208
27 votes
4 answers
41k views

Listing all feature classes in File Geodatabase, including within feature datasets?

From python how can I build a list of all feature classes in a file geodatabase (*.gdb), including inside feature datasets? The standard example only lists feature classes at the top level of the ...
  • 27.9k
26 votes
5 answers
8k views

Using ArcGIS functionality in Python without running ArcMap (e.g. separate editor/environment)?

I'm trying to take the next step in programming ArcGIS with Python and see if its actually possible to run my script/code without having to load ArcMap and paste them into the Python window. I imagine ...
25 votes
1 answer
9k views

How to get size of file geodatabase feature class on disk?

Is there a simple way to determine the amount of hard drive space a feature class takes up? I feel like I'm missing something simple, but I don't recall a method that does so. You would think that ...
  • 7,315
24 votes
5 answers
26k views

Including variable in where clause of arcpy.Select_analysis()?

I am trying to loop through a shapefile, selecting each feature in turn and copying it to a temporary shapefile to by included in a union analysis. I'm using a cursor to find the ID name for each ...
  • 1,062
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 ...
  • 243
24 votes
6 answers
7k views

Making GIS inventory using ArcPy

My office will be seeing a big change in its GIS section. This section has been operational since the 1980's and has a huge collection of GIS data (i.e., shapefiles, raster files, data, etc) but never ...
  • 785
24 votes
4 answers
38k views

Running Python scripts (with parameters) within another Python script with ArcPy?

A common coding pattern used in AML was to run an AML (with parameters) inside another AML. An application that I'm currently developing would benefit from being able to run a Python script (with ...
  • 64.5k
23 votes
2 answers
30k views

Getting list of selected features in ArcGIS for Desktop using Python code?

I have a question regarding selections in ArcGIS for Desktop. Assumed I have one layer in ArcMap and I have selected two of five features. Is it possible to get a list of all selected features by ...
  • 812
23 votes
5 answers
25k 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\...
  • 7,904
23 votes
3 answers
11k views

Adding new group layer with ArcPy?

Does anyone now how to add a group layer with Python in ArcGIS Desktop 10? I can use arcpy.mapping.AddLayer but surely this is only for an actual layer as opposed to a group layer. so far I have ...
  • 321
22 votes
3 answers
6k views

Do ArcGIS SpatialReference object factory codes correspond with EPSG numbers?

I've got a project where I'm reading in geometry objects from text files to put them in ArcSDE. These geometry objects have an associated EPSG code, and I'm looking for a way to ensure they're in the ...
  • 15.5k
22 votes
2 answers
39k views

Adding shapefile or feature class as layer in ArcMap using ArcPy

I am trying to automate various tasks in ArcGIS Desktop (using ArcMap generally) with Python, and I keep needing a way to add a shapefile to the current map. (And then do stuff to it, but that's ...
  • 429
22 votes
3 answers
3k views

Running Python Script when opening MXD?

Can anyone tell me how to accomplish this? I want a Python script to run on opening the MXD which would pull an excel worksheet into a GDB and refresh the map. I only want this to happen in this ...
  • 321
21 votes
6 answers
9k views

Documentation for ArcPy site-package?

Has anyone found any informative documentation about Esri's ArcPy Python module?
21 votes
2 answers
6k views

Using ArcPy to determine ArcMap document version?

Is there a way with ArcPy to identify the version of a Map Document (MXD). I am working on a solution to inventory our MXD's and would like to know if a document is 8.1, 9.2, 10.0, etc. I am ...
  • 22.9k
21 votes
4 answers
5k views

Applying four colors theorem in polygon map using ArcMap

I need to apply the four colors theorem in a polygonal shape in a way that I do not need to choose manually each color to put in each region. I wish to knows if there is any extension, plug-in, script ...
  • 313
21 votes
3 answers
11k views

Finding angle between intersecting features in two feature classes using ArcGIS Desktop and Python [closed]

I have two intersecting line featureclasses. I want to find the angle at each point of intersection using ArcGIS 10 and Python. Can anyone help?
  • 211
21 votes
1 answer
5k views

How to Split a Concave Polygon Into Convex Polygons in Arcpy?

I'm looking for a tool or algorithm to detect concave polygons and split them into convex polygons. Like explained in the picture, the blue polygon is split into A and B polygons I'm using Arcpy ...
  • 4,530
20 votes
3 answers
11k views

Casting ArcPy result object from arcpy.GetCount_management() as integer instead?

I am using ArcMap 10.1. I am trying to get a number by counting how many points are in a shapefile. And this works, except I then am running into trouble using that number somewhere else. Eventually, ...
  • 8,936
20 votes
7 answers
5k views

Code-completing/auto-completing ArcPy scripts using Notepad++ (external editor)?

I have been scripting in Python for ArcGIS 10, and so far I have just been using Notepad++. I like how the Python command line interface code-completes arcpy functionality for you, showing you your ...
  • 7,315
20 votes
4 answers
21k views

Using ArcPy to zoom to selected feature?

Is there a way to zoom to the extent of a selected feature using the ArcPy module in ArcGIS Desktop 10.
  • 6,142
20 votes
8 answers
50k views

How to manually break statement execution in Python window of ArcMap?

How does one break the execution of a long-running process in the python console of ArcMap? For example, how do you break a long iteration like the one below once it is started? for i in range(1, 50)...
20 votes
1 answer
6k 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 ...
  • 3,999
20 votes
1 answer
2k views

ArcGIS 10.1 Python AddIn Using Multiprocessing crashes ArcMap?

I would like to run a multiprocessing task from a python add-in tool. My issue is that the process keeps failing. Basically crashes ArcMap. Here is my basic code: def function(startOID, endOID, fc)...
19 votes
7 answers
13k views

Listing feature classes with active domains?

I have an Esri file geodatabase with attribute domains defined. I need to delete some of the attribute domains but can't because "The domain is used by an attribute rule.". How might I discover which ...
  • 27.9k
19 votes
5 answers
7k views

Comparing two geometries in ArcPy?

I am trying to compare two separate feature classes to identify differences between them (sort of a diff function). My basic workflow: I extract the geometries using a SearchCursor Save the ...
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 ...
  • 51.2k
18 votes
5 answers
22k views

Trying to extract a list of Unique Values from a field using python

I have a number of columns in a number of tables withinh a FGDB where I need to extract the unique values for each column. For Example: the values may be [1,2,2,2,3,4], and I am trying to return [...
18 votes
1 answer
29k views

Calculate area within Python script in ArcMap

I am trying to calculate the area of a polygon within my Python script. I create a new polygon from merging two together, and I'd like to add the area of the resulting polygon to a field in the output ...
  • 4,920
18 votes
1 answer
4k 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 ...
  • 6,590
17 votes
4 answers
7k 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 ...
  • 357
17 votes
3 answers
7k views

Using ArcPy to get layer symbology?

Since ArcGIS 10 comes with the ArcPy package, I'm wondering it is possible to use ArcPy functions to get Symbology (i.e color, width...) of a layer?
  • 1,470
17 votes
3 answers
3k views

Refreshing imported modules in 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 ...
17 votes
1 answer
7k views

Self terminating Python script in ArcMap?

I have tried sys.exit, but it doesn't seem to work in ArcMap 10. Anyone know how to do it?
  • 7,315
16 votes
3 answers
4k views

Porting Avenue code for Producing Building Shadows to ArcPy/Python for ArcGIS Desktop? [duplicate]

Whuber provided an answer at Producing building shadows using ArcGIS Desktop? which required using Avenue code. Any idea how to make it work in ArcGIS Desktop 10?
16 votes
4 answers
20k views

Selecting features by attribute if in Python list?

I am trying to complete a select by attribute in Python but based on the query of whether an attribute is present in a list. Such a query at its simplest should be something like this: qry = " \"...
  • 475

1
2 3 4 5
208