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

learn more… | top users | synonyms

2
votes
1answer
57 views

Shapely & RTree vs. PostGIS/PostgreSQL?

I would really like some insight to the pros and cons of one approach versus the other. I recently wrote some python code that inspects two layers of the same test ESRI GDB file using RTree (bounding ...
0
votes
1answer
30 views

Numpy raster reclassify outputs only 2 out of 6 classes

I have a raster (.tif) which I want to classify (6 classes) using gdal, python and numpy. The cell values range from: MIN = -30.9847 to MAX = 7.3505. From the first two answers in this question, I've ...
3
votes
1answer
33 views

Re-import custom functions without restarting QGIS

I have a python file (in [user]\.qgis2\python) with some functions that I'm working on. It's just a .py file with a bunch of def function_1, def function_2 etc. in it. On startup I import the .py file ...
0
votes
1answer
44 views

Import OSM data in postgis with python script

I want to import OSM data (way and nodes) in postgis database with a script pyhton, I found in the internet that I should create a schema but I don't know how and I really don't know what to put on ...
0
votes
0answers
33 views

Error when using gdal_calc.py

I'm trying to perform some raster calculations (ex:A+B, A*(A>0)) using gdal_calc.py, but I'm stuck with an error when I try to make this simple test command: import subprocess import sys ...
2
votes
0answers
29 views

Python Shapely - filling small gaps between multi polygons

I have a set of rectangular polygons, which currently form a directional path. The library I am using is Python Shapely / GeoPandas. The issue I am having is as the path changes direction, there are ...
0
votes
0answers
56 views

Login to USGS Earth Explorer and download Landsat imagery with Python

I want to login to the USGS Earth Explorer website at http://earthexplorer.usgs.gov/ with Python and download imagery from the Landsat Archive collection just by giving it username,password,path/row (...
2
votes
1answer
37 views

QGIS Field Pyculator Reclass

I'm new to the QGIS Pyculator and need to reclass a field ('AP') based on another field ('Mag'). What I have so far, from the ArcGIS field calculator: def Reclass(Mag,AP): if Mag>= 2000: ...
0
votes
1answer
47 views

Build GEOTiff file using Python GDAL

Is there a way to add data to a GEOTiff file in a loop? I can make one using WriteArray like so: dataset.GetRasterBand(1).WriteArray(array) But whenever I put it in a for loop it just overwrites ...
0
votes
0answers
38 views

installing GDAL on cent os7 setup.py egg_info failed

I saw this post here: Install GDAL on CentOS 7 And got the EPEL 7 installed, then did a sudo yum install gdal and it did its thing without errors. However when trying to do a sudo pip install gdal ...
2
votes
2answers
63 views

Save line geometry as points geometry in QGIS (pyqgis)

I have line and polygon layers. I want to make a list of points' coordinates (ends or begginings of lines), which are touching the polygons. The coordinates which I need are selected as yellow. ...
1
vote
1answer
30 views

masking multiband with rasterio

I have 2 multiband rasters and I want to mask some areas of one of them with values of the other one, so I write this code (I can't figure out why is not working): import os, rasterio import numpy as ...
1
vote
0answers
25 views

Use Function V.clean of the grass tool in a script pyhton

I need to integrate V.clean functionality of Grass in a script python. this functionnality is accessible in Qgis (Processing->tools). I found that I should use Grass API but I don't know the code ...
1
vote
0answers
35 views

How to extract the study area from a netCDF by a shapefile boundary with Python?

I have a global size netCDF document, the variable is three dimensions, including time. lat and lon. I have a shapefile boundary for my study area, both of them have same projection. How can I extract ...
0
votes
2answers
38 views

PySal and PostGIS (maybe via Shapely). How can these two interact?

I'm trying to learn the use of PySal and Python. As I'm already regular user of PostGIS, I would like to integrate the database as the storage medium for the data to be analysed. I'm using the test ...
1
vote
1answer
28 views

ST_Contains. Check for true/false in Python cursor

I would like to create a list of toponyms, which are within some distance from a point. I have calculated a buffer (dbrows_transf_back) and now I am checking if toponyms from a gazetteer (dbrows_os) ...
0
votes
2answers
104 views

Any high-level GIS library for python from the point of view of a data-scientist? [closed]

I am a data-scientist (an applied economist) and I have often to deal with data that includes spatial attributes. I am hence interested in using spatial data, rather than producing spatial attributes....
3
votes
0answers
33 views

How to access qgis module from my virtualenv

I am running an Ubuntu 14.4 and I have installed a python virtual environment. Then I pip installed several python libraries (gdal, lxml, psycopg2 etc.) Also in my system I have the module for qgis. ...
0
votes
1answer
41 views

Load a specific spatial data from a postGIS table

A single postGIS table contains multiple type of spatial data(example: Linestring,Polygon,etc.,). How to load a specific spatial data from PostGIS table into QGIS by using pyqgis?
1
vote
1answer
40 views

Python GDAL API: .Transform(osr.CoordinateTransformation(…), …)

A have input .tif files and geojson with different EPGS. I'm trying to use osr.CoordinateTransformation(source, target) method which takes 2 arguments of EPGS like on this cookbook. So how can I get ...
1
vote
0answers
35 views

Is there a faster process to update one column for all features?

I have written a python script in QGIS which estimates the amount of residents for each building polygon by using census block data and building polygons (about 500 000 buildings in an area of about ...
1
vote
2answers
71 views

Angle at intersection point from two Lines

I would like to find the angle of two lines at their intersection point. In my opinion it is the azimuth I'm looking for, right? So I'm using Python with shapely for finding the intersection and ...
0
votes
0answers
28 views

Enable LSCV kernel density estimation for Animove in QGIS?

I am currently studying primate home range behaviour and I want to create a kernel density utilization distribution based on the least-squares cross validation bandwidth parameter (LSCV), as some GPS-...
0
votes
1answer
59 views

Calculate centroid of a point cluster

Having this function that inserts locations in a database: def insertLocation(cur, label, point): print label cur.execute(""" SELECT label, centroid, point_cluster ...
0
votes
0answers
46 views

Read a vector layer from a Postgres/PostGIS database via a SQL query with QGIS and ogr in a python script

I have a treatment table for different aggregation stategies on a geospatial table in a PostgresSQL/PostGIS database. The aggregation strategies addressing temporal and species specific pre-selections ...
2
votes
1answer
57 views

Can the JSON output for an ArcGIS Rest Server be opened in a similar way to a WFSServer?

I would like to construct a python script to obtain JSON vector data from the following ArcGIS Rest Server: http://maps.six.nsw.gov.au/arcgis/rest/services/sixmaps/LPIMap/MapServer/69 For a ...
2
votes
0answers
41 views

How to interpolate raster data using computer vision (OpenCV)?

Background A raster file collected via LIDAR records the topography of a watershed. To properly model the watershed, the river must appear continuous without any breaks or interruptions. The roads in ...
3
votes
0answers
45 views

Python QGIS crashes within categorized renderer setup

I'm hassling around with QGIS renderer definitions in python with QGIS 2.8 at debian wheezy. At least I want simply build step by step a categorized renderer to fill a polygon. The script crashes, ...
1
vote
2answers
39 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
24 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 ...
2
votes
1answer
58 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
0answers
14 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 ...
1
vote
0answers
27 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
1answer
64 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 ...
1
vote
2answers
105 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 ...
1
vote
1answer
40 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 ...
0
votes
1answer
49 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 ...
2
votes
1answer
18 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) ...
1
vote
0answers
31 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 ...
3
votes
0answers
53 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 ...
1
vote
1answer
42 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 ...
2
votes
1answer
41 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 ...
0
votes
1answer
18 views

Parsing error with field calculator [closed]

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 ...
5
votes
1answer
111 views

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() ...
1
vote
0answers
25 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
24 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
1answer
40 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
2answers
47 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 ...
0
votes
0answers
63 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 ...
0
votes
1answer
84 views

Clipping GeoTIFF file by GeoJSON?

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