A site-package created by Esri to expose ArcObjects to Python.

learn more… | top users | synonyms (1)

7
votes
3answers
409 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 ...
7
votes
2answers
207 views

Finding specific pixel values ​​in ArcGIS using Python

I have a raster file containing some integer values. I need to find all pixels whose values are not defined in list like this one: l = [1,2,4,8,16,32,64,128]. Is there any easy way to solve that ...
7
votes
2answers
433 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 ...
7
votes
1answer
1k views

How to perform a table look-up using Python in ArcGIS 10.0?

Using ArcGIS 10.1 the arcpy module has a TableToNumPyArray command, which converts a table into an array. Unfortunately I don't have access to 10.1 on my work PC. Is there a workaround which will ...
7
votes
2answers
833 views

Process a raster with multiple geoprocessing tools in arcgis 10 using python - flow between processes

I'm writing a short python script that includes processing rasters with different geoprocessing tools in ArcGis 10, for example, the three processes below, is this best way to use multiple tools ...
7
votes
1answer
91 views

Meaning of exclamation mark in Python parser of ArcGIS Field Calculator?

In the following line, I don't understand what those exclamation marks mean? And why put everything in quotation? I don't understand the purpose of the variable expression, please explain to me as I'm ...
7
votes
2answers
530 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 ...
7
votes
2answers
3k views

Modify raster layer display and symbology properties programmatically with arcpy or ArcObjects

I have over 1500 NITF files that I need to be able to modify the layer display and symbology of programmatically from within ArcMap. I need to set the properties outlined in red below: I've looked ...
7
votes
3answers
2k views

How to create a circle in arcpy

Suppose I have a dataset where each record has an x,y and r (the centroid and radius of a circle). How can I create a polygon feature class containing parametric circles? Sorry to those who have a ...
7
votes
2answers
127 views

How to Determine if Layer is a Point

I have been working on a Python toolbox which contains 6 parameters. I am a little lost on all of the different data types available in ArcMap (it seems like there's hundreds of them!). However, one ...
7
votes
3answers
185 views

How to perform a “mostly within” selection?

I'm looking for a way to determine if a polyline is "mostly within" a polygon. Since mostly within is arbitrary, I would need be able to enter a percentage at its execution. I thought there might ...
7
votes
2answers
213 views

Unusual results for geoprocessing speed tests

I have been observing unusual performance with a Python geoprocessing script. The (attached) script performs the following actions: Use a search cursor to look up UTM zone corresponding to polygon ...
7
votes
2answers
336 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" ...
7
votes
1answer
674 views

ArcPy method to determine ArcMap document version

Is there a way with ArcPy to identify the version of a Map Document (MXD). I am working on a solution to inventory our MXD's and would like to know if a document is 8.1, 9.2, 10.0, etc. I am ...
7
votes
1answer
1k views

Why can't I access a table in a personal geodatabase (.mdb) with arcpy after installing 64-bit geoprocessing?

I wrote and ran a simple script last year - it cycled through some line features, buffered them and then intersected with some other lines - it all worked fine. I'm now trying to tweak the file to ...
7
votes
1answer
1k views

Guidelines for organizing Python Toolboxes (.pyt) in ArcGIS

For one of my tasks I need to create a Toolbox with three tools (python scripts). Instead of ordinary tbx I've decided to write it as Python Toolbox (pyt). Everything is clear except the "good" way ...
7
votes
1answer
920 views

How to keep 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 = ...
7
votes
1answer
969 views

concurrent use of in_memory workspace in arcpy

i am using a python script that's eliminating small polygons from a feature class. this script creates temporary feature classes with fixed (hardcoded) names in the "in_memory" workspace. example: ...
7
votes
3answers
977 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 ...
7
votes
2answers
1k views

Change from layout view to data view using python? (ArcMap 10)

Is there a way to change from layout view to data view using python? I would prefer to do it using arcpy.
7
votes
1answer
967 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: ...
7
votes
2answers
615 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 ...
7
votes
1answer
179 views

Reduce processing time in Erase function using Arcpy in IDLE

I am processing 18,000 feature classes (saved in a file GDB), each with ~500 records (polygon features) in ocean areas, and I am running a script to remove area overlapping with the coast, using the ...
7
votes
1answer
3k views

using arcpy outside arcmap

There may be something I'm missing, but is it possible to use the arcpy module outside arcmap? My situation is that we have one license on a computer which is shared over a network. I need to do ...
7
votes
4answers
5k 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 ...
7
votes
2answers
436 views

How can I speed up my arcpy script?

I have written an application that does a lot of geoprocessing using arcpy. Once started, the application itself runs at an acceptable speed, but it is very slow to boot. It can take 30 seconds or so ...
7
votes
1answer
1k views

Edit End Points in Polyline (Python/ArcMap10)

I am trying to make a polyline endpoint snapping tool in python. using a Search Cursor I read in the values to an array of line objects (which contain the feature id of the line, and two "EndPoint" ...
7
votes
2answers
1k 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 ...
7
votes
1answer
468 views

How to simulate moving vehicles?

I have a point layer (stored in SQL Server 2008) that is being served up by a map service in ArcGIS Server 10.1. I am consuming this service in a web client. Lets say the points are boats out at ...
7
votes
2answers
271 views

Conflict between ArcPy and GDAL/OGR?

TL;DR I can't get an installation free version of GDAL/OGR to work from within ArcMap 10.0. I get an ImportError: DLL load failed on _mod = imp.load_module('_gdal', fp, pathname, description). ...
7
votes
3answers
607 views

How to Receive an Email after a script has run?

I'm working my way through my first attempt at scheduled tasks with modelbuilder and python. So far I have: Created a model that reconciles our SDE versions and then compresses the database. ...
7
votes
2answers
194 views

How to access current job id from geoprocessing script running on esri server?

I want to programmatically access the current job id of a geoprocessing script running on ESRI 10.2. The script is what needs to know the job id, not the caller of the script. While searching, I ...
7
votes
1answer
220 views

Draw middle ordinate perpendicular to chord, out to curve, with arcpy

I've been assigned to find the radius of road curves. My boss found this article describing a pretty straightforward method of doing so: find the start/end points of the curve; create a chord; ...
7
votes
1answer
2k views

Python-arcpy : How make feature list from gdb and value list from field and use them in gaLayer function?

I'm not an expert in python, however I have to write a script to do geostatistical analyses with the GACreateLayer function from Arcgis. I have several data (>2000) and I want to use list of features ...
7
votes
1answer
223 views

Efficient Network Neighbors?

I would like to identify the Kth order neighbors of an edge on a network, specifically the neighbors of a large set of streets. For example, I have a street that I'm interested in looking at, call ...
7
votes
5answers
536 views

How to programatically identify the “Joined Field” in ArcMap?

Is it possible to programmatically identify the Join Field that is being used to Table Join two datasets together in ArcMap? I am currently using ArcGIS 10.0, SP5 and would prefer an ArcPy solution, ...
7
votes
3answers
1k views

python.exe has stopped working

A python script was written about 18 months ago by a person who has now left. It produced the required outputs then. I've been asked to run it again but with different (finer resolution) data ...
7
votes
1answer
428 views

Arcpy crashes in loop geoprocessing (general behaviour)

I have several standalone scripts that create a list of shapefiles to process (or coverages in one of the scripts). Sometimes my script crashes after it processes three files, sometimes ten, ...
6
votes
4answers
2k 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 ...
6
votes
4answers
1k views

Raster to Polygon Scripting Problems

I am trying to make a script which selects every .png file in a folder beginning with the letters "LG". I then want the scipt create a shapefile, replacing the "LG" with "SH", and then i want the ...
6
votes
2answers
5k 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 ...
6
votes
3answers
2k views

How can I select vector features that overlay raster in arcpy?

I have two datasets: point feature class and raster (stored in file geodatabase). The spatial extent of the raster is smaller than the point dataset. Is there a way I could select (or create new, ...
6
votes
2answers
1k views

Creating geodatabase from CSV using python

I have a file with weather data (daily) for multiple weather stations for multiple years. I am looking for some python script to automate the database creation process and its interpolation on a daily ...
6
votes
2answers
251 views

Python scripting- compute statistics

I'm new to Python but I've heard is a good way to automate tasks. I have thousands of point shapefiles and need to extract the maximum value of each one and put them in a new table. I'll appreciate ...
6
votes
3answers
1k views

Why is an extra field necessary when creating point shapefile from csv files in Python?

I have a Python script that creates a point shapefile from a csv file within a Python script. This script gives me a ValueError for the longitude field (LON) if there isn't an extra nonsensical field ...
6
votes
1answer
3k views

In an arcpy script, how do I convert ArcGIS date value to a string reading in mm/dd/yyyy format?

I am writing an arcpy tool script in ArcGIS 10.0. In a fGDB feature class, I have a Date type field. I gather that the values in the Date field are stored as long integer dates, but they display in ...
6
votes
2answers
2k views

Is it possible to access ArcGIS's table operations “Summarize…” and “Statistics…” in python?

ArcGIS has a few nifty table tools, including Summarize and Statistics. Is there a way to access them through arcpy, or will I have to hack my own methods via math and lists?
6
votes
4answers
693 views

How to optimise and speed up Python code? [closed]

Again my lines of surface runoff... I made a script, solving the issue when lines cross other lines. Something like generalization. Like on the picture below. The problem is that I have to solve 30 ...
6
votes
5answers
176 views

How to access adjacent rows with cursor?

In the attached screenshot, the attributes contain two field of interest "a" and "b". I want to write a script to access the adjacent rows in order to make some calculations. To access a single row, ...
6
votes
1answer
400 views

Are there any distinct advantages of creating a Python Toolbox over a Custom Toolbox?

I enjoy making different geoprocessing tools to practice Python and to become more familiar with the arcpy modules. I've just been using a Custom Toolbox and then importing the Python script and ...