Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [python]

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

9
votes
0answers
305 views

Alter Minimum Bounding Box Algorithm

I'm trying to create an algorithm similar to minimum bounding box (though it may end up looking nothing like it). In this case the angle will be passed as a parameter and given the angle I need the ...
9
votes
0answers
266 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 ...
7
votes
0answers
176 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
522 views

Rasterio does not execute the rasterize function

Rasterio's features.rasterize() function is not working as expected. I have two files: OpenStreetMap shapefile with land usages Raster (.tif) with satellite imagery Goal: Create a raster file from ...
7
votes
0answers
359 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 ...
6
votes
0answers
50 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 ...
6
votes
0answers
220 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
0answers
155 views

GDAL grid Not recognizing csv as having geometry

NON-DUPLICATE EDIT: This question is not a duplicate because I have tried the solution presented as the answer to the "original" question and it did not work. See results below. I am attempting to ...
5
votes
0answers
123 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 ...
5
votes
0answers
232 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 ...
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
798 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
848 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 ...
4
votes
0answers
73 views

Variable width buffer based on axis directions in QGIS

I need to buffer a polygon with a different distance in the x and y directions. I should add that my polygon has the following properties: closed (obviously) simple (no edge crossing, no more ...
4
votes
0answers
83 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
89 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
188 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
41 views

How to get a layer object from a geometry

I have a polygon as a gdal geometry and I'd like to use it with gdal.RasterizeLayer(). As its name states, this method needs a layer object, not a geometry. So I need to convert/wrap my geometry into ...
4
votes
0answers
127 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 ...
4
votes
0answers
663 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
0answers
177 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 ...
4
votes
0answers
429 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
408 views

Math domain error in slippy tiles generator

I'm running Alexander Hajnal's Python module (http://alephnull.net/software/gis/tile_writer.shtml) in QGIS (2.14.3, Win10 64) and I'm using the EPSG:3857 as crs. I got this error: "Traceback (most ...
4
votes
0answers
466 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 ...
4
votes
0answers
557 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
256 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
141 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
0answers
474 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
152 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, ...
4
votes
0answers
912 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
90 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
91 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
328 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
0answers
130 views

TypeError: QgsEncodingFileDialog

I am using the latest version of QGIS (Lyon) on MAC and have set the default Python version 2.7. Moreover, I have installed all the required python modules and GDAL. It was working before, but now, ...
4
votes
0answers
66 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 ...
4
votes
0answers
534 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
370 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
1k views

Is there a way to execute FME transformers from a PythonCaller script in an FME workspace?

I have a very large and complex Python/arcpy script that does lots of custom calculations, and I am trying to port it to an FME environemnt. The script runs beautifully under ArcGIS. The problem in ...
4
votes
0answers
742 views

Extracting x,y,z values from a postgis linestring to python using ogr

I am trying to load a postgis linestring into python (using ST_DumpPoints) and extracting x,y,z coordinates, which is working but extremely slow..and if i mean slow, i really mean it (yes, it takes ...
4
votes
0answers
1k views

Add CAD Drawing Dataset into ArcMap using Python

I am trying to add an CAD Drawing Dataset into ArcMap using Python. Question is how to add a Auto-CAD .dwg file to ArcMap using Python Normally comes in as CAD file within a Group layer with: ...
3
votes
0answers
44 views

ArcPy Memory issue re-using dictionary?

Before I start I should mention that before this I have never worked in Python before. I am trying to process a large fc to fc update, 3 million plus rows with 70 columns. I tried using updatecursor ...
3
votes
0answers
98 views

QGisPlugin : Trigger closeEvent by clicking 'X' in QgsAttributeForm

This is the code: def formOpen(dialog, layer, feature): """Function called when a connec is identified in the map""" global feature_dialog # Create class to manage Feature Form interaction ...
3
votes
0answers
54 views

Multiprocessing with geopandas

I am learning how to implement the multiprocessing with spatial data using the module multiprocessing. I am trying to implement a spatial intersection between a polygon file and a grid file. I am ...
3
votes
0answers
58 views

Shapefile polygon operation efficiency

I would like to make a graph from a shapefile, where edges would express spatial relations between polygons according to DE-9IM For that, I use fiona + shapely My code is working but it is extremely ...
3
votes
0answers
131 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 ...
3
votes
0answers
106 views

Using Rasterio to work with two rasters of different extent and resolution?

I have two spatial rasters of different extent and different cell size and I want to do a conditional statement with them. I decided to use rasterio for that. I use this code: with rasterio.open('A....
3
votes
0answers
65 views

Why can't I transpose a raster across the pole with rasterio or gdal, and how could it be done?

I have a raster in e.g epsg:4326, it covers all world, from 180E to 180W, from 90S to 90N. I want to re-project a part of it to epsg:3031 and also change the grid size and resolution. Here is a ...
3
votes
0answers
37 views

QGIS Python: sort by attributes <= 0

In QGIS 2.18 I'm try to sort features by an integer attribute with a Python script. The problem is, that some of the values of the sorting attribue are <= 0 (for sure they have to be <=0) and ...
3
votes
0answers
175 views

How to label a rubber band (QgsRubberBand)

It is possible to label QgsRubberBand or QgsVertexMarker with a text annotation (QgsTextAnnotationItem). See this MWE: ... r_polyline = QgsRubberBand(iface.mapCanvas(), False) r_polyline....