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
11
votes
2answers
7k views

Seeking Python script for creating .mxd files?

I am new to both ArcGIS and Python. My requirement is to automate the below MANUAL process: Creating a layer in ArcGIS for Desktop. To put it in another words, creating an ArcMap document (.mxd). ...
11
votes
2answers
3k views

Why is ArcPy script slow?

I have a simple arcpy script to update a field in a point shapefile with info from the polygon feature that it is within. It takes 9 minutes to do 100 points in arcpy but a spatial join in arcmap is ...
11
votes
3answers
21k 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
8k views

Creating line of varying distance from origin point using Python in ArcGIS Desktop?

I'm trying to create a line feature from a single point, using a set distance and angle using ArcGIS and Python (ArcPy). I have a point at these coordinates: X = 400460.99, Y = 135836.76 From ...
11
votes
3answers
16k views

Setting Definition Query on ArcPy layer from shapefile?

I'm trying to determine options to set a layer definition query using ArcPy. I know that it is possible when using arcpy.mapping.ListLayers(). However, in this scenario I am loading in ...
11
votes
2answers
7k views

Finding mid-point of line using ArcPy?

How can the mid-point of a polyline be calculated using the geoprocessing framework, e.g. in a Python script? The polyline.centroid property returns The true centroid if it is within or on the ...
11
votes
3answers
8k views

Using multiple wildcard parameters with arcpy.ListFeatureClasses

I know there has to be a way to do this but I'm having trouble figuring out how to do so. I would like to create a list of feature classes to perform operations on however, I want to have the list ...
11
votes
2answers
9k views

Listing feature classes in multiple geodatabases in folder using ArcPy?

I have a folder with numerous geodatabases in it. Within the geodatabases are feature classes. I would like to get a list of the feature classes in these geodatabases using a Python script. I've only ...
11
votes
4answers
7k views

Getting full path of layer selected in drop-down box for ArcGIS Python script tool?

I have a Python script-based tool in ArcGIS. One of the parameters for the tool is an input raster file, which I've set (using the properties of the tool within the toolbox) to be a Raster Layer. This ...
11
votes
2answers
10k views

Creating checkbox parameter in Python script tool for ArcGIS Desktop?

I am working on creating an ArcGIS tool from a Python script I am writing. I am wondering if it is possible to have a checkbox parameter. I want to have a parameter where the user selects a ...
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 ...
11
votes
2answers
1k views

Computing new attribute based on changes in another attribute using ArcGIS Desktop with Python?

I am attempting to classify a set of gps time-encoded point data into behaviors based on different attributes. I have created an attribute that is 0 for home and 1 for away based on location, and ...
11
votes
2answers
962 views

Can ArcGIS and OSGeo4W share the same python install? [duplicate]

I don't like unnecessary duplication. Is it possible to install python only once and have both ArcGIS and OSGeo4W using it?
11
votes
3answers
12k views

Expecting ArcPy to overwrite files in geodatabase file?

I'm writing a python script, I've got an mxd and its workspace is a geodatabase file with all the files I need into. The problem I'm encountering in testing and writing code is that, despite of the ...
11
votes
2answers
4k views

Setting in memory workspace in ArcPy?

Is it possible to set env.workspace = "in_memory" in ArcPy using both ArcGIS Pro and the ArcGIS 10.2.2 (or 10.3) architectures? What I am trying to do is get the output of a snap pour point operation ...
11
votes
4answers
16k views

Avoiding import arcpy error (RuntimeError: NotInitialized) when using IDLE?

ArcGIS Version: ArcGIS 10, Python 2.6.5 Machine: Windows 7 64bit (Intel) I'm receiving the following error when importing arcpy using the the IDLE (gui and cmd prompt) and when using pythonwin. I ...
11
votes
1answer
441 views

Using Python to disable Scale map elements proportionally to changes in page size?

I am changing sources on MXDs in differents offices using ArcPy and ArcGIS 10.0. As observed here, the printer settings revert to the default printer when the instruction mxd.save() is sent. Losing ...
11
votes
2answers
14k 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 ...
11
votes
2answers
2k views

Drawing parallel lines inside polygons (Well Paths) using ArcGIS Desktop?

I would like to take a polygon feature class with multiple irregular polygons, and have Arc draw parallel lines inside of each polygon. Ideally, it would be nice for Arc to figure out the angle of the ...
11
votes
1answer
2k views

Using ArcPy with ArcGIS Pro and ArcGIS Desktop on same machine?

I'm just trying out ArcGIS Pro for the first time and I had to change my PYTHONPATH to python34 ArcGIS Pro is now working without crashing every time I open the Analysis tab... However now when I try ...
11
votes
3answers
4k views

Generating multivalue choice list in ArcGIS using Tool Validation without using Frequency?

I'm trying to adapt a model and script combination found on ESRI's blog site titled 'Generating a multivalue choice list'. However, I've concluded that part of the validation used in the embedded ...
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 ...
11
votes
4answers
7k views

Avoiding exclusive schema lock error with ArcPy?

I have a script for updating some features on my database every night (just for copying and replacing some features). This features are "read-only". My problem is that I can't avoid that these ...
11
votes
4answers
6k views

ArcGIS Python SearchCursor file locking?

I have a script that gets a value from a shapefile's field to return to the user. It seems that only when the arcpy.SearchCursor is called ArcMap 10.0 locks the file and it doesn't get removed ...
11
votes
2answers
2k views

Writing scripts that can call on both Arcpy and PyQGIS?

I have spent quite a bit of time looking for a clear answer this topic and have still been unable to really accomplish my goal of accessing PyQGIS in a stand alone script. Parts of answers have been ...
11
votes
1answer
711 views

PySAL natural breaks from Numpy array

I am attempting to extract natural break values from a raster using Python. The intended process goes: Arcpy raster object to NumPy Array (using RasterToNumPyArray) to natural break values (using ...
11
votes
1answer
5k views

Python Script to Create Table Using Data Driven Pages

I am trying to convert some python script to display a table (based on a dbf) of features located within a specific data driven page. So far, I have the script successfully able to refresh the map to ...
11
votes
1answer
117 views

Python Script Performance as an ArcGIS Tool Versus Stand-Alone

Has anyone studied the difference in running a Python script in ArcToolbox versus as a stand-alone script? I had to write a quick-and-dirty script to convert a set of RGB images to single band by ...
10
votes
6answers
13k views

Moving / offsetting point locations using ArcPy or ModelBuilder?

I have a number non-georeferenced CAD layers (see this question) that have text annotation features. I have created a model to convert the text to points, but after converting the annotation to a ...
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 (...
10
votes
5answers
33k 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.
10
votes
2answers
6k views

Python scripts that run inside ArcMap vs ones that run outside?

I'm just starting to get into Python scripting for work. I'm currently creating a script to automate a process. Basically, it asks the user the client name, gets a projection if available, creates ...
10
votes
3answers
20k views

Creating shapefile from lat/long values using ArcPy? [closed]

How can I create a shapefile using Python in ArcGIS 10? I have lat & long. From this I need Python code which will create a shapefile in ArcGIS Desktop 10.
10
votes
7answers
7k views

Getting raster image as array in Python with ArcGIS Desktop?

When starting to work with Python and ArcGIS 9.3, I assumed there would be a simple way to get a raster image into a Python array so that I can manipulate it before storing it back as another raster ...
10
votes
4answers
15k 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]...
10
votes
2answers
3k views

How to access Esri ArcPy modules from Enthought Canopy?

I have ArcGIS 10.1 running on my windows system and I have also installed the new 32-bit Canopy Express Enthought Python Distribution. Is it possible to load and use the Esri ArcPy modules from ...
10
votes
2answers
9k views

How to bypass errors in arcpy for/while loop?

I have a handy script tool that loops through a workspace and renames and copies shapefiles to a feature dataset. However, if there is a corrupted shapefile somewhere in the workspace the script ...
10
votes
5answers
1k views

How to improve performance when using ArcGIS cursors in Python with big tables?

I have a pretty big point feature class in a file geodatabase (~4 000 000 records). This is a regular grid of points with a 100m resolution. I need to perform a kind of generalization on this layer. ...
10
votes
2answers
18k views

Executing script in Python window of ArcMap?

I've been writing Python in my text editor so I have a Python script, script.py. I'm still developing it so don't want to put it in my toolbox yet, and at the moment this means copying and pasting it ...
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 ...
10
votes
6answers
2k views

Is there a faster way in python of finding the smallest number in a field?

Using arcgis desktop 10.3.1 I have a script which uses a search cursor to append values to a list and then use min() to find the smallest integer. The variable is then used in a script. The Feature ...
10
votes
1answer
21k views

Exporting Selected Feature to New Shapefile using ArcPy?

I currently have a search cursor iterating through a shapefile in ArcGIS 10.1 that selects a feature and runs a viewshed analysis on that feature (and only that feature). What's the easiest way to ...
10
votes
2answers
627 views

Create area buffers that are limited by a coastline

I'm trying to use ArcGIS 10.2 to create a buffer of points based on a pre-defined area (e.g 400 sq km). Further to that, the buffers of some of the points are close to the coastline that requires the ...
10
votes
2answers
620 views

Retrieving size of shapefile in ArcPy?

Is it possible to retrieve the size of a shapefile using python and arcpy? If so, how?
10
votes
5answers
5k views

Checking via ArcPy if ArcMap is in edit session?

I've created a Python add-in button that helps speed up my coworkers workflow by copying one feature class attribute to another. It uses the arcpy.UpdateCursor function to update a row in the target ...
10
votes
2answers
2k views

Check validity of file geodatabase using arcpy

AS the title suggests, how can I whether a GDB file is valid using arcpy? One approach is, only checking the whether the name ends with .gdb, but that's not a robust approach. Because a normal file ...
10
votes
3answers
6k views

Does ArcPy have a spatial search function for geometry?

My problem: Using ArcPy I want to loop over buffers and select geometry_features inside each buffer and do something (update) only the objects found within that specific buffer. The code below ...
10
votes
3answers
2k views

Searching Geodatabase for Feature Class or Table by its name?

I'm looking for a way to search Geodatabases for a Feature Class or Table by using its name. Is there any function like this available? Obviously windows search only returns the random ID's for the ...
10
votes
2answers
3k views

Is there a ArcGIS python script development API?

I'm a somewhat experienced software engineer new to the GIS world. I started working on a GIS project that supports ArcGIS 9.3 and 10.0 and looking through existing code it looks like the main ...
10
votes
3answers
5k views

How to reclassify a very large land cover dataset?

Consider the NLCD2001 Land Cover dataset for Alaska (download link). I need to reclassify this dataset so that only pixels of value 41, 42, and 43 are preserved; all other pixel values should become ...