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
15
votes
3answers
12k views

Exporting only certain columns to CSV file in ArcGIS for Desktop?

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 ...
15
votes
3answers
5k views

Selecting ArcSDE polygon by point in ArcGIS Desktop using ArcPy?

I keep thinking that I must be missing something, but there does not seem to be a tool in ArcGIS 10 to select features (in particular polygons) from a layer at a point (X,Y) location via ArcPy. The ...
15
votes
1answer
905 views

Understanding why ArcPy Cost Path Analysis tool faster than ArcObjects? [closed]

Although I use python to create geoprocessing scripts/services, I was under the impression that using ArcObjects to do the equivalent operation(s) will have better performance. I've posted ArcGIS ...
14
votes
6answers
15k views

How to randomly subset x% of selected points?

What methods are available in ArcGIS 10.2 to randomly subset a selection of points. For example, in the attached screenshot I am interested in keeping 20% of the selected points and deleting the rest....
14
votes
5answers
18k views

Changing feature class and field aliases in bulk using ArcPy?

I have over a hundred FCs, each with 10 or 20 attributes to add or change the aliases for, two or more times a year. Needless to say, this is not something I'm going to grunt my way through. How can I ...
14
votes
1answer
554 views

Splitting Polygons at midpoint using ArcPy?

I'm attempting to split around 4000 polygons at their midpoint, perpendicular to their longest axis (ie across the width at the midpoint), as in the diagram below. Ideally, I'd like to do this ...
14
votes
5answers
553 views

Working as a Python Development Project Team with ArcGIS?

We have a development project in Python (ArcGIS 10). This project involves a mixture of toolboxes, map templates, layer files, file geodatabase templates (acting as templates being imported into a ...
14
votes
2answers
6k 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 ...
14
votes
5answers
3k 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 ...
14
votes
1answer
4k views

Repairing data sources in multiple MXDs using ArcPy?

I have about 50 mxd's with all broken layers that I have been going through and manually resetting. The data was moved from another computer and the folder structure was changed so it isn't just a ...
13
votes
4answers
6k views

Extracting number of vertices in each polygon?

I have ArcGIS Desktop 10.2 and my challenge is how to extract the of number vertices in each polygon for all features like this: I have many parcels in my feature class and I want to extract the ...
13
votes
4answers
5k 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 ...
13
votes
4answers
11k views

Converting 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-...
13
votes
4answers
8k views

Developing GUI in Python for ArcGIS geoprocessing using PyQT/Tkinter/wxPython?

I want to develop a GUI in Python for ArcGIS geoprocessing. Can I use PyQT for GUI programming in ArcGIS? I have also considered using Tkinter and wxPython.
13
votes
5answers
18k views

Removing 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 ...
13
votes
4answers
13k views

Will ArcGIS Desktop support latest Python 2.x or Python 3.x versions?

I'm curious to know whether ArcGIS Desktop 10.0 will support newer versions of Python than 2.6. And for that matter newer versions of NumPy (ie, 1.4, 1.5 etc). I'm sure that this documentation is on ...
13
votes
1answer
23k 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 ...
13
votes
5answers
13k views

Setting up PyCharm to reference ArcPy?

How would I setup PyCharm to recognize import arcpy? I'd like to use PyCharm to develop and debug geoprocessing tool.
13
votes
7answers
12k views

Getting latitude and longitude of projected point using ArcPy? [closed]

I have a point feature in a feature class that is being accessed by ArcPy. The point is projected but I need to find an efficient means to get the unprojected latitude and longitude for this point. ...
13
votes
2answers
37k views

Running Python script in Task Scheduler— Script will not run

I have a script which I wish to run on a regular monthly basis without me needing to open and run the it. I have referred to every web page I can find on Windows Task Scheduler and followed their ...
13
votes
5answers
4k views

Python only using one core at a time to work?

I noticed recently that python is only using one core at a time to work. Is there a way, maybe special builds or commands, to make it use all resources (second core)?
13
votes
2answers
3k views

Keeping 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....
13
votes
3answers
545 views

File organization for sharing ArcGIS python code

What is the best organizational structure for sharing ArcGIS python code and geoprocessing tools? Or even, are sharing code and sharing tools separate questions? Esri has a Methods for distributing ...
13
votes
2answers
5k views

Deleting 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 ...
13
votes
1answer
494 views

File Validation using ArcPy?

I have a script which scans a directory and outputs basic raster data information such as the file name, format, number of bands, and etc. I need a way to make it so if the directory does not contain ...
13
votes
1answer
8k 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 ...
13
votes
3answers
5k views

How do I use sys.exit(0) in an arcpy script to exit early without having an error message show up?

I have an arcpy tool script for ArcGIS 10.0 that has two major functional sections. The user can choose whether or not to run the second section. If the user chooses NOT to run the second section, I ...
13
votes
1answer
3k 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
11k 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. ...
13
votes
2answers
3k views

Multiprocessing Errors - ArcGIS implementation

I was wondering if anyone else in the community here has attempted to use multi-processing for spatial analyses. Namely I am trying to iterate through a series of rasters, create a multiprocessing job ...
13
votes
5answers
1k views

Looping through 16 million records using ArcPy?

I have a table with 8 columns and ~16.7 million records. I need to run a set of if-else equations on the columns. I've written a script using UpdateCursor module, but after a few million records it ...
12
votes
1answer
14k 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?
12
votes
3answers
15k 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 = " \"...
12
votes
3answers
17k views

How does one access a featurelayer in SDE via Python?

I am trying to use Arcpy to run the CopyFeatures_management script so that I can copy a featurelayer in SDE. What do I use for the input (and output, for that matter, since I'll be copying the layer ...
12
votes
5answers
12k views

Batch Clipping in ArcGIS Desktop using ArcPy?

I've come across a few similar questions for older versions of ArcGIS, but haven't found a suitable answer for ArcGIS 10. I have two polygon shapefiles that cover a large area (e.g. an entire State/...
12
votes
5answers
7k views

Compiling Python scripts (to .exe) that use ArcGIS Geoprocessing Tools?

I've been coding with Python for several months now and have developed some reasonably complex scripts for primarily geoprocessing tasks. That being said, I'm still learning a lot as I'm coming from a ...
12
votes
3answers
2k 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
5k 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. Is it possible to automatically be updated with new filenames, and possibly even metadata (as created in the ArcGIS metadata ...
12
votes
1answer
6k views

What'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 ...
12
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 ...
12
votes
3answers
689 views

Deleting cursor used in SearchCursor within dictionary comprehension?

If it is best to open cursors using a with statement to ensure it is deleted, like so: with arcpy.da.UpdateCursor(fc,fields) as cursor: Then, if a cursor is used as the iterable in a comprehension ...
12
votes
6answers
5k views

Identifying true curves/arcs in ArcMap?

The only good way of creating circles in ArcMap is using true arc, (compound curves) but I need to convert those to vertex (densifying) because of a compatibility problem. I need info for geodatabase ...
12
votes
1answer
2k views

Fastest methods for modifying attribute tables with Python?

A while ago, I wrote a quick Python function for converting an attribute table to a python dictionary, where the key is taken from a user-specified unique ID field (typically the OID field). ...
12
votes
1answer
744 views

Running ArcGIS 10.0 Under Virtualenv

I am working on a Python package that has a mixture of command line tools and ArcToolbox tools. For Python development it is really useful to use VirtualEnv, especially when working with installers. ...
12
votes
4answers
4k 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. ...
12
votes
2answers
8k views

Making button that calls Python script as command rather than script tool?

I believe that in Arc9.3, commands could be created using VBA scripts. To add a custom command, you would navigate to Customize > Toolbars > Customize... and click UIControls. However, UIControls is ...
12
votes
1answer
402 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
2answers
2k views

SP1 for ArcGIS 10.1 has extension for 64-bit Python for background geoprocessing — implications for other Python use

If the 64-bit Background Geoprocessing for ArcGIS Desktop 10.1sp1 is installed how does that affect Python configuration for general use? Esri has released SP1 for the ArcGIS 10.1 product, and for ...
12
votes
1answer
9k views

Building extraction with LiDAR data (Improve Process)

I have the following process for automatically creating building outlines/footprints from Las files and was wondering if anyone can help improve it or has suggestions for other processes to use? ...
12
votes
0answers
698 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)...