Questions tagged [python]

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

1,489 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
0answers
422 views

Accessing existing instance of QGIS from stand-alone python script

For my own data analysis pipeline, I am running a split screen setup with iPython notebooks on one side, generating variables from source data, pushing them to a CSV file which QGIS then reads/joins ...
8
votes
1answer
117 views

Coarse Woody Debris extraction

I created very high dense point cloud of some forest plots using terrestrial laser scanner. Then removed points above 1.3 meter to see the coarse woody debris (Fallen dead trees). Attached is the ...
8
votes
0answers
332 views

Executing bidirectional dijkstra on TIFF image?

Can anyone indicate an example of how to do this? Link, tutorial etc... I started a discussion here about how to load a TIFF image like a graph nicely answered by @sehe. But, in this post the image is ...
8
votes
3answers
4k 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 (...
7
votes
0answers
225 views

Multithreaded DB connection for QGIS plugin

I am using QGIS 2.18.21 and PostgreSQL 9.6. on a Windows 8 machine. I am trying to do processing of a certain database task in the background, and I want the user to be able to continue to work in ...
7
votes
0answers
204 views

Computing the horizon profile given a DEM in python

Can anybody orient me towards an open source python script that computes the 360° horizon profile (azi + elevation of highest topography in eye sight) from a single point (x,y,z) on Earth (account for ...
6
votes
0answers
284 views

MapScript with Python 3

I am trying to build raster summarizing features into a GeoDjango webmap, and would like to use the django-raster and django-wms packages to do so. I believe that I have them set up correctly, but am ...
6
votes
0answers
715 views

Setting band names when writing multiple layer rasters using GDAL with Python?

I want to write a raster file (using GDAL+Python) with multiply bands. However, I do not know how to named bands. Their names are always "Band 1", "Band 2", etc. I search and found a function that ...
6
votes
0answers
235 views

Different results from GDAL raster attribute table command on mac and windows

I am trying to get the raster attribute table of the following file: Shift_cult_past_current_prediction_20160107_gr1DD.tif available here: https://www.dropbox.com/s/fmomfpro3j6dmz8/...
5
votes
1answer
386 views

Geoalchemy: insert 3D elements in PostGIS database

I have shp files that I would like to insert into a PostGIS database. I'm planning to use Geoalchemy2 and geopandas to do so. However, my data have the geometry types LINESTRING Z and POINT Z. As I ...
5
votes
2answers
159 views

Automatically moving along columns within a layer as moved to the next item in a QGIS Atlas?

My problem is quite hard to explain, I have attached some images to help illustrate my issue. I want to produce a large number of maps which overlap in geographic area. Currently my data is arranged ...
5
votes
0answers
165 views

Determining Bounding Points of UAV Images

I know the EXIF data from drones contains the GPS point central to the photo to provide photo location. What I'd like is to determine the lat/lon of the four corners of the image. I've done a pretty ...
5
votes
1answer
418 views

Competing versions of GDAL

This is confusing, and a question I've harvested from a duplicate, so let me start with my setup. OS: Windows 7 x64 GIS Client 1: ArcGIS Desktop 10.5 GIS Client 2: ArcGIS Pro 1.4 GIS Client 3: ...
5
votes
0answers
190 views

PyQGIS composed Atlas generation

I have some layers : layer 1 layer 2 layer 3 and I have create styles for any labels layer using base rule styles and labels and I have create a template .qpt and I use atlas correct. In my ...
5
votes
0answers
2k views

gdal/python: tif not recognised a supported file format

I'm trying to open a tif using gdal, read it as a array, do some math, and write it back as a tif. However, when I try to gdal.Open(tif) in python, I get the error: RuntimeError: /att/gpfsfs/...
5
votes
0answers
76 views

“Merging” 2 layers of LineString with splits at intersections

I would like to "merge" 2 networks of lines and these lines need to be split when they intersect. With pictures it should be clearer : What to do: if a black line intersects a red line, they should ...
5
votes
2answers
4k views

WindowsError: [Error 32] The process cannot access the file because it is being used by another process

I am reading images (through Python) and do something. These images are placed in a temporary file, through: tf = tempfile.mkdtemp(filename) I use gdal to read the images (short part of code): ... ...
5
votes
0answers
895 views

library for minimum bounding box “by width” in javascript or python

I'm looking for a library (or at least a code snippet) to calculate the minimum bounding box "by width" in javascript or python. Below is an illustration from the ArcGIS documentation of that ...
5
votes
0answers
879 views

Print Composer Template produces empty map?

I have a print composer template which I'm trying to populate with different subset queries from a CSV-derived vector layer using the Python API. However, all the output PDFs contain everything except ...
5
votes
1answer
339 views

Displacement when clip raster by shapefile

I run a script to clip raster by shapefile. Even with layers own the same crs (epsg: 4674) the output raster be displaced. I didn't find out in my script what is caused the error. Here is my code: ""...
4
votes
0answers
47 views

Running and scheduling processing jobs in QGIS 3?

Basically I want to write a script that would run on a daily basis on QGIS 3. This tutorial seems to have exactly what I want but the tutorial only works for QGIS 2. QGIS Tutorials and Tips | ...
4
votes
1answer
61 views

Adding up several rasters to show the change

I want to add several images such that their change is shown in different colors. Such as the following in which I simply added two images in their grayscale. But I would like to have a colored ...
4
votes
0answers
39 views

Randomized organic warp of adjacent polygons that preserves topology and fixed nodes

I'm looking for algoritms to modify a set of polygons to make them appear more organic. They still need to maintain their topology and furthermore some of the nodes might be fixed. Please see the ...
4
votes
0answers
265 views

QGIS 3 Python plugin psycopg2 Postgres Notify/Listen Live Connection

I'm developing a plugin for QGIS3 for my company, where my managers can allocate tasks to other users. I have programmed two tables within the python script, witch will be only visible according to ...
4
votes
0answers
108 views

Speed execution of PyQGIS algorithms

I don't understand why if I do "manually" some algorithms I get results much faster than when I insert the same in a pyqgis code (with the same input). This happens, for example, with the extract ...
4
votes
0answers
107 views

Performance improvement methods in a shapely environment

I am trying to use the Shapely and Fiona libraries to eliminate polygons from one layer (some triangles) from another layer (which represents the world's oceans). I am looking for suggestions to ...
4
votes
0answers
234 views

Installing third party python library in QGIS 2.18.x Windows

We are running into a strange behaviour while trying to use pyoidc with QGIS 2.18.x windows standalone version. Due to pip/pipy no longer working with QGIS 2.18 (see this post), we installed the ...
4
votes
0answers
2k views

Using polygons to create mask on 2d grid with Python?

I have some polygons (Canadian provinces), read in with GeoPandas, and want to use these to create a mask to apply to gridded data on a 2-d latitude-longitude grid (read from a netcdf file using iris)....
4
votes
0answers
762 views

How to perform spatial join and obtain attribute in python/GDAL?

I am working on a script that will take an unprojected raster, and using a UTM grid (shapefile), will obtain the correct SRS (I have a shapefile where each zone is attributed with its numerical SRS) ...
4
votes
0answers
711 views

Install OSGeo module in virtualenv

How can you install the osgeo module in a virtualenv? I downloaded QGIS using KyngChaos (www.kyngchaos.com/software/qgis) following https://arset.gsfc.nasa.gov/sites/default/files/land/webinars/...
4
votes
1answer
199 views

QField — using Python init functions

We are using the field mapping application QField with QGIS 2.18 for on-site data collection. I've looked through the documentation and am still unsure, so am bring this question here: Is it possible ...
4
votes
0answers
541 views

Import Pandas or any Python module into QGIS internal Python

(Also asked in stack overflow - https://stackoverflow.com/questions/43244062/import-pandas-or-any-python-module-into-qgis-internal-python ) I am developing a plugin for the current LTR version of ...
4
votes
0answers
582 views

Right-hand-rule in QGIS

It seems that there isn't a plugin to perform the right-hand-rule on a layer or selected features. Can this be done by using some Python code? Is there a function that works in the same way as ...
4
votes
0answers
837 views

Shapely polygons crossing the antimeridian

Sample data Consider the following WKT Polygon, crossing the international dateline (antimeridian): POLYGON((176 49,-65 49,-65 11,176 11,176 49)) And the following points: POINT(-140 32) # ...
4
votes
0answers
2k views

What is the fastest version of gdal2tiles?

I have multi-CPU linux server, so I wonder what is the fastest parallel version of gdal2tiles.py ? My Ubuntu version: lsb_release -a Description: Ubuntu 12.04.5 LTS How I install the package: ...
4
votes
0answers
211 views

How to add a Google map layer in a pyqgis script

I'm creating a python plugin for different users that has the layers that each person need to use and work with in QGIS. I have no trouble adding rasters from Geoserver using the following code: ...
4
votes
0answers
308 views

netCDF has wrong spatial extent in metadata

I have a netCDF file with spatial data ranging from x:528500 573500 y:350500 399500 on EPSG: 31287. If I open and explore the file with Panoply and show the data on a map all works like it should. ...
4
votes
0answers
166 views

Gdal Python problem: black strips in image translation

I have a 500 x 500 m resolution world map of clumping index data (He et al., 2012) and I am trying to do two things at the same time: 1) to isolate the variables per plant functional type following ...
4
votes
1answer
1k views

Unable to install Python 3.4 gdal bindings on CentOS

I can easily install GDAL and Python bindings on a Windows machine, but I can not reproduce the same thing on a CentOS machine. The problem is I want to use Python 3.4 (Python 2.7 is too old and ...
4
votes
0answers
520 views

ATDI free map read with software

I am interested in working with the freely available ATDI MAPS. The maps are provided for their proprietary software ICS manager or ICS telecom. I am involved in a project to develop a software in c++ ...
4
votes
0answers
231 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 ...
4
votes
0answers
1k views

GDAL RasterIO performance in C++ vs ReadAsArray in python/numpy

I'm currently writing optimisations for a raster viewer program which uses gdal as it's base. It's currently written purely in python, and has some major speed issues which cause problems when we are ...
4
votes
0answers
92 views

Issues updating field values programmatically for particular field data type on 64bit Windows computer using QGIS 2.8.7

I have an issue with a plugin for QGIS 2.8 I'm developing when using it on a Windows 64bit machine (as opposed to 32bit). I am trying to update values in a particular field in my plugin, and the ...
4
votes
0answers
105 views

Open QGIS project files in exclusive mode / alert if project file already in use

I have QGIS-Project-Files saved to a network drive and was wondering if it is possible to warn users that a project file is already opened by an other user to prevent concurrent editing of the same ...
4
votes
0answers
356 views

PyQGIS: vector layer does not get displayed after rendering

My project goal is to write a standalone app for Unbuntu and QGIS 2.14. It should get a layer of simple points and their name from a Postgres database and show them in a layer. In addition there ...
4
votes
1answer
275 views

Showing only selected features from a a layer in the QgsComposerLegend?

I have developed a custom qgis plugin. I have a button to export the map canvas in the form of image along with the legend. I came up with the following code for the legend: legend = ...
4
votes
0answers
72 views

QGIS plugin window qt creator formatting is ineffective

I am developing a QGIS plugin. I have assigned the QGIS main window as the parent window of custom plugin using: QtGui.QDialog.__init__(self, iface.mainWindow()) But after doing so the problem is ...
4
votes
0answers
544 views

Setting up PyCharm CE 4 to work with PyQGIS library in Mac OS

I am trying to set up pycharm to work with pyQgis library but with not success till now. I am using PyCharm CE v4 and QGIS version 2.8 I have tried to implemnte the instructions of several posts like ...
4
votes
0answers
439 views

Using ST_AsText() without session object

I am storing gps locations as feature in a restfull api. The locations are linked by foreign key to "place" objects in a flask/sqlalchemy/geoalchemy framework. I would like to print a user readable ...
4
votes
0answers
931 views

Geoprocessing Service on ArcGIS Server to Export File

ArcGIS Server / Geoprocessing Question I have a geoprocessing service that will perform a selection on a layer based on a provided expression. I would like to output the result as a csv file (or ...