Questions tagged [python]

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

2,567 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
12 votes
0 answers
504 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 ...
user avatar
  • 1,249
11 votes
0 answers
2k views

Making polygon for every point in set using Voronoi diagram

I'm trying to make polygons from points, where 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 ...
user avatar
  • 539
8 votes
0 answers
268 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....
user avatar
8 votes
1 answer
688 views

Finding the closest line to polygon using Python Rtree

I have a series of fields and roads. I am trying to find the nearest road to each field. I want to add field to each of my polygons with the index/name etc. of the closest road. Would this be the ...
user avatar
  • 321
8 votes
0 answers
922 views

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

I have a number of large geodataframes and I 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 ...
user avatar
  • 81
8 votes
0 answers
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 ...
user avatar
8 votes
0 answers
2k 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 ...
user avatar
  • 213
8 votes
0 answers
612 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. I am using PyCharm CE v4 and QGIS version 2.8 I have tried to implement the instructions of several posts like: http://osgeo-org.1560.x6....
user avatar
  • 221
7 votes
0 answers
211 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 ...
user avatar
  • 463
7 votes
0 answers
427 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 ...
user avatar
  • 379
7 votes
0 answers
344 views

Save GeoPandas spatial index to disk

I'd like to save the R-tree spatial index generated by GeoPandas to disk. GeoPandas automatically generates an index for each shape (points in this case) in the dataframe. I'm attempting to create a ...
user avatar
  • 399
7 votes
1 answer
219 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 ...
user avatar
  • 143
7 votes
0 answers
507 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 Multipart to Singleparts tool while saving in memory. However, once it is ...
user avatar
  • 181
7 votes
0 answers
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)...
user avatar
  • 2,965
7 votes
0 answers
266 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 ...
user avatar
7 votes
0 answers
334 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 ...
user avatar
  • 1,023
7 votes
0 answers
273 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/...
user avatar
6 votes
0 answers
118 views

Creating a seamless vector dataset from raster with gdal, R or Python

I'm trying to create a seamless vector dataset from an integer raster. "Seamless" as in: not gaps between features and no overlapping features. The tools gdal_polygonize, pkpolygonize, terra:...
user avatar
  • 833
6 votes
2 answers
353 views

Shortest path touching all points

I am looking for a solution to derive the shortest route that touches all the points using Python. Please note that This is not a Travelling salesman problem (TSP), in which the route should end ...
user avatar
  • 315
6 votes
1 answer
130 views

GIF freezes when QGIS plugin runs

I have a QGIS plugin and would like to put loading GIF (spinner) somewhere in the Dialog Window. The problem is when I run the spinner with the following code and call next function, the spinner ...
user avatar
6 votes
0 answers
155 views

How to transform ERA5 vertical datum to WGS84

I am trying to plot a netcdf file from ECMWF ERA5 in a folium map but I am having troubles with the projections in the file. ECMWF documentation states: ECMWF data is referenced in the horizontal with ...
user avatar
  • 199
6 votes
0 answers
936 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 (...
user avatar
  • 6,698
6 votes
0 answers
342 views

Unable to install QGIS Plugins on Windows

I've installed QGIS 3.16 Hannover on my laptop about three days ago (Windows 10 Home 1909) and am unable to install any plugins, nor get access to any of the core plugins save four. When going to ...
user avatar
6 votes
2 answers
820 views

Adding support to Esri's FileGDB driver when fiona/gdal/osgeo were installed through Anaconda

Is there a way to tweak the fiona/gdal/osgeo packages installed through Anaconda so that they can be used to read/write GDB files using the ESRI FileGDB driver? The main thing I'm actually trying to ...
user avatar
  • 1,737
6 votes
0 answers
290 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....
user avatar
  • 151
6 votes
0 answers
615 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 ...
user avatar
  • 123
6 votes
0 answers
64 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 ...
user avatar
6 votes
0 answers
2k 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 ...
user avatar
  • 533
6 votes
1 answer
747 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: ...
user avatar
  • 1,325
6 votes
0 answers
870 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 ...
user avatar
  • 681
6 votes
0 answers
4k 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: ...
user avatar
  • 591
6 votes
0 answers
731 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. ...
user avatar
  • 287
6 votes
0 answers
189 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 ...
user avatar
  • 61
6 votes
0 answers
292 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 ...
user avatar
  • 61
6 votes
2 answers
13k 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): ... ...
user avatar
6 votes
0 answers
918 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 ...
user avatar
6 votes
0 answers
2k views

Buffering a Raster with GDAL and Numpy

I am using GDAL to convert a raster dataset into a numpy.array and then using numpy to buffer the data in the raster. For example, I need to know all the regions within 100ft of a school point ...
user avatar
  • 4,109
5 votes
0 answers
107 views

TMS tilenames for Elliptical Mercator projection - EPSG:3395

My goal is to derive TMS tile names from given lat/lon and vice versa for Elliptical Mercator projection (EPSG:3395) using Python. OSM wiki explains the logic for Spherical Mercator (EPSG:3857), but ...
user avatar
  • 3,353
5 votes
0 answers
508 views

Controlling the visibility of a FeatureGroup in Folium with an HTML checkbox

I'm working on a project in Django where I want to show layers on a map by checking or unchecking boxes which I created using bootstrap. I am aware it is possible to use LayerControl to get these ...
user avatar
5 votes
0 answers
99 views

Where does QGIS download plugin .zip files prior to install?

I have a QGIS Python plugin we use internally. I've released a new version - edited the "metadata.txt" file, zipped it, replaced the .zip package on our web host, updated our plugins.xml ...
user avatar
5 votes
1 answer
390 views

Finding distance from points to the boundary of the nearest polygon in Python

I asked this question on stackoverflow.com but it seems that doing so here is a better option. Context: I want to compute the distance from points to the closest boundary of the closest polygon to ...
user avatar
  • 181
5 votes
0 answers
463 views

Using PyQGIS functions outside QGIS

I want to use PyQGIS function crs.isValid() in normal Python file outside of QGIS like this: wkt = 'GEOGCS["WGS84", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298....
user avatar
  • 1,385
5 votes
1 answer
105 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 ...
user avatar
5 votes
0 answers
201 views

Finding union of many geodataframes using GeoPandas

I have a series of many GeoPandas Polygon objects, each with an associated exposure time. My goal is to find the union of all the Polygons in order to create an exposure time map. For each Polygon in ...
user avatar
  • 51
5 votes
0 answers
218 views

Programmatically Enable/disable input parameters in a QGIS Processing plugin

Is there a way to enable/disable a parameter by a checkbox in the processing interface? In my screenshot below, I would like to disable the Output Wall Aspect Raster when the Calculate wall aspect ...
user avatar
  • 176
5 votes
1 answer
236 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 ...
user avatar
  • 448
5 votes
0 answers
107 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. ...
user avatar
5 votes
0 answers
96 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 ...
user avatar
5 votes
1 answer
898 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). ...
user avatar
  • 61
5 votes
0 answers
293 views

Is there a limit to the number of GCPs that can be used?

I am trying to georeference an image using many (>1,000,000) GCPs (derived by matching two images using triangulation). However, after many attempts doing this in different ways I think I found that ...
user avatar
  • 91

1
2 3 4 5
52