Questions tagged [python]
Python is an open source interpreted programming language used in many GIS programs.
12,250 questions
0
votes
0
answers
15
views
Unable to download MODIS emissivity through pystac
I'm using Planetary Computer STAC catalog to download MODIS emissivity data (modis-11A1-061 collection, although the same problem appears with the modis-11A2-061 and modis-21A2-061 collections).
It ...
0
votes
0
answers
26
views
Change ArcGIS Pro's proenv.bat behaviour (don't change working dir)
In ArcGIS Pro, to activate the default python conda environment in your terminal, you can run the proenv.bat script (copied below). I don't speak bat, so I don't know how it works. What I don't want ...
0
votes
0
answers
22
views
Error when converting feature collection to Pandas data frame
I'm trying to do zonal statistics in Python API when I encounter error message:
EEException: Computation timed out
while running this cell of code to convert feature collection into data frame:
...
1
vote
1
answer
55
views
Natural Breaks (Jenks) classification using Python
I am classifying a PlanetScope Imagery into 3 classes (water, non-water and mixed) using NDWI. Natural breaks (Jenks) worked the best for me when I tried different data classification methods in ...
2
votes
2
answers
171
views
AttributeError: 'DataFrame' object has no attribute 'to_file'. Did you mean: 'to_pickle'?
I have a workflow with QGIS, where I open an entire gdb, filter all layers by a common column and save all the filtered layers in a gpkg. I'm trying to make those steps with geopandas, so I don't ...
0
votes
1
answer
21
views
Uploading style (SLD) to GeoServer using REST API not working - for empty workspaces
I am trying to upload a layer using the GeoServer (2.28) REST API using the Importer extension in python. I ak not not what I am doing wrong.If I use the PUT method when the sld does not exists in an ...
2
votes
1
answer
184
views
Landsat Imagery comes up all white inside ROI
I'm trying to figure out why this shows a white region instead of color. I tried playing around with the min/max values and I cannot seem to find a solution to get true RBG color.
import ee
import ...
4
votes
1
answer
90
views
Why does gdal.Warp create a black region on the sides of some rasters when it reprojects and cuts them?
I have a JPEG of a red square, example.jpeg.
I use it as webmercator tile 6/36/16. I georeference it accordingly, using the bounds of 6/36/16 (I calculated them like this – details are irrelevant to ...
2
votes
1
answer
59
views
Getting rid off black/RGB pixels on edges caused by during reprojection with Python
I have large .tif file, and would like to reproject it and then create COG. But as a final result I have interrupted pixels on edges. How can i remove them?
Furthermore, the values are not only 0, ...
3
votes
1
answer
83
views
Truncate layer in ArcGIS Online using arcgis.gis
I'm trying to delete all features in a layer hosted in ArcGIS Online.
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
#Login AGOL
gis = GIS("https://www.arcgis.com", &...
0
votes
1
answer
48
views
QGIS Processing script to join two layers by two attributes
Since I work a lot with routing and trip matrices I have a daily need for joining two layers by two attributes (origin and destination).
I have had AI to support me in writing a Processing Script for ...
2
votes
0
answers
40
views
Efficient spatial join with OvertureMaps GeoParquet in SedonaDB
I want to check if points is contained in buildings and if so, join the buildings' attributes to them.
I looked through:
https://sedona.apache.org/sedonadb/latest/quickstart-python/
https://sedona....
3
votes
1
answer
112
views
Creating Mapbox Vector Tiles from GeoJSON without unnecessarily filling holes of the input geometry
I use geopandas/pyogrio to create a Mapbox Vector Tile from a GeoJSON. The shape in the vector tile ends up being wrong: some holes are filled.
Here is an example GeoJSON demonstrating the issue I am ...
0
votes
1
answer
31
views
Why is fiona.open causing a PermissionError?
I'm working on a flask app that takes a geojson file and returns a shapefile. Currently it is giving me the error PermissionError: [Errno 13] Permission denied: 'C:\\Users\\john\\Desktop\\...
1
vote
0
answers
48
views
GDAL Python bindings crash when calling gdal.Translate/gdal.Warp synchronously in PyQt5 GUI [closed]
I’m experiencing a hard crash (process terminates immediately, no Python exception) whenever I run GDAL operations like gdal.Translate or gdal.Warp synchronously in the main thread of a PyQt5 ...
0
votes
0
answers
73
views
What criteria could be used to automatically identify lakes in a DEM?
I have elevation data as a DEM PNG image and would like to automatically detect lakes. I have tried to use the following criteria:
Lakes are areas of adjacent pixels of equal grayscale color.
Pixels ...
2
votes
1
answer
67
views
How to use virtual environments within Docker images to access dependencies without having to reinstall GDAL?
I am trying to have a Docker container running an externally accessible JupyterLab, with the from osgeo import gdal Python command not failing. I hope to achieve this without reinstalling gdal ...
5
votes
1
answer
200
views
Skeletonize or extract lines from segmentation image
I have this raster:
which I'd like to convert to vector data (linestring) (e.g. a Shapefile).
To this end, I'm using this Python code:
import rasterio
import geopandas as gpd
from skimage.morphology ...
0
votes
1
answer
59
views
Python error: Couldn't load plugin 'Geo-SAM'
I have installed GeoSAM plugin on my QGIS LTS 3.40.11 on windows 11, according to the instruction here.
All steps of python dependencies passed and I installed required packages there after. Now I am ...
0
votes
1
answer
61
views
Windows 11 pytorch installation error
I am following this tutorial to install GeoSAM plugin for QGIS.
As I removed my old QGIS and installed the latest LTS version through OSGeo4W installer it seems that at some point the old installation ...
1
vote
1
answer
87
views
Reduce memory-footprint of point-in-polygon lookups in GeoPandas
Context:
I’m using a polygon layer as a makeshift gazetteer to find approximate addresses for point locations. My current workflow uses geopandas to:
Load the polygon dataset into memory
Use the ...
2
votes
1
answer
98
views
Overcoming temporary file writing error in GDAL
I am trying to use a Python package called hydrosar to apply a water mapping algorithm to a Sentinel-1 image. I am getting the following error:
Attempt to create new TIFF file C:\gdal_temp\tmp_xxxxx ...
1
vote
1
answer
190
views
How to create a COG using gdal.Warp without turning transparent pixels to black pixels?
I am trying to create a COG from a TIF file from OpenAerialMap. The initial file appears in QGIS nicely: areas which do not have data are transparent. However, when viewing the COG, some of the no ...
3
votes
1
answer
87
views
Issue plotting orthographic projection with GeoPandas
I'm getting an issue plotting countries in an orthographic projection with GeoPandas. It can be seen as a cut through Russia at the top of the image (white in the country and green in the ocean). I ...
1
vote
1
answer
61
views
How to reproject TIFFs to COGs and have TILING_SCHEME info in the output files when using GDAL?
Issue presented using GDAL called from Python
I have a TIFF file, src.tiff. I want to reproject it and create a COG, dst.tiff. To achieve that, I do the following:
from osgeo import gdal
warp_opts = ...
1
vote
0
answers
67
views
Running Python script before PostgreSQL authentication in QGIS
I'm working with PostgreSQL in QGIS and have a Python script that runs when the QGIS session starts.
Right now, the PostgreSQL connection requires authentication first, and only after that, the Python ...
0
votes
0
answers
68
views
QGIS 3.40 Geometric Attributes plugin causes fatal exception crash
I am using the centerlines tool on a complex polygon shapefile. The data are projected in EPSG:27700 (British National Grid). Each time I use the plugin it causes QGIS to crash with the following ...
1
vote
0
answers
57
views
Reading file from Google Cloud Storage with rasterio
I try to open a file from Google Cloud Storage (a cloud-optimised geotiff) using rasterio directly without downloading the whole blob manually. In this example, I simply want to download the number of ...
3
votes
1
answer
89
views
Reading geopackages with FLOAT fields with Fiona
I get
WARNING:fiona.ogrext:Skipping field t: invalid type (2, 3)
errors when reading a geopackage which has t FLOAT field. The reason seems to be that the subtype of the field is 3 (Single precision (...
0
votes
1
answer
53
views
ogr2ogr on ArcGIS Feature service - migrate to use gdal.VectorTranslate
I currently have a working console command, which translates an ArcGIS Feature Service to a geopackage.
The command line is as follows (where ive just replaced the full with the word 'url':
ogr2ogr -f ...
1
vote
1
answer
83
views
Converting single band DEM to 3D coordinates with Python
I have an elevation model in UTM Z13N, it has a single band representing EGM2008 height (EPSG:32613+3855). I want to create an array with the same shape, but each pixel contains the 3 components of ...
0
votes
1
answer
48
views
arcpy PointsToLine produces no output and no error
I have a situation where the arcpy tool PointsToLine silently fails. Ie, it produces no output and no errors.
My script runs the following code:
arcpy.PointsToLine_management(position_history_lyr, ...
2
votes
1
answer
120
views
Handling mixed datatypes in geospatial data in GeoTIFF file format
I am working with GeoTIFF file which is 2 byte 2 channel image. I am trying to create third derived channel which is ratio of first band and second band and trying to save this band in Float32 format ...
2
votes
1
answer
86
views
Raster and Vector data match in QGIS but do not match in Python
I am working with imagery from Pleides Neo3. I have some raster data in geotiffs and a vector mask as a .GML file.
When i open these files in QGIS, the raster and vector data are aligned.
The ...
3
votes
2
answers
267
views
GeoPandas does not detect unclosed polygons as invalid, unlike OGR
With GDAL 3.12.0dev-c93ac7701e7c5b3b5537598f2dea1e8a382cc81a, released 2025/08/08 I can extract some invalid unclosed rings in a shapefile, but I cannot get GeoPandas to extract them.
In order to play ...
2
votes
1
answer
92
views
Embed custom properties or variables to geopackage file/layer
Is it possible to embed custom properties or custom variables on a layer/geopackage file to be used on different projects ?
I tried layer.setCustomProperty('key', 'value') but this is only visible on ...
1
vote
0
answers
77
views
QGIS Union missing features
I am trying to get the overlap from polygon layers as new polygons. Classifying new polygons based on their overlap with other layers is the goal.
I am using union to achieve this. I am getting weird ...
2
votes
1
answer
150
views
Is GeoPandas is_valid_reason method the same as shapely explain_validity?
I've come across both geopandas.GeoSeries.is_valid_reason and shapely.validation.explain_validity, and I'm wondering if they are the same (i.e. if the same checks / the same code is executed under the ...
1
vote
1
answer
45
views
TypeError: zonal_stats() got an unexpected keyword argument 'stats' with rasterstats
I am creating a GET endpoint(FastAPI) which will take the local geojson and raster files and perform the stats and return. But the mentioned error is being thrown. I even upgraded the rasterstats. ...
0
votes
1
answer
89
views
Editing Python code to fix errors [closed]
I have the error:
Traceback (most recent call last): File "_________ (removed personal data) default/python/plugins\SDEllipse\SDEllipse.py", line 127, in run self.dlg.progressBar.setValue(0....
0
votes
0
answers
69
views
Using thin plate spline (openCV) and rasterio for georeferencing raster images
I have png file and several ground control points for him (points with pixel and geo coordinates). From reading documentation for rasterio I've got some understanding about how to georeference an ...
1
vote
1
answer
60
views
Rasterio: rasterize in 10 band?
I'm working with two inputs: a 10-band raster and a shapefile with polygons constructed over this raster. To create a mask of regions in the raster overlapped by the polygons, I use the following:
...
1
vote
0
answers
73
views
Properly uninstalling Python package in FME Form
In FME (2025.1.0.1, build 25609 at the time of writing), according to the official documentation, one can install Python packages using this command, e.g. on Windows:
C:\<install_dir>\FME> ...
1
vote
1
answer
153
views
Remove overlapping polygons but keep the top-most overlap using Python [closed]
I have a huge dataset of about 1 million+ features, of which many are overlapping. I would like to remove all the overlaps in each instance of overlap, but keep to top-most polygon.
This is for a ...
3
votes
3
answers
141
views
Loading badly formatted ESRI shapefile having duplicated field names in Python
When opening an ESRI shapefile in QGIS, it shows field names with more than 10 characters:
But when trying to load that same Shapefile using fiona (1.9.6):
import fiona
src = fiona.open(filepath)
...
0
votes
3
answers
88
views
Simplify geometry originated from viewshed raster image
I am doing a viewshed analysis on a DEM .tiff file. I would like to convert the viewshed raster into vector geometry in the format of .geojson, which i have achieved, although, the result is not good. ...
0
votes
0
answers
39
views
Morans I for binary raster data
i am fairly new to Moran's I and am currently trying to find out if it's even applicable to my data.
I have a collection of binary rasters showing the spread of Bark Beetles between 2018 and 2024. All ...
2
votes
1
answer
184
views
Efficiently remove holes from complex polygons while preserving geometry
Problem
I have a polygon dataset containing many features with holes of various sizes. For my downstream modeling workflow, I need polygons without any holes. The challenge is to remove these holes ...
0
votes
2
answers
100
views
Optimisation and robustness: Integrating shapefiles (sub-folders) into a single GeoPackage via a Python script [closed]
I created a Python script in order to insert a shapefile to geopackage.
Have you some advice in order to make this script better (readability, errors manage, etc). I'm open for any suggestion!
#...
1
vote
0
answers
48
views
How to generate raster layers interactively through Streamlit
I am trying to create an interactive map through Streamlit running on Python based around a building footprint shapefile layer, where I can use these building footprint shapes to generate buffer ...