Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [arcpy]

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

37
votes
6answers
27k views

Learning ArcPy?

Where can I start to learn ArcPy?
21
votes
5answers
21k 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 ...
20
votes
2answers
30k views

Adding shapefile or feature class as layer in ArcGIS Desktop using Python/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 ...
2
votes
1answer
1k views

Graph/Network building and analysis of linked polygons in ArcGIS for Desktop?

This is more of a follow-up question to Divide polygons into *n* number of groups of equal counts with ArcGIS 10.2 and grouping village points based on distance and population size, particularly the ...
37
votes
4answers
6k 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 ...
2
votes
2answers
2k views

Create a line perpendicular to an existing line in ArcGIS

For an existing set of line features, I would like to generate a perpendicular line, of say 1km, at the midpoint of each existing line feature in ArcGIS. I imagine that The methodology would be to: ...
26
votes
4answers
12k 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 ...
23
votes
4answers
34k 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 ...
12
votes
1answer
4k 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 ...
15
votes
3answers
3k 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?
20
votes
6answers
5k views

How to make a GIS inventory?

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 ...
10
votes
6answers
7k views

Get a point on a polyline from end points given distance along poly line

I have start point and end point of a polyline. How can I get a point on that polyline from end points specified by the given distance. How can I get this by using arcpy provided that this script ...
14
votes
6answers
15k views

Randomly subsetting X% of selected features using ArcPy?

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....
49
votes
5answers
9k views

Debugging ArcPy scripts?

I have written many Python scripts using ArcPy in ArcGIS 10, and so far my only means of debugging is restricted to printing messages to the geoprocessing results window using arcpy.AddMessage(). ...
14
votes
5answers
17k 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 ...
10
votes
3answers
20k views

Remove lock on feature class

When i try to delete a feature class , after or during the use of an Arcgis engine app which uses the same feature class i got an error concerning the lock , so i can't get ride of this lock until i ...
11
votes
4answers
10k 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-...
9
votes
7answers
4k views

Divide polygons into *n* number of groups of equal counts with ArcGIS 10.2

One of my tasks for work is to divide parcels into groups. These groups will be used by agents to talk to property owners. The goal is to make the agent's job easy by grouping parcels that are near ...
21
votes
3answers
7k 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 ...
10
votes
5answers
10k 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.
6
votes
1answer
3k views

Adding Table to Layout View using ArcPy?

I am using ArcGIS 10.1 and I have a non-spatial table and some layers in a Data Frame. When I switch to Layout View I want to be able to show the map in a data frame element and the table in another ...
17
votes
1answer
2k 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 ...
22
votes
3answers
5k 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 ...
9
votes
2answers
1k views

Creating summary table of symbology of all datasets in multiple MXDs?

This is related to the following Retain ESRI symbology in Mapinfo TAB . As an initial step (in arcpy) I want to access the symbology of all the datasets and create a document which has the details of ...
19
votes
2answers
21k 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 ...
6
votes
1answer
1k views

Convert point XY to page units XY using arcpy?

I am using arcpy to export PDFs from my ArcGIS Server application. I want to move a TextElement in my layout view to the centroid of a selected feature. I can get the centroid of the feature, but that'...
3
votes
1answer
2k views

How to run OGR in ArcGIS Scripts?

When I run my script outside ArcGIS it works because during execution script uses a GDAL and OGR modules from osgeo. When I use script as a tool in ArcGIS it does not work. In PySripter I can import ...
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. ...
11
votes
4answers
4k views

Refreshing open attribute table in ArcMap using ArcPy rather than ArcObjects?

I am running the Calculate Field GP tool from the arcpy in ArcMap. When a row value is updated, it does not show up untill I use the Reload Cache tool (Table Options > Reload Cache). How do I refresh ...
30
votes
6answers
18k 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 ...
19
votes
6answers
19k views

Obtaining extent of each polygon in shapefile using ArcPy?

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\...
9
votes
2answers
2k views

How to create an oriented buffer using arcpy?

I would like to create an oriented buffer for every polygon in my shapefile using arcpy. By oriented I mean that I have two angles a1 and a2 that constraint the direction of the buffer. This is ...
9
votes
1answer
5k views

Computing UTM Zone from lat/long point?

I am trying to convert a latlong point to UTM. To define UTM projection, I need to calculate zone for the point. I am trying to figure out the best way to do this. One way to do this would be ...
10
votes
4answers
14k 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]...
9
votes
3answers
7k views

Replacing non-English characters in attribute tables using ArcPy and Python?

I have a few shapefiles where some of the attributes contain the non-English characters ÅÄÖ. Since some queries doesn't work with these characters (specifically ChangeDetector), I tried to change them ...
11
votes
1answer
13k 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?
11
votes
3answers
14k 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 = " \"...
7
votes
1answer
4k views

Can multiprocessing with arcpy be run in a script tool?

I have been tinkering around with the multiprocessing module to resolve some processing of data in ArcMap 10.3. I have created a script which works fine if I run it in IDLE. I see all my cores max ...
10
votes
2answers
3k views

Inserting newlines in Rectangle Text elements via ArcPy causes overlap?

I ran across an issue the other day when I tried to use ArcPy's mapping module to edit rectangle text elements with newlines (\n) in an ArcMap document. Here's what the output looked like: Here's ...
9
votes
1answer
4k views

Batch Georeferencing in ArcMap/ArcPy?

I have about 50 pdf maps that I would like to batch georeference and/or georectify. I've saved one as a jpg and georeferenced it manually and would like to automate the rest which are in the same ...
6
votes
4answers
9k views

Debugging RuntimeError: workspace already in transaction mode from arcpy.da.UpdateCursor and ArcSDE feature classes?

I am making my first attempt at editing an ArcSDE feature class with python through a da.UpdateCursor. I'm essentially taking code I've written for a file geodatabase feature class and applying it to ...
3
votes
2answers
4k views

Getting all results from Selection made by Attribute or Location using ArcPy?

Using arcpy I'm trying to get the results of a selection, or what is currently selected as a list. Basically I'm attempting to build an addin which on click will either perform an operation where I ...
11
votes
5answers
7k views

Splitting polygon with line using ArcPy?

In looking at Buffering with physical barrier using ArcGIS for Desktop?, it occurred to me that I am not sure how one would go about using geoprocessing tools in ArcGIS to split a polygon with a line ...
4
votes
2answers
1k views

Adding feature class to Map in CURRENT project using ArcPy in ArcGIS Pro?

I want to add a feature class within a Geodatabase to a map in ArcGIS Pro (1.4.1) using arcpy. I am converting some python code from ArcGIS Desktop to ArcGIS Pro. This issue is very similar to: ...
4
votes
1answer
179 views

Selecting LiDAR return point type in LiDAR dataset with ArcPy?

I am trying to create a Digital Earth Model (DEM) using ArcPy under ArcGIS Pro 2, but I am running into some problems. I can generate a DEM within ArcGIS Pro by selecting only the ground points ...
3
votes
3answers
4k views

Runtime error : ERROR 000358: Invalid expression using SelectLayerByAttribute in ArcPy?

I cannot for the life of me persuade SelectLayerByAttribute to work (I need to automate this for a complex script). Working in ArcMap's python console on already loaded shapefile, the format below: ...
25
votes
3answers
6k 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 ...
32
votes
3answers
22k 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 ...
10
votes
4answers
5k views

Creating arcs between two points in ArcPy?

I've been working on an python script automating the visualization of live point data. I have a table with two coordinate pairs. I'd like to connect these two point with an arc of a circle or similar (...
19
votes
4answers
16k 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.