Questions tagged [python]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
29 views

Check if function-argument is valid vector-geometry in Python GeoPandas

I wanto to build a function (let's call it clip) that accepts a vector-file (can be a shapefile, a geopackage....) and a raster. How can I make sure the argument that the users gives to the function ...
1
vote
0answers
41 views

Random forest classification starting from a JSON file

I have a lot of images of Earth and I need to find the section of the image where there is water using random forest. I also have one JSON file (not GeoJSON) that have all the image's information. ...
2
votes
1answer
161 views

Open QGIS prococessing algorithm dialog with Python

I would like to programmatically show a processing algorithm dialog from Python. I gived a look to processing toolbox and I found that this is possible importing and instantiating the class ...
1
vote
1answer
46 views

Generate an empty large raster using GDAL?

Using GDAL, how can I simply create an empty single band raster? I can't seem to find out how. I know in PostGIS you can create a new table with a 'raster' column type, then insert a band into it. ...
0
votes
0answers
16 views

How can I mosaic list of osgeo.gdal.Datasets and add overlapping grid cells?

I have a list of osgeo.gdal.Datasets that I created from a list of numpy arrays containing geo-referenced ice velocity values for a glacier. I would like to merge these all into a single mosaic and ...
6
votes
0answers
41 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....
1
vote
1answer
26 views

Apply transparency to a raster layer by using actions

i have a specific action to load an raster layer by clicking on it, however i need to know if is possible to open that specific file and automatically apply a style. My idea is when someone click and ...
2
votes
1answer
43 views

Build Mosaic using gdal based on Modal value

I have an immense (~50,000) set of tiles that I want to mosaic using the mode for every pixel. The tiles have a size of 299x299 and are overlapping each other by 2/3 respectively. For the sake of ...
0
votes
0answers
35 views

Python Displaying a 3D MNT or slope map

I'm working on a scientific programming project and so it's about calculating a slope map, aspect map and a risk map and of course displaying graphical results. I've already done the essential (...
1
vote
1answer
37 views

Exporting Error 'Pattern 'VH' did not match any bands'?

I am trying to process a Sentinel 1 image to add layover and shadow masking. However when I do that and try and export the image to google drive I get an error: Error: Image.select: Pattern 'VH' did ...
0
votes
1answer
51 views

Change in altitude value after resizing .tif file

I have a TIFF file of 7378x6923 (widthXheight) resolution. I resized it to 1200x1200 pixels using Image module in Python. img = Image.open('path to tif file') img = img.resize((1200,1200)) But after ...
2
votes
1answer
62 views

Rasterising multiple shapefiles into a single raster

I'm not even sure you can do this, but I want to convert multiple shapefiles into a single single-band raster. I'm pretty sure its going to be easier to first create a multi-band raster and then use ...
1
vote
0answers
34 views

Using Carto's “Static Maps” API from Python

I want to download a static image of a map to my local PC via a Python script. I'm using carto-print: carto-print I have tried this method: from xlwings import Book, Range from carto.auth import ...
1
vote
0answers
39 views

Getting pixel size without opening raster using Python [closed]

I want to get the pixel size (resolution) of a raster without opening up the raster in gdal. I currently have my script opening the raster in GDAL using gdal.Open() and getting the resolution that way....
0
votes
0answers
28 views

Issue exporting GeoPandas dataframe

I am trying to export a GeoPandas Dataframe looking like this to an external file: id geometry 0 POLYGON ((39.92713 1.41394, 39.92703 1.41394, ... 1 POLYGON ((39.95126 1.41866, 39.95116 1....
1
vote
0answers
26 views

v.overlay with empty layer [closed]

I'm writing a Grass Python Script (using GRASS GIS 7.6.1) for a project for university. Sadly, I never learned Python, so it's a bit tricky but so far I got everything done I wanted to. The Script ...
0
votes
0answers
39 views

Enable Python extension for GeoServer 2.16.x

I am using Windows 10 (64 bit) & QGIS 3.4 along with GeoServer 2.16.x in my machine I am trying to enable 'scripting' in GeoServer (so that will develop Python scripts) but it gives me error (my ...
4
votes
1answer
85 views

Assigning new values to polygon based on overlapping area with other polygons

I have two square polygons df1 and df2. Both polygons are assigned a value of 10 (df1) and 20 (df2) in the "content" column. Let's assume, I have a circle with the midpoint 1.5,1.5 and a radius of 1. ...
0
votes
1answer
45 views

Create VRT from multiple hdf files with Rasterio/GDAL

I have several Landsat 8 Scenes, each consisting of 11 bands. I want to mosaic them by creating a VRT and afterwards exporting the mosaic as TIFF again. I tried using GDAL via Python. But maybe it ...
1
vote
1answer
45 views

Creating a raster based on values of other rasters

I have three single band rasters, raster_a, raster_b and raster_c with pixel values 1 and 0. I am trying to burn the values of raster_a to raster_b and create a "new_raster_b" where if: raster_a == ...
4
votes
1answer
99 views

Setting CRS to ESRI:102001 using GeoPandas

I've been passed some GeoJSON shape data that I've been told is in the CRS ESRI:102001, although that property has not been written into the GeoJSON file. I've been able to confirm that is the correct ...
0
votes
0answers
15 views

Convert list of .hdf-files to .vrt in python with Gdal

I'm a little lost. I have a directory with some Landsat-8-scenes. There are files that end on .hdf and they are always accompanied by a .hdr file. What I wanted to do is to convert these scenes to a ...
2
votes
1answer
55 views

Creating new shapefile using pyshp

I am trying to strip data out of an existing shapefile to create new shapefiles. I have made the loop work, and made the new file, but I cannot work out why I cannot add records to the new file I am ...
1
vote
1answer
57 views

Using PyQt5 Objects inside QTabWidget and QScrollArea - QGIS Plugin [closed]

I'm using PyQt5 and QT Designer to create the user interface for my QGIS plugin. Now I'm learning to use QTabWidget and QScrollArea. What I don't understand is how to use the objects inside tabs or ...
1
vote
1answer
50 views

Received corrupt data from Overpass (incomplete polygon) with Overpass API Python wrapper

I'd like to collect forest data on overpass turbo. But my code isn't working properly. Here is the first version: import overpass api = overpass.API() res = api.get(""" area[name="Charente-...
0
votes
0answers
43 views

How to find the points of hausdorff_distance()?

The Shapely hausdorff_distance() function returns a single (scalar) value. Is there a way to get the/a pair of points on both geometries that fit this distance? Similar to how we have ...
1
vote
1answer
44 views

How to write BIGTIFF raster files with rasterio

A few months ago I had a hard time in finding a way to read BIGTIFF files. In the end I only managed to do so by creating a new conda environment with the following options: conda create -n env_name ...
1
vote
1answer
46 views

Finding distance of consecutive points in a GeoPandas data frame

I am trying to find the distance between every consecutive points in a GeoPandas dataframe. Let's say we have the following data frame: import pandas as pd import geopandas data=pd.DataFrame() data['...
2
votes
1answer
50 views

Calculate distance from a point to a MultiLineString geometry - PYQGIS

I'm trying to calculate the distance from a point to the closest river in my QGIS plugin. But I receive this message: MultiLineString geometry cannot be converted to a point. Only Point types are ...
1
vote
2answers
66 views

Read ASCII Grid file cell value for given long/lat coordinates

I am trying to write a Python script which takes a set of long/lat coordinates as input and returns the cell value corresponding to these coordinates The ASCII Grid file is from PVGIS and contains ...
1
vote
1answer
38 views

GDAL in docker using pipelines in gitlab

I want use gitlab to test python with GDAL library pip install gdal is not working I use gitlab to CI/CD Source code of project: https://github.com/lazyspot/georeference-image-library It is ...
0
votes
0answers
37 views

Spatiotemporal analysis with polygons and points

In QGIS, I have a dataset of burned areas (polygons) and lightning strikes (points). In both datasets, I have the date of the fires, date of the lightning strikes, latitudes, and longitudes. However, ...
1
vote
1answer
35 views

gsconfig add WFS with shapefile via Python

I am generating a shapefile with a Python script and I want to publish it via GeoServer. The GeoServer is running on localhost 8080. I learned from this website that the workflow would be: Add a ...
1
vote
1answer
37 views

Updating Pyproj syntax results in other values

I want to know the length in meters of a LineString with coordinates in EPSG4326. Based on this post, this is code that works for me: from shapely.geometry import LineString from shapely.ops import ...
1
vote
0answers
34 views

Folium choropleth plots markers [closed]

I have this code to plot a choropleth from a GeoPandas DataFrame. def create_gpd_dataframe(self d = {'Angle of point': yard_list, 'Latitude': yard_lat_list, 'Longitude': yard_lon_list} ...
1
vote
0answers
36 views

Convert GeoTIFF to KMZ

I am trying to convert a GeoTIFF to a KMZ. Here's my code: from osgeo import gdal import zipfile srcf = r"C:\raster_to_kml\OrthoImage.tif" vfn = "/vsimem/OrthoImage.jpg" drv = gdal.GetDriverByName('...
0
votes
1answer
47 views

Deleting features with Null value in attribute field

I have polygonized a single band raster and created an area field. I want to keep the 10 largest polygons by area and delete the rest. The following script computes the area for all polygons and sorts ...
2
votes
1answer
32 views

Set image SRC using GDAL [closed]

I have a TIFF image with no coordinate reference system and I need that image to be in EPSG 32631. Is there a way to do this using GDAL? Note: I am very new to Python
1
vote
0answers
43 views

Python Classification of multiple NDVI images for difference

I have several months worth of NDVI images for an area. When I check the values, there seems to be some deviation. I am using python GDAL to attempt to calculate possible areas of concern for ...
0
votes
1answer
46 views

How to visualize large .tif file which is a multispectral image

This image is supposedly a 5m multispectral multi-temporal (LISS IV) data of a place in India called Satna. It is a .tif format file of size around 32 MB. Image should typically have greenery(...
1
vote
0answers
23 views

Problem with Python plugin [duplicate]

I developed a Python plugin to import a PostgreSQL project organized in QGIS with one click. The problem is that I don't put the layers it in the correct "tree scheme" in the layer panel. I enclose a ...
1
vote
1answer
40 views

Sort and create attribute field to the shapefile

I am creating a shapefile layer and adding an 'Area' attribute field using the following script: # Create shapefile layer drv = ogr.GetDriverByName("ESRI Shapefile") dst_ds = drv.CreateDataSource(...
0
votes
0answers
37 views

earthpy.spatial stack() -function and data type

I have Landsat-8 OLI images in directories named after image WRS-2 scenes. I tried to compose script that would iterate these directories and stack rasters within each directory - using earthpy python ...
0
votes
0answers
30 views

Convert heights from DHDN Gauß Krüger Zone 4 to UTM 32 ETRS 89 in pyproj

I am using pyproj. X/Y conversion is pretty straightforward through transformer = Transformer.from_crs(31468, 25832,always_xy=True) However, this does not transform the heights. From Vertical ...
0
votes
1answer
51 views

Extract/export Attribute Table of pixel information from Classified Raster in Python?

I am at beginner level in image processing with python. I have classified satellite image with python in 10 classes. I am able to write the image in geotiff format. However, I do not know how extract ...
0
votes
0answers
57 views

Mask Sentinel 1 images for radar shadow in Colab?

I am trying to export Sentinel 1 images from Colab to Google Drive, but before I want to mask out areas of radar shadow and layover. Is there code or a function for masking out radar shadow in the ...
2
votes
1answer
100 views

Error name '__file__' is not defined

I have a complement (image_1) that works perfect. But I get an error by wanting to make a change. I add the code of my two .py files. I want to change this address: "C:/Users/SENARA/AppData/Roaming/...
1
vote
0answers
35 views

OSMIUM deleted column conflict with OSM

The following code used to extract the data from a history file. import osmium class CounterHandler(osmium.SimpleHandler): def __init__(self): osmium.SimpleHandler.__init__(self) ...
0
votes
0answers
28 views

Where can I find the source code of shapely.geometry.multilinestring.interpolate() function?

When I use shapely.geometry.multilinestring.interpolate() function, it creates points at every 50 m along the multiline. I try to create a points at a given interval (lets say the distance between ...
2
votes
0answers
29 views

Combining graphic modeller Python output with another Python Script

I created a model that takes my point shapelayer, creates polygons from these points using minimum bounding geometry then adds a field named 'Zonekey' to attribute table; from qgis.core import ...