Questions tagged [python]

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

2,022 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
0answers
393 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 ...
7
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 ...
7
votes
0answers
280 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
1k 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
96 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
0answers
389 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
0answers
305 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
246 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
98 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
571 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
1answer
113 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 ...
5
votes
0answers
183 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
259 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
53 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
139 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
563 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
283 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
651 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
2answers
7k 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
898 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
47 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
83 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
33 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
0answers
313 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 ...
4
votes
1answer
81 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
1answer
156 views

How to track progress on a route?

I want to track and visualize the progress of a bus, as follows: I have the coordinates of each station as well as the coordinates of the bus, updated every 10 seconds The information is stored in ...
4
votes
2answers
220 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
1k 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)...
4
votes
0answers
218 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 ...
4
votes
0answers
209 views

Run GDAL on android and perform operations

Could one run gdal on android devices to perform some GIS operation, like viewshed, contours, etc?
4
votes
0answers
132 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
269 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
517 views

How to extract transformation coefficients calculated with GDAL based on GCPs?

I want to precompute the least squares fit polynomials from a provided set of GCPs, and store the coefficients for later transformation of points between pixel/line and georeferenced coordinates. Thus ...
4
votes
0answers
1k 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
737 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
704 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
757 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
1k 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
491 views

Spatial clustering with attribute

I need to do some sort of spatial clustering where each spatial coordinate has a value attribute. So, for example, each point has a salary attached to it. So each cluster would have a total salary if ...
4
votes
0answers
3k 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
275 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
453 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
173 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
649 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
1k views

Click to copy coordinates From QGIS

I have a created some point data using CRS ESPG:4326 and added Google base map from OpenLayers plugin. While adding the Google Maps imagery I have changed CRS to ESPG:3857 in project properties. ...
4
votes
0answers
251 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
101 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 ...

1
2 3 4 5
41