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
10
votes
1answer
4k views

Creating 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
3k views

How to specify unit of measurement when accessing Geometry() object's 'length' attribute?

Using the CalculateField_management tool, one can specify the unit of measurement when calculating shape length: #Calculate polyline lengths in miles polylines = "C:\sampleShape.shp" arcpy....
10
votes
3answers
17k views

Creating 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() ...
10
votes
1answer
1k views

Identify shape of the polygons: elongation, roundness, etc

I am generalizing geological map. In the initial step I am dealing with small polygons which should be either deleted, enlarged, aggregated and etc. Before applying operations mentioned above I ...
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 ...
10
votes
2answers
5k views

Rotating Features in ArcGIS for Desktop using ArcPy? [closed]

I have a series of polygons that I want to rotate. Each polygon has a rotate angle and an anchor point (xy coordinate) stored as field values. As it happens, all anchor points are on a vertex of ...
10
votes
2answers
3k views

Error handling with python script in ArcGIS 10

I have a python script that I am using to create a list of all mxd files (with full pathing) in our Projects folder. The script then uses that to iterate through the list and do a ...
10
votes
4answers
3k views

With arcpy, how do I detect relationship classes in a file GDB (or can't I)?

I would like to be able to detect relationship classes in a file GDB. Because users of my script might have only an ArcView level license, they would not be able to manipulate the schema of a feature ...
10
votes
3answers
1k 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
2answers
3k views

Detecting Join programmatically using ArcPy?

I have some Python code that is launched from within an ArcMap project. Any joins that the user may have created in the project must be removed in order for my code to run. Unfortunately, the code ...
10
votes
1answer
1k views

Teaching Python to Land Surveyors [closed]

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

Dividing polygons into *n* number of groups of equal counts with ArcPy?

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

Set default values for value table in Python Toolbox tool

I created a Python Toolbox tool to reorder fields and create a new feature class with the reordered fields. The tool works nicely and I am able to use a value table to let the user arrange the fields ...
10
votes
1answer
7k views

Setting up Drop-Down list in Parameters of Python script tool?

I am trying to create a tool from a python script I have written that will take a list I have created and use it as a drop-down menu in the finished tool as one of the inputs (see attached image for ...
10
votes
2answers
358 views

Minimising number of dynamic pages to map scattered points using ArcGIS Desktop?

From time to time I have to produce mapbook to show points of interest. First step to create pages, using regular mesh: I don't like the solution because a) there are some pages with single points (e....
10
votes
1answer
600 views

Using ArcPy and PyGRASS tools in 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
2k 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
2answers
2k views

Handle annotation layers with arcpy

I want to access annotation layers using arcpy (the purpose is to verify few text strings in text annotations). By annotation I mean draw tool annotations, not dynamic labels. These annotation layers ...
10
votes
2answers
2k views

Implementing MultiValue Parameter with Multiple Columns with Python and ArcGIS Desktop?

I am working on an ArcGIS (9.3) Python script. One of the inputs is a list of features. For each feature, I need to select a corresponding field. Setting the parameter to MultiValue gives a nice table ...
9
votes
8answers
6k views

Maximizing the use of CPU

My script is intersecting lines with polygons. It's a long process since there are more than 3000 lines and more than 500000 polygons. I executed from PyScripter: # Import import arcpy import time # ...
9
votes
5answers
15k 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 ...
9
votes
2answers
7k 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 ...
9
votes
3answers
14k views

Retrieving start and end point coordinates with ArcPy? [closed]

How do I retrieve start and end point coordinates with 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. The ...
9
votes
1answer
16k views

How to delete selected rows using ArcPy?

I want to delete all rows in a feature class but remain rows 1 to 5. In other hand I want to remain first five rows and delete others. I know that I have to use search cursor and update cursor but I ...
9
votes
2answers
3k 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
3answers
3k views

Distinguishing Python version when using IDLE with ArcGIS Pro and ArcGIS 10.x for Desktop architecture?

I have just started to work with Python 3.4.1 which comes with ArcGIS Pro 1.0.0, on my laptop, which also has Python 2.7.8 which comes with ArcGIS 10.3 for Desktop installed, and I would like to ...
9
votes
2answers
1k views

ArcMap running scripts slower if you import Arcpy

I am finding ArcMap runs slower, if you have written a script, which imports arcpy. You may wish to write a script that can be operated in ArcMap, through the python window, or as a standalone ...
9
votes
5answers
1k views

python.multiprocessing and “FATAL ERROR (INFADI) MISSING DIRECTORY”

While trying to do multiprocessing with arcpy, I am occasionally running into this error: FATAL ERROR (INFADI) MISSING DIRECTORY I have no clue what is triggering this error, and it crashes the ...
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 ...
9
votes
6answers
7k views

Calculating orientation of each side of polygon using ArcPy?

I want to examine the orientation of each line in a polygon so that I can calculate their solar exposure. Each polygon represents a building, and has an associated height. For the moment, I just want ...
9
votes
1answer
7k views

Delete layer from ArcMap using Python

Problem: I'm trying to loop through all my layers looking for layer named "CADAnnotation". If the layer exists then remove the layer from the mxd Notes: Running from Stand-Alone script (ie. NOT ...
9
votes
2answers
3k views

Changing from layout view to data view using ArcPy?

Is there a way to change from layout view to data view using Python and ArcMap 10? I would prefer to do it using ArcPy.
9
votes
6answers
2k views

How to programmatically check if the number of shapes = number of table records?

I have a handful of approximately 1000 shapefiles that are corrupted (see attached error message). The shapefiles were generated from eCognition Developer 8. There is a script tool that seems to ...
9
votes
3answers
2k views

Speeding up Python calculated timestamp field in ArcGIS Desktop?

I am new to Python and have started to create scripts for ArcGIS workflows. I am wondering how I can speed up my code to generate an "Hours" double numeric field from a timestamp field. I start with ...
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 ...
9
votes
4answers
12k views

Copying ArcSDE geodatabase to file geodatabase using ArcPy?

I would like to make an exact copy (domains, feature datasets, feature classes, etc.) of an SDE database to a file geodatabase. I have tried several possibilities, including: using the Copy (Data ...
9
votes
4answers
4k views

Exploding overlapping to new non-overlapping polygons?

Given multiple polygons that overlap in multiple ways, I would like to export from these features all polygons that don't overlap with others, iteratively. The product would be a number of features ...
9
votes
4answers
2k views

Creating polygon connecting endpoints of multiple lines using ArcPy?

I'm trying to figure out how to create a polygon that connects all the endpoints of a shapefile containing a set of polyilnes with pythonscript in ArcGIS, I'm having trouble doing this as the order of ...
9
votes
3answers
1k views

can arcpy detect whether it's running in Desktop or Server?

I'm developing some code that I want to run both as an ArcGIS Server web service and as a standalone script. I want to be able to modify the execution slightly depending on whether it's running as an ...
9
votes
2answers
3k views

How to implement bivariate Ripley's K function?

The attached image shows a forest gap with red pine represented as circles and white pine represented as crosses. I am interested in determining if there is a positive or negative association between ...
9
votes
2answers
13k views

How to clip a vector feature to the extent of an existing raster dataset using arcpy

I have a clipped raster dataset with polylines (from the contour tool) overlayed (see attached). I am trying to clip the polylines to the extent of the raster dataset, which seems simple enough, but ...
9
votes
1answer
8k views

Creating script tool that will create copy of feature class and offset it by given distance using ArcPy?

I want to duplicate a polygon feature class and offset all of the polygons by about 10 feet in both the x and y directions. I asked if there was any way to do this last week, and I was informed that I ...
9
votes
2answers
11k views

Altering label styles (font, color, size, etc.) using ArcPy?

I am trying to write a python macro for ArcGIS 10.2 that will automate the process of labeling points in a layer based on different types of apartments. For example, one style of apartments would ...
9
votes
3answers
8k 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 ...
9
votes
1answer
1k views

Determining Shape Area Field Name

I'm dealing with a varierty of spatial polygon files (shapefiles, file/personal gdb feature classes, sde feature classes (some with spatial views)) and depending on the file type, I get a mulittude of ...
9
votes
3answers
17k views

Finding duplicate records in field using ArcGIS for Desktop?

I'm looking for duplicate records in dbf files based upon the attribute called 'ID'. I have various dbf files from 500,000 records to 1.5 million and I know there are a host of duplicates. I would ...
9
votes
2answers
1k views

How to create a solar intensity map for a garden plot?

I'm interested in creating a raster surface that depicts the average solar intensity per unit area for a small garden plot. I imagine the inputs into the model would be the following: Plot area--for ...
9
votes
1answer
212 views

The role of '#' in a python 'if':

I recently exported an ArcGIS model to python and was reviewing the script and am confused by the following line: if TRU_W_DatableFeatures == '#' or not TRU_W_DatableFeatures: What is the role of ...
9
votes
3answers
5k views

Transform bookmarks to data driven pages in ArcGIS Desktop?

We have this large project in ArcGIS with 30 maps with different extents using Bookmarks to pan between these maps/pages. Now we would like to use Data driven pages instead. The question is, is it ...
9
votes
3answers
2k views

How to determine on which side of a line a polygon feature falls?

I have parcel data intersecting line data. In the parcel data there are some parcels that don't intersect the line. How could I programmatically figure out if the non-intersecting parcel is on the ...