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

learn more… | top users | synonyms

0
votes
0answers
9 views

gdal.RasterizeLayer: clip image by geometry

Stuck for few days. Trying to cut image by polygon. Have input geojson file that I convert from lat/lon coord to UTM and next need cut image by this polygon. I use 'MEMORY' to take layer in memory. ...
1
vote
1answer
36 views

Add multiple rasters using QgsRasterLayer with for loop

I am trying to create a for loop for coloring up multiple rasters simultaneously. I am able to do it for one layer, but trying to implement the for loop to do it for more than one layer is proving ...
1
vote
1answer
19 views

Smoothing grid of cells

I have a grid of cells that outline sharp transitions between different neighbour values: I would like to "smooth" the transition between the cells so that I obtain some sort of gradients between ...
0
votes
1answer
44 views

How to burn geometry to raster without shapefile, just from list of coordinates?

I have a list of coordinates points(x,y) of some multipolygon like this: [[x1,y1][x2,y2][x3,y3] ... [xN,yN]] Also can convert between lat/lon and UTM coord systems. When we use gdal.Raesterize like ...
0
votes
0answers
11 views

Polylines to raster (Input: Coordinates end point of polylines) using Python [on hold]

I have coordinates of every corner of each polyline. I need to convert the polylines into a raster image using some python code. Polylines drawn can be seen in the attached figure.So, i need to create ...
6
votes
1answer
8k views

Python GDAL: Save array as raster with projection from other file

I have an array of data, and for each datapoint I know the latitude and longitude. I'd like to save it as a GTiff with the same projection as other rasters I have. This is what I've tried so far, but ...
1
vote
1answer
19 views

Add a geometry in sqlite in pyqgis

I'm trying to create a geometry column in a table which I created. I found the following code: cur.execute('SELECT addgeometrycolumn(%s, %s, %s, %s, %s)' %(table_name, geometry_column_name, EPSGcode,...
0
votes
0answers
9 views

gdalwarp not clipping VRT to correct extent

I'm trying to clip a projected .vrt raster to an extent expressed in GCS coordinates and it's not doing what I would expect. Here is my command: gdalwarp -te -133.08813624 56.69042536 -132.69405069 ...
0
votes
2answers
3k views

Raster Calculator Workaround in Arcpy for Suitabiliy Analysis

This is my first attempt at a complex stand alone python code. I am self teaching the arcpy module, well at least attempting to. I am having a great deal of difficulty getting my site suitability ...
1
vote
1answer
504 views

Error in Select Numeric type column in pyodbc with ArcCatalog?

I created a python script that uses "pyodbc" plugin to connect a SQL Server database and write out data. It was imported in an ArcGIS 10.1 tool and run from there. try: arcpy.AddMessage('FLAG 0') ...
1
vote
0answers
8 views

Return raster that intersects another raster in gdal

I'm trying to programmatically orthorectify a bunch of Rasters (.ntf format), however I need a DEM that covers each raster in order to do so. I have DEM rasters (.tif) as tiles that cover the entire ...
2
votes
1answer
543 views

How Can i create a Vector layer from selected features qgis

In my qgis plugin i select dynamically features from a Vector layer. and currently i create a new layer from selection on combining all feature into a new feature: theField = QgsField self.theString =...
0
votes
0answers
49 views

how to create geometry type(point,line,polygon)on esri personal geodatabase*.mdb?

Qgis can not read geometry type on ms access*.mdb's table connecting with esri personal geodatabase *.mdb? This can open as test file, but unknow geometry type. Point can create using with "point ...
2
votes
1answer
55 views

How to set “draw line inside polygon” using Python?

In the QGIS properties of a layer I want to activate "draw line only inside polygon" for a specific layer, but using Python. I don't want to use the GUI for it. Can this be done? I set the line ...
1
vote
0answers
23 views

Is there a Python equivalent to QGIS Raster Calculator's “file1.asc” AND “file2.asc”

I would like to script a calculation equivalent to QGIS Raster Calculator's "file1.asc" AND "file2.asc". I have 18 data raster files which I would like to do the equivalent of ADD to each of five ...
1
vote
2answers
78 views

How to read geographic coordinates when the Shapefile has a projected spatial reference

I have a polygon Shapefile and want to read the polygon's vertices using OGR and Python. The reference system of the file is projected. However, for further processing I need the geographic ...
0
votes
1answer
241 views

Can't get the correct version of GDAL installed to use ReadAsArray without getting error in Python

Using the instructions here . . . https://pythongisandstuff.wordpress.com/2011/07/07/installing-gdal-and-ogr-for-python-on-windows/ I downloaded the following files: GDAL-1.11.1.win-amd64-py2.7.msi ...
3
votes
6answers
3k views

ExportToJPEG() arcpy script failure

I'm attempting to writing a python script that will automate exporting a set of stock maps to JPEG from their mxd files, and I'm having some strange issues getting there. I've alternatively been ...
7
votes
2answers
2k views

Automating batch load of multiple GPX files into PostGIS

I've got 50+ GPX files that I would like to "batch load" into a PostGIS database. All of the track_points data would be loaded into a "track_points" table (with typical GPS fields like lat, long, ...
0
votes
1answer
976 views

ArcPy SelectLayerByAttribute Error and how to control GP output layer name

I have a rather long script that first references an SDE feature class (non-versioned) to perform an attribute selection based on a SQL selection. I've been unable to figure out why the script will ...
1
vote
0answers
25 views

How to implement a Plotting widget into already existing PyQt4 Interface

I am using Python, PyQgis for about one week and already built a plugin for GIS 2.14 which is -so far- working pretty well. As my next step I want to add a widget to plot data to my already existing ...
1
vote
1answer
37 views

QGIS: startup.py executed twice?

To test something I have a very simple startup.py file in my .qgis/python folder: import qgis qgis.utils.iface.actionShowPythonDialog().trigger() print "Welcome chump" Python console launches fine,...
1
vote
1answer
54 views
+50

How to define border colour for rule-based style using PyQGIS?

I use the following to create a Rule-based style for a given layer which includes defining a label, expression and colour fill: from PyQt4.QtGui import QColor layer = qgis.utils.iface.activeLayer() ...
5
votes
2answers
1k views

How to remove all selection from all registered layers using QGIS plugin?

I want to remove all selection from registered layer in QGIS using Python. I tried to clear the map canvas using: self.iface.mapCanvas().clear() self.iface.mapCanvas().refresh() but the ...
1
vote
1answer
30 views

SAGA GIS work with python API error

I want to work with python API and SAGA GIS. I am very new with this work. The first step I find one module for example Slope, Aspect, Curvature and I take with right click one python script. python ...
3
votes
0answers
49 views

How to handle large tables in QGIS using python?

I'm currently writing a plugin that calculates values based on a QgsVectorLayer's attributes. To display and print the values I'm using a QgsComposerTextTableV2. I have several problems with my ...
2
votes
1answer
237 views

Plugins crashing with “No module named qgsprojectionselectionwidget” in Windows?

My Python QGIS plugin works on Ubuntu (at least for me, and all fatal bugs reported so far are solved), but when I run it on QGIS installed from the official 2.10.1 64-bit installer for Windows (on ...
0
votes
1answer
35 views

Write GeoJSON As Feature Object in Postgis

I'm trying to create a geofence/circle from a lat/long set and I'm close except that the GeoJSON that PostGIS creates differs in structure from the client library that our front-end uses. Here is my ...
1
vote
2answers
292 views

how to find that two polygon boundaries are connected?

I am working on a Geo database where there is a layer with many polygons. i want to find that which polygons boundaries are connected so that i can create new layer from that polygons and which ...
2
votes
1answer
14 views

SyntaxError with custom function using QgsFeatureRequest.setFilterExpression

def get_subsel(layer,filter): layers = iface.mapCanvas().layers() for lyr in layers: if lyr.name() == layer: request = QgsFeatureRequest().setFilterExpression(filter) ...
0
votes
1answer
64 views

Clipping GeoTIFF file by GeoJSON?

Input GeoJSON file: { "type": "Feature", "properties": { "id": 1 }, "geometry": { "type": "Multipolygon", "coordinates": [[[ [27.397511483867362, 44.161117466010516], [...
1
vote
1answer
41 views

Install GDAL python package in virtualenv on mac

I'm trying to instal the GDAL python package, preferably in a virtual environment, but when I try "pip install gdal", I get the following error: extensions/gdal_wrap.cpp:3085:10: fatal error: '...
2
votes
1answer
27 views

Creating an Interrupted Map With OGR, Mapnik and PIL

I am trying to create a simple interrupted Sinusoidal map with Python using OGR, Mapnik and PIL. The general idea is: Make 6x 60 degree sinusoidal maps For each one, make a mask to make it gore ...
1
vote
0answers
25 views

How to change which python GDAL is “connected” to?

I would like to use GDAL with Python 2.7 on Ubuntu 14.04. I have installed gdal-bin and python-gdal from UbuntuGIS following their instructions. However, importing GDAL (from osgeo import gdal) only ...
4
votes
4answers
6k views

How can I fix “ImportError: No module named qgis.core”?

First of all, I'm using Python 2.7.3, QGIS 1.8 (Lisboa) on Windows 7 pro 64 bits. Now let's go to the actual question: I have written some code (Python) that works well within the QGIS built in ...
1
vote
0answers
19 views

Convert and plot python basemap and netCDF file in UTM zone 45N

I have a netCDF file with precipitation output for one year. I have a problem with aligning the basemap and netCDF file, and plot them in the same coordinate system. The netCDF file covers the ...
0
votes
1answer
17 views

Parsing error with field calculator [on hold]

I am trying to do a simple calculation that populates a field based on a set of acreage figures. I am using if/else if statements with acreage ranges. Here is the python script I came up with. def ...
2
votes
1answer
94 views
+50

How to use Qt3 Support widgets in QGIS plugin?

Similar to this post: My plugins crashes with “No module named qgsprojectionselectionwidget” in Windows. Except I would like to also use Qt3 Support widgets (in particular, a Q3ButtonGroup). However, ...
1
vote
0answers
22 views

batch convert geojson to shapefile [duplicate]

I have a directory full of geojson files that I need to convert to shapefiles for editing in QGIS. As far as I have searched, there are no resources in GIS StackExchange that explain how to do this ...
1
vote
0answers
23 views

Segmentation fault in readasarray

I am running the following code and get: Segmentation fault (core dumped) I have no clue why, I have been using the functions many times before and now suddenly this happens. Sometimes it happens at ...
1
vote
2answers
40 views

Values extracted from NetCDF not matching original raw data

I am working with monthly rainfall data from University of Delaware which is available as a NetCDF from NOAA and raw text from UDel's homepage. I would prefer to use the NetCDF format but when I ...
1
vote
1answer
32 views

Array written by GDAL with Python script has numbers read as “nan” by QGIS?

I would like to write an array to a geotiff with Python script using the GDAL module. When I try to do something simple like copying an existing GeoTiff via reading it to an array, then, writing to a ...
1
vote
1answer
571 views

How to select and zoom in features from a QGIS Python Plugin

I'm very new to Python. I'm trying to find a way to select and zoom to the features from a QGIS layer. I've created a plugin and built a custom form. I have 3 values from the form which I need to ...
2
votes
1answer
250 views

gdal_calc works but I get a Python error at the end of each process

I have a problem while using gdal_calc by a .bat file. Here is the code : call "C:\OSGeo4w64\bin\o4w_env.bat" gdal_calc -A"D:\tuilage_script_1\tuilage\ndvi\4_810000_6370000_820000_6360000_ndvi....
1
vote
1answer
50 views

Dynamically move map canvas and main window using PyQGIS

I am trying to create plugin that will open new window with some layer, Dynamically "pan" my window, when main window is pan. So boundingbox coordinates should be the same in both windows. I need new ...
1
vote
1answer
188 views

Couldn't load plugin PRISM due an error when calling its classFactory() method in QGIS1.8 inWin8

When I load a plugin in QGIS ,met some problems : I had tried copy other Python27's files to QGIS's Python 27 file but it still does't work. Couldn't load plugin PRISM due an error when calling ...
1
vote
1answer
58 views

gdal/python WriteArray working for 8-bit but not 16-bit

I'm trying to use GDAL/python API to open a raster, do some math, then write the two resulting arrays as rastes. One is to be an 8-bit raster and the other 16-bit signed. However, only the 8-bit ...
1
vote
0answers
12 views

Getting the activeLayer() in Eclipse

I've been working on a plugin in python for qgis. I'm using Eclipse-pydev with remote-debug. I believe I'm set up correctly; I've followedthe Cookbook instructions completely. When starting remote-...
0
votes
0answers
11 views

gdalwarp fails based on output filename? does it have to do with my using -t_srs?

I am so confused by what is going on with my gdal warp. From my terminal I can enter a command for it: $gdalwarp -t_srs '+proj=ortho +datum=WGS84' test_imagery/Maui/OBS_IMAG.nitf testout3.tif ...
1
vote
1answer
56 views

GDAL python cut geotiff image with geojson file

I wrote the function which cutting geotiff image by bounding box. First image is original. At second you can see result off my code. I don't use gdalwarp or any console utilities. But I have no idea ...