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

learn more… | top users | synonyms

9
votes
1answer
607 views

Import GRASS and SAGA modules to python script

I'm new at this. I am "building" a python plugin for qgis and I want to import modules from GRASS and SAGA but I don't understand how to do it. The plugin I want to import is Kriging interpolation ...
9
votes
4answers
507 views

ArcView 3.x Avenue Bitmaps (Tabs?) vs. ArcView 10 Python Cursors

Note: While this question has an answer, any further tips for optimizing a cursor process would be greatly appreciated. I will be monitoring for any updates. Currently, my boss (who works in Avenue) ...
9
votes
2answers
3k views

Measuring distance in spherical Mercator vs zoned UTM

I've got points in WGS84 lat/long and I'd like to measure "small" (less than say 5km) distances between them. I can use the haversine formula from http://www.movable-type.co.uk/scripts/latlong.html ...
9
votes
2answers
666 views

Can ArcGIS and OSGeo4W share the same python install?

I don't like unnecessary duplication. Is it possible to install python only once and have both ArcGIS and OSGeo4W use it?
9
votes
2answers
648 views

Python, GDAL and building raster attribute tables

I have an integer raster for which I would like to build a raster attribute table using Python and GDAL. I can create a GDAL raster attribute table in Python as follows: >>> rat = ...
9
votes
2answers
2k 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 ...
9
votes
2answers
4k views

How to make a button that calls a python script as a command rather than a script tool?(ArcMap 10)

I believe that in Arc9.3, commands could be created using VBA scripts. To add a custom command, you would navigate to Customize > Toolbars > Customize... and click UIControls. However, UIControls is ...
9
votes
3answers
208 views

Setting symbol descriptions of ArcMap layout legends from table?

ArcMap has the ability to show an extended description for each item in the symbol list. How can I populate that property from a table? The goal is to avoid having to edit each symbol one by one in ...
9
votes
1answer
442 views

Is there a way to properly have GDAL raise exceptions in Python?

I am working with GDAL in Python and have wanted to get GDAL to raise exceptions so that I can do something useful with them. For instance if a file cannot be opened with gdal.Open() I would like to ...
9
votes
1answer
4k views

“Field Mapping” in ArcGIS 10 - ArcPy

I've wrote a Python script that does a spatial join and some simple calculations. My problem is with setting the merge rule for one specific field, and leaving the rest of the fields as is. For ...
9
votes
3answers
2k views

ArcGIS Python Tool - Importing Custom Script Into ToolValidator Class

I had posted a question last week about customizing a ToolValidator class and got some very good answers. In working with the proposed solutions, I have created a custom module that performs queries ...
9
votes
4answers
5k views

Bilinear interpolation of point data on a raster in Python?

I have a raster that I'd like to do some point interpolations with. Here is where I'm at: from osgeo import gdal from numpy import array # Read raster source = gdal.Open('my_raster.tif') nx, ny = ...
9
votes
1answer
2k views

When iterating over a vector layer with pyqgis, how do I check whether a feature is selected?

While iterating over a vector layer using the following code (summerized from the example in the pyqgis cookbook), is there a way to check whether a feature is selected? provider = ...
9
votes
2answers
768 views

GeoTIFFs made in GDAL don't have min/max range when loaded in Arc/QGIS

I'm creating some floating point rasters in GDAL with the GeoTIFF driver. When I load the resulting images into QGIS or Arc the default symbology puts the min at -3.40282e38 and max to 3.40282e38, so ...
9
votes
3answers
1k views

How to populate an undirected graph from PostGIS?

This question is more related to resources that I might not have identified yet, although I've been searching the web for a while. In the project I'm working at the moment I need to run a ...
9
votes
1answer
354 views

Is there a way to use ArcPy and PyGRASS tools in the 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. ...
9
votes
3answers
3k views

Setting parameters in Script Tool using Python

I hate to bug you all with the same problem over and over again but I run into a new problem everytime I make a slight change to the code. All I did to the code below was to replace field names to ...
9
votes
2answers
446 views

Best design for Open Source Python / PostGIS prototype

I am writing a data intensive web application that is delivered through apache. My question is about how to best arrange processing given that there are multiple options. I have at my disposal ...
9
votes
1answer
1k views

Importing GDAL from Python window of ArcGIS for Desktop?

I am trying to run some Python code using the Python window in ArcGIS 10.1 that uses both the arcpy and gdal modules. However, when I try and import the gdal module I get an error: ImportError: No ...
9
votes
2answers
489 views

Generate near table for x number of neighbours using arcpy

There are 3 likely scenerios that I am trying to capture near distances for: An interchange subway station, which has 2 or more neighboring stations. That is, the station in question connects 2 or ...
9
votes
1answer
963 views

Arcobjects in Python: assign interface to objects with feature (shape) geometry

I am trying to use ArcObject in Python. I do have problem with assigning an interface (i.e. IZ.InterpolateZsBetween) to my object with geometry data, code is: from Comtypes.client import ...
9
votes
2answers
685 views

Scriptable alternative to ArcScan (particularly vectorising lines within tolerances)

Sadly the answer to this question suggests that it is not possible to script ArcScan from within a python script. Therefore, does anyone know of any alternatives to ArcScan (either within ArcGIS, or ...
9
votes
2answers
308 views

Can ArcGIS ModelBuilder open Excel file for manual editing, then feed those edits back into model?

I have been tasked with creating a model using ArcGIS ModelBuilder, that initially runs a couple of geoprocessing tasks, before then joining an Excel table to the result of those geoprocesses. ...
9
votes
1answer
695 views

Arcmap Select by Attribute with Python

I would like the following to select (highlight) the "project" layer that intersects the grid, and then pull a record from the selected "Grid". I do not need to save the layer. Note: Running the ...
9
votes
1answer
621 views

How to implement MultiValue Parameter with Multiple Columns?

This might be a simple question, but I haven't been able to find a straightforward answer. I'm working on an ArcGIS (9.3) Python script. One of the inputs is a list of features. For each feature, I ...
8
votes
4answers
3k 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 ...
8
votes
4answers
2k views

how can i convert a shapefile to lat and lon boundaries?

i have a shapefile of country subdivisions and i would like to extract an array of bounding lat and lon for each division.. is it possible to do?
8
votes
3answers
9k views

Define Workspace for SDE Connection in Python

How do we define SDE Connection for workspace in Python Scripting?
8
votes
3answers
3k views

How do I use variables from one Python script in other Python scripts?

I want to set up a single python file containing variables that have the locations of all my data sources. This would then be used by all my other scripts, then as a data source changes, I only have ...
8
votes
4answers
274 views

Subset Folder Contents ArcPy

I have about 1500 .txt files within a folder named 3410001ne => 3809962sw. I need to subset about 470 of these files to process with a Python script. Below is the section of code prior to my for ...
8
votes
3answers
4k views

How to round a column in attribute table (ArcMap)

I want to use the Field Calculator in ArcMap to round an existing column to two decimals. Currently I have a column that is 6 decimal places long and would like to simply round it down to 2 decimals. ...
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 ...
8
votes
2answers
3k 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 ...
8
votes
2answers
449 views

How to add different sized rasters in GDAL so the result is only in the intersected region

I'm writing a Python method that adds two rasters and generates a single raster output. For reasons beyond my control, the extents of the input rasters are different, but they do overlap. Is it ...
8
votes
1answer
1k 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. It would be awesome if it were possible to automatically be updated with new filenames, and possibly even ...
8
votes
4answers
2k views

Best way to find the polygons crossed by a line

I'm trying to find all the polygons crossed by a single line (a GPS track). I'm using the OGR library (from python) for computing this, but it's currently a bit 'brute-force' (and slow). For every ...
8
votes
8answers
8k views

How to Remove return/newline (\n) character from Field using Python and Field Calculator?

I have a geodatabase table with a field that I'm trying to remove return characters (new line). I found this post (How can I remove (chomp) a newline in Python?) of how to do it, however it is not ...
8
votes
4answers
1k views

Is there a mapping between OGR and python data types?

I'm writing a shapefile using OGR in python, creating fields on-the-fly from a python data source. Creation of a new field requires an OGR data type, is there a mapping between OGR and python data ...
8
votes
6answers
1k views

How to integrate SAGA Python Modules into ArcGIS Desktop?

I have been having a look at SAGA (http://www.saga-gis.org/en/index.html) and it seems to have some nice tools for geoprocessing. I was wondering if anyone out there has had any luck bringing SAGA ...
8
votes
5answers
1k views

Will there be a Python API for ArcGIS Server?

It seems like an obvious next step given the big push towards Python in ArcGIS Desktop at 10.0. Are there any limitations of Python compared to javascript, flex, etc that would prevent ESRI from ...
8
votes
2answers
4k views

How to fully load a raster into a numpy array?

I have been trying to check my filters on DEM raster for pattern recognition and it is always resulting in missing last rows and columns(like..20). I have tried with PIL library, image load. Then with ...
8
votes
2answers
870 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 ...
8
votes
1answer
160 views

How to save python session in QGIS?

After running a lot of scripts in QGIS' python console, I have more than 10 dictionaries and lists, and I need these for further analysis. Is there a way to save python session, with all these ...
8
votes
1answer
563 views

Fastest methods for modifying attribute tables with Python?

A while ago, I wrote a quick Python function for converting an attribute table to a python dictionary, where the key is taken from a user-specified unique ID field (typically the OID field). ...
8
votes
3answers
410 views

Using ESRI geoprocessing services from a non-ESRI client (Python)?

I'm thinking it should be possible to consume an ESRI Geoprocessing service from a python script without invoking ArcPy or needing an ESRI installation on the client machine. For example I create a ...
8
votes
1answer
2k views

Polygon overlay with Shapely

I'm trying to capture all the non-overlapping polygons indicated below using Shapely (given polygons A,B & C). Moreover, I'm hoping to do so without iteration, testing for intersect etc. The ...
8
votes
4answers
431 views

Joining lines when direction is not known

I am struggling with this problem. I have a polyline made up of several segments. Each segment is made up of points, each point identified in 3D space by coordinates and elevation. Together, if ...
8
votes
3answers
8k views

How to create a button in Arcmap 10 to run a Python program?

I have a script that I want to run within ArcMap when a button in a toolbar is clicked, and so far I have only been able to make the script into a script tool. I need it to run as a command, not as a ...
8
votes
4answers
683 views

How to split single address field into 4 fields (House No., Direction, Name, Suffix)

I have to do some massaging of our parcel data to make it usable by a program in sheriff helicopters. The program requires one of the following address formats within the fields: Our addresses are ...
8
votes
2answers
365 views

Is there a way to refresh imported modules in a ArcGIS Python Toolbox?

When using a python toolbox (.pyt) in ArcMap, I'll typically follow a pattern where the .pyt file itself is simply a wrapper to collect input arguments and define the tools themselves. Supporting ...