Questions tagged [python]

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

2,179 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
9
votes
0answers
429 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 ...
8
votes
0answers
1k views

Georeference an unreferenced image using rasterio in Python

I have unregistered/unreferenced 6 band TIFF images that I have been trying to export as georeferenced GeoTIFFs. The GPS coordinates of the corners of each image is known and each image is 1024 height ...
8
votes
0answers
291 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 ...
8
votes
0answers
2k 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 ...
7
votes
0answers
445 views

Labelling 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....
6
votes
1answer
140 views

QGIS 3.6 and QGIS 3.10 report different geometry types for the same shapefile

I used QGIS 3.6.3 to create a polyline shapefile, and the program reported the polyline as LineStringZM. When I opened the same shape file in QGIS 3.10.3-2, the polyline was reported as ...
6
votes
0answers
138 views

OGR failing to unpack polygons and respective holes from shapefile

I'm trying to unpack shapefiles in Python (v3.7.4) using the GDAL-OGR library (v2.3.3). Each shapefile has only one feature containing multiple polygons with holes. They cannot be produced differently....
6
votes
1answer
712 views

Deleting vector layer from Geopackage using PyQGIS

Programmatically I have added the vector layers to an existing GeoPackage in QGIS 3.2 using Python. Similarly, I would like to delete a layer from the existing GeoPackage using Python code. But there ...
6
votes
0answers
308 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 ...
6
votes
0answers
3k views

Get rid of jumping GPS data with pykalman

I have gps data that I get from a smartphone application. Whenever the smartphone is stationary, the gps points are jumping. I understand that the signal is inaccurate due to the reception in a city ...
6
votes
0answers
249 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/...
6
votes
0answers
112 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 ...
6
votes
0answers
584 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 ...
5
votes
0answers
64 views

QGIS contextual menu overriding

I would like to override the default contextual menu in QGIS 3 in the ToC. I've created a class that inherit from QgsLayerTreeViewMenuProvider. from qgis.gui import QgsLayerTreeViewMenuProvider from ...
5
votes
0answers
97 views

Georeference and warp a drone image based on sensor orientation and location

I have been flying some drone surveys over the ocean and need to properly project and georeference my images. I have all the information I think I need: lat, lon, altitude, yaw, pitch, and roll along ...
5
votes
0answers
288 views

QGIS 3: Set custom project variables with input dialog

I am using QGIS 3.10.0 and Windows 10. I have a project where I want the user to define custom project variables. I want to make this user friendly, I don't want the user to need to open the project ...
5
votes
0answers
446 views

Making polygon for every point in set using voronois?

I'm trying to make polygons from points, were each point will be represented by one polygon. I tried using voronois, but the results are incomplete. While I more or less understand where this ...
5
votes
0answers
352 views

Nearest neighbour joins for two geodataframes using KDtree from scipy/sklearn

I have a number of large geodataframes and want to automate the implementation of a Nearest Neighbour function using a KDtree for more efficient processing. The process I want to achieve here is to ...
5
votes
0answers
54 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 ...
5
votes
0answers
2k views

Overlay Union Geopandas improve performance

How to speed up the "union" of two shapefiles using geopandas? I have two large shapefiles: geodataframe_left.shape = (3610, 12) (500 MB) (link) geodataframe_right.shape = (16396, 3) (200 MB) (link)...
5
votes
0answers
152 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 ...
5
votes
1answer
615 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
1answer
324 views

Geocoding address involving non-ASCII characters in PyQGIS

I have installed the "GeoCoding" Plugin in QGIS and it worked well even though I have used non-ASCII characters to geocode (i.e. Hacettepe Üniversitesi). However, when I tried to do the same ...
5
votes
1answer
670 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
737 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 ...
5
votes
0answers
825 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 ...
5
votes
2answers
9k 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
1k 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 ...
5
votes
0answers
905 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
27 views

Identify U curves in route

I'm trying to identify the mountain roads in a route, and I've thought that a good approach could be get the paths with a very closed curve (like a U turn), but now I can not find any documentation ...
4
votes
1answer
52 views

QGIS Processing algorithm output

I am developing a plugin in QGIS using Python language. This plugin uses algorithms from Processing Toolbox and I save some results in the temporary folder assigning QgsProcessing.TEMPORARY_OUTPUT in ...
4
votes
0answers
63 views

Convert the geometry column of a GeoDataFrame with mixed geometry types to a unique multi-type

I have a GeoDataFrame where I have a mix of geometry types in its geometry column, some are multi-geometry types, some are single geometry types, some are empty geometry types, and others are None (...
4
votes
1answer
67 views

Obtaining a transform for Affine transformation (Cartesian to geodetic coordinate system)

I have a Line, defined as 2 points in a Cartesian coordinate system. Shapely allows projecting this line with an affine transformation if a transform is specified. from shapely.geometry import ...
4
votes
1answer
45 views

Make QGIS use a conda virtual environment for python libraries

I wanted to install a plugin, but it requires scipy. Thus I realized that QGIS use the default python3 installation. I tried to launch it from a conda virtual environment, as advised in this related ...
4
votes
1answer
82 views

How to choose limited number of points to represent a point grid

I need to choose a few points to represent the grid below, e.g: 8 points in the grid below. This point need to be geographic distributed This points needs to be geographic distributed. Lets see a bad ...
4
votes
0answers
50 views

Subclassing QgsMapToolDigitizeFeature

How does one subclass QgsMapToolDigitizeFeature? I'm trying to create a map tool in QGIS using Python. The tool will need to draw a polygon (and points and lines) in the same manner that QGIS does ...
4
votes
0answers
2k views

Max retries exceeded with URL in Nominatim with GeoPy

I'm trying to get a country name by lat lon (reverse encoding) using Python. I got to Nominatim with GeoPy which worked great two times but now I keep getting Max retries exceeded error. My code: from ...
4
votes
1answer
106 views

Optimizing pixel extraction from GeoTiff using Python

I am creating IDF Curves for work using python and 30-minute rainfall rate rasters. There are 24 rasters per day and about two decades worth of data. I basically input lat/lon coordinates and my ...
4
votes
0answers
52 views

QGIS processing tools - saving/exporting graph

I just tried QGIS processing tools for the first time. When using shortest path search for the first time, the algorithm is building a path graph (of course). However, the graph is never re-used. ...
4
votes
0answers
118 views

Open multiple QGIS projects via PyQGIS simultaneously in different threads

I'm writing a standalone PyQGIS application. When the method qgis() is called in a new thread, it's supposed to open a QGIS project (with one layer in it) and close it again: from concurrent.futures....
4
votes
0answers
45 views

Python osgeo/OGR not returning all features in PBF

I have a PBF file that is a limited export of the Nepal area. I'm trying to pull out all the adminstrative boundaries. If I use osmconvert to turn my PBF file into a OSM file, sure enough I see the ...
4
votes
1answer
376 views

Using rasterio to show RGB image with nodata

This question is same as https://stackoverflow.com/questions/59132459/use-rasterio-show-rgb-image-with-nodata I have a multiband image with nodata value (which is Landsat and been set nodata to 0). ...
4
votes
0answers
1k views

Export: Error: Internal error. from Google Earth Engine

I'm attempting to export an image by a time block for a particular census KML using the method below. Earth Engine is kicking back "internal error". As the error is not very helpful, I am having a ...
4
votes
1answer
90 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
2answers
288 views

Writing Non Spatial Table into Geopackage - Python

Just wondering how to write a non spatial (aspatial) table to geopackage using python. I have attempted using Fiona, geopackage = 'some_geo.gpkg' layer = 'test_layer' schema = {'geometry': {'type'...
4
votes
0answers
360 views

How to create LineString geometry in QGIS3?

The default geometry type for a newly created line seems to be MultiLineString. It can be changed to LineString using the Multi to Single tool while saving in memory. However, once it is exported it ...
4
votes
0answers
1k 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 ...
4
votes
2answers
314 views

QGIS plugin development environment variables?

I want to develop a plugin gor QGIS3. I downloaded Osgeo4w network installer 64Bit. I created a bat file as following for set my environment variables; @echo off call "%~dp0\o4w_env.bat" call ...
4
votes
0answers
318 views

Memory errors when doing Zonal Statistics on a multi polygon shapefile in Python

I want to calculate the mean NDVI with the EthNdvi.tif file for each zone (there are around 650 admin zones) in the the woreda shapefile. I'm having some issues with running the following lines of ...
4
votes
0answers
225 views

QGIS plugin external libraries in plugin’s directory

I’m developing my first QGIS plugin and I have to use two external libraries not included in the default OSGeoW64 installation: Couchdb and Pandas. I would like to include those libraries in my ...

1
2 3 4 5
44