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

learn more… | top users | synonyms

3
votes
1answer
224 views

Python Postgres Multiprocessing speed increase

I'm trying to speed up my PostGIS queries using multiprocessing. My current setup is using python and psycopg2 such as below. Although this has given a speed increase, it still seems like there are ...
3
votes
1answer
232 views

How come “Zoom to Polygon” always puts me in the middle of Nebraska?

This is an issue related to this question I'd asked a few days ago. I've got that code working, to an extent. Every time, though, that I double click on one of the Polygons in the attribute table that ...
0
votes
1answer
28 views

What's the reason for this Invalid Layer “Cannot open GDAL dataset …” error

When adding a rasterfile with QGIS python console there appears an error when the first letter of a rasterfile to be added is not written in capital letters. Why this behaviour? Example case1: ...
3
votes
2answers
221 views

Load and display a layer using PYQGIS

I'm having a go at using pyqgis from within the QGIS python console to load a layer from SQL Server and display it. I feel like I'm part way there but I'm having a real issue getting the layer to ...
3
votes
2answers
224 views

Per-pixel (statistical) calculations on a raster stack using GDAL

In R, it's relatively trivial to perform per pixel calculations based on a raster stack (e.g., get std.dev for each pixel on a 12 layer GeoTIFF). Unfortunately, the speed is less than desirable when ...
0
votes
2answers
24 views

Aggregating rasters with GDAL

I have a set of files that have been mosaiced into a global VRT in a particular projection and resolution. However, I have a need to report statistics on a (say) one degree grid, where the reported ...
0
votes
0answers
38 views

Proxy.cgi for OpenLayers reading from GeoRSS but not from WFS

I'm having trouble with the standard proxy.cgi written in Python for OpenLayers. Here's my code: #!C:/Python27/python.exe -u """This is a blind proxy that we use to get around browser restrictions ...
0
votes
0answers
38 views

Creating symbology by category in python?

I'm trying to create a python script that creates color-coded symbology by county for multiple maps with different data. I've never created a layer file for the purposes of symbology before, but I ...
3
votes
1answer
154 views

draw lines with an angle inside a rectangle in python

I am trying to make a plugin for Qgis with python. I have the four corner coordinates for a rectangle. I want to give the user the inputs, line space and angle (0 -180 degrees). With these inputs, I ...
3
votes
2answers
52 views

Converting huge multipolygon to polygons

I have a shapefile with some huge multipolygons, with 100.000's of parts. What would be the easiest way to split them to singlepart polygons? I'm looking for something like QGIS ”Multipart to ...
0
votes
1answer
109 views

Writing shapefile with projection defined crashes fiona

I've just started trying to use Fiona to write out shapefiles. I found the example code below, which seems to work fine from shapely.geometry import mapping, Polygon import fiona # Here's an example ...
1
vote
2answers
25 views

Rename LAS Files - Python

I have a bunch of LAS files that have been delivered with different naming conventions. I want to rename the files to all have the same uniform naming - based on the easting and northing coordinates ...
3
votes
1answer
24 views

How to find the distance between start of line and start of raster with arcpy/python?

I'am creating a python script tool for ArcGIS Desktop 10.1 to extract profiles. I’m using stack profile to extract values to a table but stack profile only outputs values where the line and raster ...
2
votes
1answer
51 views

How do I rename rasters in an mxd by using my csv?

I have the following data in a csv: RasterName First name Raster 1 Aaron Raster 1 Paul Raster 2 Bryan Raster 3 Cranston Raster 3 Vince I have added these ...
0
votes
1answer
22 views

QGIS Python console - save image from bounding box

I want to save an image from QGIS but the save image functionality feels limited. My question is if it's possible to use the python command line to save an image at a specific zoomed in scale and to ...
1
vote
1answer
23 views

pyQGIS - Data Source is Invalid

Why I am getting Data Source is Invalid in python console of QGIS when running: vlayer = QgsVectorLayer("home/sanjayr/Desktop/india-latest.shp/buildings.shp","sanjay","ogr") I am using QGIS 2.4 on ...
2
votes
1answer
35 views

Unicode Decode Error for shapefile in Python

I have Python script for converting shapefiles to Geojson. My code works well if I use some usa data, but when I want to use some other encoding, it gives me this error: Traceback (most recent ...
2
votes
1answer
163 views

How to use SAGA ShapesToGrid via Processing in a Python plugin?

I run these lines in my code: vectorlayer_vector = ftools_utils.getVectorLayerByName(inputLayer) Elevation = self.lineAttrib.currentText() cellSize = int(self.linePix.value()) outPath = ...
9
votes
5answers
267 views

Raster diff: how to check if images have identical values?

Is there a means to check to see if any 2 given raster layers have identical content? We have a problem on our corporate shared storage volume: it's now so big that it takes over 3 days to conduct a ...
2
votes
3answers
36 views

How to increase raster extent by filling extent with no data using ArcGIS Desktop without Spatial Analyst?

I am using feature to raster to rasterize water polygons. It only makes a raster the extent of the features in the polygons, whereas I would like it to be the extent of another existing .tif image. ...
2
votes
0answers
45 views

Where is my Polygon?

I created this script to merge all of the polygons in a shapefile into a single polygon. I am using Python 2.7.5, Shapely 1.3.0, and Fiona 1.1.5. def merge(path_in, path_out): #Import Libraries ...
2
votes
0answers
28 views

Performing buffering and intersection with script in PyQGIS

I wrote a script that performs the intersection of two layers: The first Layer -> layer1, represents the rivers The second Layer -> layer2, represents a set of circular dots distributed in a ...
1
vote
0answers
28 views

Clipping between features within a single vector?

Is it possible (via the Qgis API and friends), to clip polygonal features within a single vector layer? The hope is to accomplish this without having to duplicate the feature into a new layer. ...
2
votes
0answers
28 views

Any solution to mosaic Modis MOD13Q1 using batch file?

I have a Modis MOD13Q1 product for Pakistan, four tiles cover my complete area and I have data consisting of 14 years, after every 16-day interval. I want to mosaic them using a batch file which ...
1
vote
0answers
36 views

FWTools Python ImportError: DLL load failed:parameter is incorrect [duplicate]

Please, can anyone help me solve this issue? Please find the attached snapshot for your reference. I am working on a Windows 7 Professional, Service Pack 1, 32-bit laptop.
1
vote
1answer
47 views

UnicodeDecodeError: While installing gdal in a new Python Virtual Environment

I was trying to create a Python Virtual Environment for some initial GIS development. I installed pip and virtualenv and then tried the following commands from the Linux-Terminal to accomplish the ...
2
votes
2answers
81 views

How we can get output for os.system() in python?

I wrote the following command in Geoserver rest-api using curl: cmd=curl -v -u admin:geoserver -XGET -H "Accept: text/xml" ...
4
votes
1answer
58 views

QGIS Processing Progress

I have been developing a python plugin that uses Processing algorithm for raster calculations. I want to support the gui with progress bar. How can i connect Processing job to progress bar? I found ...
1
vote
1answer
34 views

Overwrite option on a standalone ZonalStatisticsAsTable using ArcPy

How can I code an "overwrite option" on a standalone ZonalStatisticsAsTable using ArcPy? I don't see any overwrite option from a Esri example. # Execute ZonalStatisticsAsTable outZSaT = ...
2
votes
2answers
148 views

How can I set the settings of an Address Locator within a Model or arcpy?

I am creating a model that processes a large road dataset, then creates an address locator from the roads. The Create Address Locator tool does not allow me to set options like Spelling Sensitivity or ...
1
vote
2answers
42 views

How to skip over errors created by cursors running through empty tables?

I am trying to automate the creation of many different feature layers were their content is created by a cursor. Sometimes during the automation, a feature layer may be empty, this is okay, but as the ...
2
votes
3answers
142 views

Clipping faster (i.e. in bulk/batch) in ArcGIS for Desktop?

I have 100 different input vector layers and one clip feature vector layer. I have to clip them 100 times but its a large amount of work. Is there any Python script (ArcPy) in ArcGIS for Desktop ...
2
votes
1answer
134 views

Python Syntax Error when running Python Snippet of successful geoprocess

I am having an issue with a simple python snippet. Here's the background: I wanted to include an additional step in a nightly update script that replaces characters in a field that simply do not play ...
1
vote
3answers
73 views

How to generate automatically the name of output parameters in a python script tool? [on hold]

I have some Python script tools in ArcGIS for Desktop. I need to reproduce what all geoprocessing tools do when the first input parameter is introduced: autogenerate a workspace and basename for the ...
0
votes
1answer
144 views

Python Geoserver gsconfig create resource from Postgis store table

I've working Workspace and PostGIS store in GeoServer. I would like to use python and gsconfig to create new resource/new layer from existing PostGIS table, with: computing bbox, adding abstract, ...
0
votes
1answer
149 views

Polygon Neighbors Analysis script (ArcPy 10.1) producing erroneous results?

I'm struggling with a python script that is supposed to calculate a field for a polygon feature class. The calculation is of the average of a field value (P_TOT_DEV) for each of a given polygon's ...
2
votes
1answer
35 views

QGIS way to import OSM/Google Maps but remove or exclude extraneous areas, limit geographically the use of OSM

GIS Newbie question, perhaps: But I am looking to place an Open Street Maps/Google Maps layer underneath the rest of my shapefiles for referencing purposes. Let's say for instance, that I am looking ...
14
votes
5answers
6k views

What's the easiest way to install GDAL and OGR for Python?

I am developing some code in Python, and I want to use the GDAL/OGR python bindings. What is the minimum I need to install in order to use the GDAL and OGR python bindings? What is the easiest way to ...
1
vote
1answer
30 views

Copy Parallel editor tool - python script / modelbuilder [duplicate]

Is it possible to use Copy Parallel tool in a python script or in modelbuilder for ArcGIS 10.2? Does anyone have a workaround or script for a tool that essential does the same thing as Copy Parallel. ...
0
votes
1answer
39 views

How to add new columns with attributes in existing Qgis layer?

How to add new columns with attributes in existing Qgis layer? Doing the "same thing" here described
3
votes
1answer
219 views

How do I write XML metadata with Python?

Some Python software I have written generates raster files via GDAL. I would like the software to create an XML metadata file for each raster so that I can include details about how the raster was ...
0
votes
0answers
22 views

Importing OGR from OSGEO Issues

I am trying to run: from osgeo import ogr and I get: Traceback (most recent call last): File "", line 1, in from osgeo import ogr File ...
3
votes
1answer
222 views

How to clip a Oracle query layer directly in a Python script?

I have a query layer directly running from ORACLE database in a MXD. I want to clip this layer with a layer being created in another MXD in a Python based tool. My question is to do this clip ...
2
votes
2answers
325 views

How to use gdal module in python

I am trying to import gdal modules from osgeo installed in my win64x machine but I get the following error: Traceback (most recent call last): File "", line 1, in from osgeo import ogr ...
-1
votes
1answer
148 views

Python code in Field Calculator gives General error executing calculator ERROR 999999: Error executing function?

In a shapefile, I have Field named Elevation with a text field containing integer ranges stored as strings: 1 - 2 3 - 6 2 - 3 8.5 - 12 11 - 12 I need to categorize it using rule that if Elevation ...
3
votes
1answer
833 views

Setting the extent for a QGIS map using python

I am writing a stand-alone application in Python/QGIS that simply creates maps. I want to load vector/raster layers, set symbology, set extent At the moment, that is all! Currently I am just using ...
2
votes
1answer
210 views

Arcpy Network Analyst solver error

Hello GIS Stack Exchange, I am finding it difficult to load locations to sublayers using python in ArcGIS 10.0 network analyst Vehicle routing problem. I'm also having some trouble debugging my ...
1
vote
1answer
75 views

Why is feature.geometry() None in my user-defined expression function?

I'm trying the user-defined expression functions for QGIS, as listed on Nathans blog: http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/ I always get the feature.geometry() as ...
1
vote
0answers
39 views

Cause of Field Calculator UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 5: ordinal not in range(128)? [on hold]

def Befahrung(value1,value2): if value1 is ' ': return ' ' else: return "G:\\Example\\" + str(value1) + "\\File_" + str(value2) + ".pdf" I try to create a field with a hyperlink. It works ...
44
votes
13answers
10k views

Resources for learning Python programming with generic GIS goals in mind?

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) For ...