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

learn more… | top users | synonyms (7)

37
votes
8answers
18k views

What are some resources for learning ArcPy?

I would like to learn ArcPy, but I do not know quite where to begin. Does anyone have any good advice on where I should start to learn ArcPy?
14
votes
3answers
12k 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 ...
6
votes
2answers
1k views

Assign point IDs to respective start and end attributes of a polyline

I have two shapefiles, Point and Polyline. I'm trying to populate my polyline layer with the point data ID (systemID) where the lines start to where they end; eg. create two columns (from and to). The ...
35
votes
4answers
5k 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 ...
18
votes
4answers
19k 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 ...
19
votes
6answers
4k 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 ...
14
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? which required using Avenue code. Any idea how to make it work in ArcGIS Desktop 10?
15
votes
2answers
18k 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 shape file to the current map. (And then do stuff to it, but that's ...
6
votes
1answer
2k 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 ...
40
votes
4answers
7k 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(). ...
9
votes
6answers
5k 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 ...
19
votes
2answers
5k views

How to make a separate Python installation that can call ArcGIS' arcpy?

I see a lot of threads 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 ...
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 ...
19
votes
2answers
5k 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 ...
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. ...
1
vote
1answer
248 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 ...
18
votes
4answers
12k views

Using Arcpy to zoom to selected feature?

The answer to this may be a simple yes or no, but I'm hoping that someone is aware of a way to zoom to the extent of a selected feature using the ArcPy modules in ArcGIS 10.
9
votes
2answers
789 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 ...
8
votes
2answers
1k 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 ...
16
votes
2answers
11k 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 ...
7
votes
3answers
12k 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
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 ...
3
votes
1answer
891 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 ...
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: ...
9
votes
1answer
5k 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?
8
votes
6answers
2k 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 ...
26
votes
6answers
13k 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 ...
14
votes
1answer
3k 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 ...
5
votes
5answers
17k views

Changing Symbology of Multiple Layers using ArcMap/ArcPy?

Is there a way to change symbology for multiple layers in ArcMap or ArcCatalog. I want to change the symbology of multiple layers at once.
15
votes
6answers
12k 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 shape file. I can get the extent of the whole shape file using ...
9
votes
4answers
5k 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 ...
5
votes
3answers
3k 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 ...
4
votes
5answers
9k views

Renaming field using ArcPy?

What I need to do: rename a field name of a table/feature class copy all values to the new field So far I have done following code as @artwork21 suggests: import sys import traceback import arcpy ...
7
votes
3answers
3k views

How to Refresh 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 ...
3
votes
3answers
2k 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: ...
21
votes
3answers
3k views

Why learn/use Python Toolboxes over Python Script Tools?

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

How to create arcs between two points in Python?

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 ...
7
votes
1answer
5k views

Setting Output Parameter in ArcPy for Server Tool

I have published the following script tool (which is wrapped in a model, i.e. just the script tool and all of its parameters) to ArcGIS Server 10. The GP service succeeds when run, but I cannot ...
13
votes
4answers
5k views

Developing GUI in Python for ArcGIS geoprocessing using PyQT?

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

How do I retrieve start and end point coordinates with Python/arcpy?

How do I retrieve start and end point coordinates with Python/arcpy for a polyline feature class? I expect to pass a segment identifier to a subroutine and have it pass back start and end coordinates. ...
5
votes
2answers
4k views

Using MultiValue in Python script tool parameters?

My script works fine with a single feature class selected for clip_fc = arcpy.GetParameter(0) . However when I set clip_fc to MultiValue in the script properties and then select several feature ...
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: ...
8
votes
3answers
2k views

Permanently replace/update server/service in each ArcSDE Layer in MXD?

Using the mxd.findAndReplaceWorkspacePaths method, if and MXD is updated and the path the the .sde connection file moves again all of the data sources will break again. Is there a method to ...
7
votes
3answers
7k views

How to create lines from points pair coordinates with arcpy?

I've got some points pair coordinates (start and end points) which I have to transform into lines. Until now, I used an append of both the coordinates in a pippo.Point(), a pippo.CalculateGeometry() ...
3
votes
1answer
1k views

Help with Python script for exporting mxds into pdfs!

I have written a python script to export my mxd into a pdf (not using data driven pages). I am getting the error that my mxd path is incorrect! I have included my script below. Any help would be ...
9
votes
1answer
1k views

How to prompt for user input during ArcGIS Python script tool execution?

I want to prompt for user input after all parameters have been specified for the script tool. I've seen many forum posts and stackexchange questions about this, and they all conclude that it's ...
7
votes
2answers
4k views

How to send long JSON objects (polygon geometry, table rows) in POST request to Geoprocessing Service?

I am seeking to understand my options for sending long JSON objects in a request to a Geoprocessing Service. In particular, I am looking for some example code to illustrate how to include two long ...
7
votes
2answers
909 views

Reordering polygon shapefile permanently?

I've written a script which produces a polygon shapefile of the extents of all the thousands of rasters in our library. I want to organise the FID so that the files with the largest extents are on the ...
4
votes
1answer
3k views

How to Calculate Field in joined table using ArcPy?

I have to calculate a field based on another field in a joined table, but an error occurs: "Parameters are not valid. ERROR 000728: Field !Table_A.field_A! does not exist within table" My code: ...