Python is an open source interpreted programming language used in many GIS programs.

learn more… | top users | synonyms

68
votes
5answers
10k views

Accessing ArcObjects from Python?

I would like to be able to script some things that are not exposed via arcgisscripting or ArcPy. How do I access ArcObjects from Python? I'm working with ArcGIS Desktop 9.3.1 right now, but will be ...
27
votes
4answers
3k 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 ...
7
votes
3answers
4k views

How to include 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 ...
36
votes
10answers
21k views

How to install GDAL with Python on windows?

Can anyone please explain to me in step by step instructions how to install GDAL/OGR with Python on Windows. I have Windows Vista and I have tried following the information on the website and it does ...
25
votes
9answers
4k 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
2k views

Port “Producing Building Shadows” Avenue code to ArcGIS 10

Whuber provided an answer here Producing building shadows? which required using Avenue code. Any idea how to make it work in Arc 10? Thanks in advance.
5
votes
3answers
2k views

Python, comtypes and ArcObjects: Error creating AppROT object

I am experimenting with comtypes and ArcObjects under Python 2.6.5 and ArcGIS 10 SP1. I'm using the pure Python method to wrap the ArcObjects OLBs described in this answer, but getting an error in the ...
16
votes
1answer
4k views

How to divide a polygon into specific sizes using ArcGIS?

I have several thousand irregularly shaped polygons in a shapefile. I want to be able to split each polygon into three areas, and to specify what the size of those areas (they sum to the previous ...
9
votes
3answers
7k views

How to change feature class and field aliases in bulk?

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

How can I effectively debug arcpy Python 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(). Are ...
20
votes
3answers
4k views

Simple thematic mapping of shapefile using Python?

I wish to visualize geographical data in Python, without using ArcGIS/ArcPy, and make a map. On the internet I found how to make a thematic map using Python: Here is some code that I tried: ...
14
votes
3answers
7k 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 ...
18
votes
7answers
6k views

Nearest neighbor between a point layer and a line layer

I've asked this question several times on stackoverflow and irc between #qgis and #postgis and I also tried to code it or implement it my self in postgis with no real answer. Using programming (most ...
6
votes
1answer
4k views

How to add automate values to attribute field?

I have parcel, Buildings layers, without any information attribute table, and i want to replace "NULL" values with numbers form 1 to 2000, in "Parcel ID", or "Building ID" field thank you.
6
votes
3answers
5k views

Programmatically start and stop map services with Python

Is it possible to programmatically stop and start ArcGIS Server map services using Python?
14
votes
4answers
6k views

How to add an attribute field to an existing Shapefile via Python

I have a Python script that adds an attribute field to a Shapefile if doesn't exist. This is easy to do with ArcGIS (graphically or via Python), but I'm looking for something that doesn't depend on ...
6
votes
3answers
8k views

Define Workspace for SDE Connection in Python

How do we define SDE Connection for workspace in Python Scripting. Its urgent please need your suggestion. Thanks
15
votes
3answers
3k views

How to call gdal_translate from Python code?

Is it possible to use some gdal API to call gdal_translate from Python code? I do not mean simply executing the gdal_translate.py from the file system, but rather call it somehow in code so I do not ...
14
votes
1answer
1k views

Voronoi polygons that run out to infinity

I have been working on implementing the voronoi.py script (Bill Simon's translation of Steve Fortune's code). According to the QGIS link it is basically the same code that I am working with, but the ...
12
votes
5answers
6k views

Obtaining extent of each polygon in shapefile?

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 ...
11
votes
6answers
937 views

How to implement value-by-alpha map in GIS?

I've been doing some background reading about cartograms recently and stumbled upon interesting alternative - value-by-alpha maps. Concept is described in more details here and full paper is ...
2
votes
1answer
516 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 ...
3
votes
2answers
1k views

ArcObjects + comtypes at 10.1

Has anyone played around with using ArcObjects in Python at version 10.1? I am having all sorts of problems, such as TypeErrors when wrapping the ESRI OLB modules and AttributeErrors when attempting ...
5
votes
3answers
2k views

Select features by attribute if in Python list

I believe this will amount to largely a sql syntax question. Essentially, 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. ...
3
votes
2answers
4k views

How to sort a feature class and then calculate a sequential ID field?

I am in ArcMap and I want to sort the records based on a field and then do a Calculate Field with an auto-incrementing value with the sort in-place. Any ideas? It looks like I could get an update ...
1
vote
1answer
736 views

How to evaluate raster calculator expressions from the console?

How can I execute from the console an expression that should be used with the raster calculator? I'm searching for something like this: qgis.someRasterCalcClass.evaluate("boh@1 + boh@2", ...
43
votes
13answers
9k views

What are the best resources for learning GIS programming with Python?

In your opinion, what is the best book/site to learn Python with GIS goals in mind? By "best", I mean: not very long (book) easy to understand (book/site) good practical examples (book/site)
43
votes
10answers
3k views

Alternatives to using Arcpy

I seem to use ESRI's Arcpy site package for virtually all of my python geoprocessing. To ESRI's credit, these are an incredible suite of tools that can help accomplish a great deal. However, I would ...
17
votes
11answers
3k views

What are the Python tools/modules/add-ins crucial in GIS?

With ArcGIS 10, Python has become the de-facto scripting language for ESRI. While leading Open source software like QGIS, GeoServer, PostGIS all supports Python. Thus it became important to know/learn ...
19
votes
9answers
5k views

How do I develop my GIS programming skills?

I would like to develop my GIS programming skills, where do I start? People say learn C++ or Python but where can I learn this in a geographic context? Tutorials or anything would be very helpful, as ...
12
votes
3answers
4k views

Clipping raster with vector layer using GDAL

I have installed GDAL using the Osgeo installer. How can I clip a raster layer with a vector layer programmatically? Is there any GDAL API available which can help me with this? I am using Python.
8
votes
4answers
2k 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 ...
29
votes
3answers
1k views

How to Share Open Source Python Code for ArcGIS?

My company just purchased ArcGIS software. I'll be writing scripts for ArcGIS in Python. Is there a community or open source project where this code can be shared?
9
votes
5answers
3k views

Compiling Python Scripts that use ArcGIS Geoprocessing Tools?

I've been coding with Python for several months now and have developed some reasonably complex scripts for primarily geoprocessing tasks. That being said, I'm still learning a lot as I'm coming from a ...
12
votes
6answers
3k views

What tools in Python are available for doing great circle distance + line creation?

I need to use Python to create a great circle distance -- both a number, and preferably some kind of 'curve' that I can use to draw in a client-side map. I don't care about the format of the curve -- ...
10
votes
1answer
1k views

How to find differences between shapefiles?

Every month I have to QA/QC some streets data for an entire county (over 47,000 records). The first step is to compare the two files. Currently, I'm using a tool that was created in house via VBA ...
10
votes
1answer
1k views

How to access feature classes in file geodatabases with Python and GDAL?

I am trying to access a vector dataset in a ESRI File Geodatabase using Python + GDAL. I have successfully compiled GDAL with the file geodatabase API. The FileGDB driver is working correctly since ...
8
votes
2answers
2k 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 ...
5
votes
1answer
510 views

Work-around for slow processing times in ArcGIS 9.3 with Spatial Analyst functions

I am batch processing a large amount of distance functions (~50,000) using ArcGIS 9.3. In this version, using spatial analyst functions, it seems to be the case that users cannot parallelize processes ...
8
votes
3answers
4k views

How to find the locations of the highest values in a raster?

Using ArcGIS 10, I have a raster where I would like to find the pixel with the maximum value in the raster and return its location (center of pixel) in decimal degrees. I would like to iterate through ...
4
votes
2answers
5k views

If/then VBScript/Python code equivalent to SQL IN ('x','y',z') expression in ArcGIS Field Calculator?

we need just like the following, only with multiple records selected... have tried the "xyz" in (1,2,3,4,5) SQL code but of course VB Script wants something else. dim f2 if [field1] = "foo" then f2 ...
3
votes
1answer
305 views

How to render area that crosses 180°?

The problem is that the Chukotka Peninsula is located in the Western Hemisphere. So it is on the left side of Natural Earth Datasets. It needs to be moved to the right. I tried to use following ...
10
votes
1answer
524 views

How to visualize azimuthal data with uncertainties?

I am trying to make a figure showing azimuthal data with a different range of uncertainties at each point. This oldschool figure from a 1991 paper captures the "bowtie plot" idea that I'm aiming for: ...
9
votes
3answers
2k views

How to programatically check for a mouse click in QGIS

I want to know how to check for a mouse click in QGIS. I am trying to write a python plugin and want to provide functionality similar to the "Select Single Feature" tool that already exists in QGIS. ...
6
votes
1answer
3k views

Using the python shape library: pyshp - how to convert .csv file to .shp

I am trying to understand how I can use the csv module in python to open a csv file in the same folder as the python script, and then create a shapefile using the shapefile module pyshp. The csv file ...
3
votes
1answer
722 views

Get a pixel value

How can i do this operation: I want to get a pixel value fro the satellite image (Landat, GeoTIFF, 7 bands) using qgis-python. What operators should i use? (for example in qgis's Python Console) ...
1
vote
2answers
239 views

How do you get all the results from a 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 ...
9
votes
4answers
3k views

How to Batch Clip in ArcGIS Desktop 10 using Python/ArcPy?

I've come across a few similar questions for older versions of ArcGIS, but haven't found a suitable answer for ArcGIS 10. I have two polygon shapefiles that cover a large area (e.g. an entire ...
7
votes
2answers
948 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 ...
5
votes
2answers
2k views

How to convert PostGIS table to Shapefile in Python?

I want to convert a PostGIS table into a shapefile (without using pgsql2shp). In order to create a geometry in the shapefile I have to give the Xmin,Ymin and Xmax,Ymax, and the geometry which I have ...