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

learn more… | top users | synonyms

5
votes
1answer
67 views

Sending a https request from a QGIS plugin using urllib2

I'm developing a QGIS plugin that needs to send https request to an API. I have to use urllib2 (see below if you want to know why I don't just use the requests package) The first request I need to ...
3
votes
2answers
223 views

Automatic selection of pixels, from a raster series, greater than minimum image of the series

Given a series of rasters, and the raster image of the minimum values of the series, I am looking for a python script capable of selecting, for each raster, the pixels whose values are greater than ...
1
vote
1answer
41 views

Writing geoJson from rasterstats

How would I write a proper geoJson, readable by a GIS, from the results of the rasterstats package? stats = zonal_stats("somePolygons.shp", "someTif.tif", ...
0
votes
1answer
55 views

NumPy to GeoTiff for use with Gdal

I have a few NumPy arrays: lat, lon, and 6 data bands. I'd like to convert these to GeoTiff and then apply the gdalwarp function, based on a specific projection, to each band. Is there a standard way ...
2
votes
1answer
24 views

AttributeError: 'SpatialReference' object has no attribute 'ImportFromESPG'

I am trying to create a spatial reference using ImportFromESPG and this is what is returned: AttributeError: 'SpatialReference' object has not attribute 'ImportFromESPG' Code and error are copied ...
3
votes
2answers
119 views

Geopandas Polygon to matplotlib patches Polygon conversion

Unfortunately geopandas plotting is extremely slow and takes a lot of resources, hence I would like to use instead matplotlib for plotting. When I use pure Fiona to open and read the shapefile I ...
1
vote
1answer
48 views

Why are there my_form_open() Python functions in my QGIS project file?

I have a project open with 6 layers (MapInfo .tab format), have set the style for each layer and added labels for 1 of them. So for a simple project the .qgs file is about 2000 lines long and among ...
1
vote
1answer
24 views

Updating a raster using a shapefile [closed]

I have a huge raster file and want to increment all the values within a relatively small shapefile by 1 in Python. Speed is of critical importance, as I have to do this many times. I have been ...
1
vote
2answers
67 views

Point Click for Coordinates - Stand Alone QGIS in Python

I am implementing a stand alone version of the answer to this question > How to programatically check for a mouse click in QGIS My code is below. The code compiles without error, and the toolbar ...
3
votes
1answer
107 views

How to convert multiple csv files to shp using python and no arcpy?

At my internship, I have been asked to learn Python on the job. Its been a rough road never having coded before so please forgive me if my problem is elementary. The Lightning CSV files I am ...
1
vote
0answers
13 views

Duplicate an existing geoserver style using gsconfig

I am playing around with gsconfig and trying to assign a new style on a layer I have created. What I want to do is to actually create a new style, which is the same with an existing one. I searched ...
1
vote
0answers
32 views

Find and filter points within a variable radius

I have a set of projected spatial points (x,y,id,dist,value) that needs to be filtered. For each point I have to find the other ones falling within a variable distance. For each selection, I need only ...
3
votes
1answer
78 views

get log of internal functions called by qgis

Is there a way to know which internal python functions are used by QGIS? e.g., when I click on "add vector layer" button I would like to know the functions that are called by QGIS. It would simplify ...
1
vote
2answers
61 views

Renaming shapefiles and raster files with Python

I'm trying to add "_Kiwi" to the name of multiple shapefiles and raster files in a folder C:\data. For the files with multiple extensions (.shp.xml for example), I can't get the files to rename ...
1
vote
1answer
54 views

How to filter out layers with QgsMapLayerComboBox?

I am using Qt Designer 4.8.5 to develop a plugin (with QGIS 2.14.3-Essen). I recently started to use QgsMapLayerComboBox widgets instead of the conventional Combo Box widget. However, I want to ...
3
votes
1answer
75 views

Add field and calculate expression with PyQGIS

I want to use PyQGIS to add a new field and calculate the values for each feature. Similar to Field Calculator option. My 'Field Calculator' expression is for example: y(start_point($geometry)) from ...
1
vote
0answers
29 views

Qgis standalone script using eclipse IDE -No data provider available issue

I know, the question is asked few times also in this forum but i apply already the presented solutions without any chance to fix the problem. In General the source code looks like the following: from ...
3
votes
2answers
47 views

Find common borders of features and get their attributes using fiona and shapely

I would like to find neighboured features in a shapefile using fiona and shapely. As shown in this answer http://gis.stackexchange.com/a/95595/62250 it's easy to get common borders between features. ...
1
vote
1answer
58 views

How can I add output vector to a list to loop a geoprocessing on it?

I have about 18000 circular buffers that I want to transform in some kind of a wind rose. To do this, I transform the buffer polygons to lines, create points along the lines on the wind directions ...
1
vote
1answer
45 views

Read only geometry from shapefile with python/geopandas

I would like to open a shapefile(shp) without loading the attributes(dbf), as I do not care about attributes and it takes about 25 minutes to load them. I am using Python Geopandas, so any Fiona or ...
2
votes
1answer
41 views

How to use create a plugin that contains a set of processing scripts using Qgis Script feature?

I have some script that I would like to share easily. I have read here that its possible to create a plugin using a set of scripts using "Scripts/Tools group in the Processing toolbox, double-click ...
1
vote
2answers
50 views

Rpy2: how do I use the function 'as' (r library methods) in python?

I want to coerce an object of class Raster Layer to class SpatialPixelsDataFrame since that is required as input for the function autoKrige from the r library automap. However, when I try to use as ...
1
vote
1answer
122 views

Regrouping points together qgis based on a sum

I work with QGIS and Python. I have a vector layer containing points. Each point has an attribute called 'number of houses' I want to dissolve this vector layer in many areas, each area must contain ...
1
vote
0answers
28 views

Using Python to alter the drawing layers visibility within the layer properties?

Does anyone know of a way that I could programmatically access and alter the visibility of each individual drawing layer found within the layers property dialog box? The CAD file that I have brought ...
1
vote
1answer
40 views

Statistical properties of raster image

I want to calculate mean and standard deviation of a raster image. In QGIS zonal statistics, we can calculate it within a polygon or a vector. But I want to calculate for whole image. In Python I'm ...
0
votes
1answer
33 views

How to Convert 3D coordinates to 2D coordinates for R-Tree?

I am trying to implement a bounding box via a spatial index and get an error stating that I must either provide coordinates as either (minx, miny, maxx, maxy) or (x,y) for 2D indexes. I've tried ...
2
votes
1answer
74 views

Cannot update GDAL on Ubuntu

I am trying to use GDAL_Rasterize and found a link via Google that suggested that there were bugs in older versions. I am running Ubuntu 14.04 LTS and 'gdalinfo --version' gives me 'GDAL 1.11.2, ...
3
votes
1answer
46 views

Concerning “Error when using r.series in a python script”

Based on the "Error when using r.series in a python script" discussion (Error when using r.series in a python script) and based upon the solution given by Joseph I tried to make the same but by using ...
1
vote
1answer
69 views

PyQGIS Processing - wrong number of parameters

I'm facing a very strange issue from the module Processing using it as a standalone (not in the Qgis python console). I'm trying to create voronoi polygons from a points csv file. I can load my file ...
2
votes
1answer
79 views

Creating lines from points in QGIS, python error ( 'NoneType' object has no attribute 'asPoint' )

I'm new to Qgis, and i'm stuck with a simple task, I have a csv file with points coordinates and i would like to connect those points in a path, I'm working with wildlife movement data. i've tried ...
8
votes
2answers
179 views

How to set transparency to multiple raster values with Python

With the following code I can set 100% transparency to raster value 0: map=None for lyr in QgsMapLayerRegistry.instance().mapLayers().values(): if lyr.name() == "some_layer": map= lyr tr=None ...
1
vote
0answers
66 views

Find Properties of Nearest Line Segments to Point in Python

I have been trying to find a workable Python approach to finding nearest line segments to one (or more) points, and came accross @gene's solution to @RustyMagoo's problem here: from shapely.geometry ...
0
votes
0answers
42 views

How to store large time series of raster images

I've got a large time-series of rasters, derived from satellite images. Each raster is about 2000 x 2000 pixels, and I've got about 10,000 individual images. I'm trying to work out what the best way ...
1
vote
1answer
88 views

How do I fill a Field Combo Box with vector layer fields in QGIS?

I am new to python and I am trying to write my first plugin for QGIS. Earlier I asked this question to find out how I could populate a combobox with point vector layers (and nothing else). I've been ...
4
votes
0answers
53 views

Cannot Open VRT of Sentinel2 image created by AutoCreateWarpedVRT

I am trying to create a warped VirtualRaster of a Sentinel2 image. Here the Python code I tried: from osgeo import gdal, osr srs = osr.SpatialReference() srs.SetFromUserInput('EPSG:32632') gdal....
3
votes
1answer
67 views

How do I fill a combobox in QGIS with only points vector layers?

I'm new to writing plugins in python for QGIS. I've been searching on internet for a while and wrote the code below. Even though it fills my combobox, all layers (rasters, vectors of all geometry ...
1
vote
1answer
27 views

Making a shapefile or kml tiles from a file that says it has no GCP

Learning my way through the GIS world, i was able to create a nice script to handle some geotiffed nitf files. Could create png, thumbnails and even kmls from these files with GDAL. Then I have ...
2
votes
0answers
30 views

Exiftool.exe in QGIS [closed]

I am developing a GIS application and in my code I need to call the exiftool executable which is installed in a different path. I call in command prompt and in OSGEO4W shell and both are fine. But ...
0
votes
0answers
22 views

splitting multipolygon with line

I am developing a QGIS plugin in python using mostly OGR that clusters features based on several conditions. One of the steps is to split the different multipolygon features (blue selection in image) ...
1
vote
2answers
30 views

Gdal vsicurl not working

I'm currently using gdal version 1.11.2 (also tested this on 2.0.0) to open AWS Landsat-8 data directly from its url. If I manually test the link in the browser, it works. If I use /vsicurl/ the ...
4
votes
1answer
78 views

point created on a line not precisely on line

In QGIS I wanted to move points to the nearest lines. I checked the solutions here, but there are using tools which I am not familiar to yet(POSTGIS or GRASSGIS). I figured out my own way with using ...
4
votes
1answer
66 views

How to use joinFieldNamesSubset from QgsVectorJoinInfo class

I have written a small python plugin to refresh a join on a point layer in QGIS. point_layer=None for lyr1 in QgsMapLayerRegistry.instance().mapLayers().values(): if lyr1.name() == "point_layer": ...
0
votes
0answers
30 views

Creating superoverlay from geotiff covered whole globe, shouldn't of?

I am new to this GIS world and found this blog post: https://developers.google.com/kml/articles/raster#step-1-download-and-install-gdal Following its instructions I used my own geotiff (ntif) image ...
1
vote
0answers
18 views

Icon in title of dockwidget

Is it possible to incorporate an icon in the title toolbar of a dockwidget? Semi-classification plugin has this. Is it possible?
1
vote
0answers
22 views

Load a GeoJSON layer with mixed geometries via QGIS's Python module

I have been able to connect my collection in MongoDB , write and store the collection to as .json file and load the GeoJSON file as a layer by QGIS's Python module unless there are mixed geometries. ...
4
votes
1answer
55 views

Register custom qgsfunction in pyqgis

I'm using pyqgis within an standalone application. Now I wanted to create a custom expression to to use as filterExpression in rule of ruleBasedRendererV2. (I tried the renderer with existing ...
1
vote
2answers
60 views

Preserving special chars using osgeo.ogr.Driver to shape in Python?

I am converting kml files to shape and run in to the problem that special characters are not preserved. #!/usr/bin/env python # -*- coding: utf-8 -*- import os, ogr, osgeo, sys ogr.UseExceptions() # ...
0
votes
0answers
42 views

Merge neighbors together Qgis Python

I have one layer which contains lots of features (polygons), each feature represents a house and each house has an attribute called 'number-of-habitant'. What i want to do automatically with python is:...
1
vote
0answers
37 views

Spatially Analyzing two layers within same File Geodatabase using Python / Shapely?

I'm using a nested for-loop to do Shapely analysis between two Python lists created via two pre-reads of the same GDB file. One list contains all the features of a particular layer while the other ...
2
votes
0answers
44 views

Set Snap Mode with PyQGIS

I am trying to set snap mode within QGIS plugin. So far, I have tried: QgsSnappingUtils().setSnapToMapMode(QgsSnappingUtils.SnapAdvanced) and QgsSnappingUtils().setSnapToMapMode(2) without ...