All Questions
Tagged with gdal python-3.x
109 questions
0
votes
0
answers
27
views
gdalwarp ERROR 1: Invalid pixel size for backmap
I used following command to generate geotiff file for VIIRS NetCDF file:
./gdalwarp -geoloc -t_srs epsg:4326 -tr 0.0035 0.0035 -r near -te -70.18 -7.64 -43.96 30.91 dat.vrt i4b.tif
but failed with ...
0
votes
0
answers
53
views
How to package a Python program that uses GDAL into an executable file using PyInstaller?
I want to package my Python code that uses GDAL into an executable file using PyInstaller, but I keep encountering missing dependencies. Can someone provide a detailed tutorial, including how to ...
1
vote
1
answer
695
views
No module named 'osgeo._gdal_array' - Docker image with Python and GDAL
I'm having trouble using GDAL in docker.
My application locally but when on docker I get this error:
ModuleNotFoundError: No module named 'osgeo._gdal_array'
I created here a small example to make ...
0
votes
3
answers
2k
views
problems installing gdal module on ubuntu python version 3.10.6
I had installed gdal on ubuntu for python version 3.10.6 using pip3 install. Unfortunately when I attempt to run a program with the following line:
import gdal
I get the following error:
Traceback (...
0
votes
1
answer
2k
views
How can I fix 'ModuleNotFoundError: No module named gdal' when trying to import the gdal module in Visual Studio Code using Python?
gdal is not imported
I have installed GDAL with Conda and it is available in the Conda list. However, when I try to import gdal in Visual Studio Code (Python file), I get the error
ModuleNotFoundError:...
1
vote
0
answers
29
views
Python package installed but not importable
I recently installed the package gdal for geospatial data handling, with the help of anaconda navigator. When I type to my MacOS terminal 'conda list', it definitely shows that gdal is installed.
...
2
votes
1
answer
1k
views
Error running GDAL scripts with Python3 on macOS 12 (Monterrey)
I know this has been asked somewhere else, but I can't find the solution for my environment:
macOS 12.6
Python 3.11.2
GDAL 3.6.3
Homebrew 4.0.10
Also I'm using Zsh.
I managed to install correctly ...
4
votes
1
answer
5k
views
OSError: /usr/lib/libgdal.so: cannot open shared object file: No such file or directory
I'm using Django 3.2 on Ubuntu 22.04 LTS. I'm running a docker container with a django-rest-api web server with python 3.8.14.I'm getting an error with regards to the GDAL library when i run docker-...
0
votes
0
answers
750
views
Django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library ,Is GDAL installed?
This comes from the continuation of my question here :
error in GDAL setup command: use_2to3 is invalid
Since the nature of error has changed, its important to post it separately.
I'm running Django ...
0
votes
0
answers
38
views
error in GDAL setup command: use_2to3 is invalid [duplicate]
I'm running Django rest api with the django 3.2 on GCPUbuntu 20.04.5 LTS (GNU/Linux 5.15.0-1025-gcp x86_64). I'm facing a problem when I run docker-compose command. The trace points to Gdal.
Currently,...
3
votes
0
answers
2k
views
gdal_config_error: [Errno 2] No such file or directory: 'gdal-config'
I'm running Django rest api with the django 3.2 on GCPUbuntu 20.04.5 LTS (GNU/Linux 5.15.0-1025-gcp x86_64). I'm getting an error when i run my docker containers. I need to use GDAL in one of my ...
1
vote
0
answers
145
views
Memory leak -- rasterio.MemoryFile()?
Code:
import numpy as np
import os
import psutil
import rasterio
from memory_profiler import profile
@profile
def main():
profile = dict(
count=1,
height=30000,
width=30000,
...
0
votes
0
answers
234
views
python not giving same results as gdal command line
I have an interpolated file which has positive Z values , so I want to use gdal_calc to make them negative.
This works on the gdalcommand line with
gdal_calc -a interpolated.tif --outfile ...
7
votes
2
answers
21k
views
Install GDAL on LINUX Ubuntu 20.04.4LTS for python
I've been having a lot of problems with this install, especially with various unmet dependencies.
these are my system infos:
Linux
Ubuntu 20.04.4 LTS
64-bit
Gnome_Version: 3.36.8
Python
using a &...
2
votes
2
answers
2k
views
How to retrieve all variable names within a netcdf using GDAL
I am struggling to find a way to retrieve metadata information from a FILE using GDAL.
Specifically, I would like to retrieve the band names and the order in which they are stored in a given file (may ...
0
votes
1
answer
267
views
How to save certain ogrinfo results to a variable?
I am using gdal's ogrinfo command in Python to obtain information about a shapefile.
My code is as follows:
from subprocess import Popen, PIPE
args = ['ogrinfo', '-ro', '-so', '-al', 'C:/test/...
2
votes
0
answers
863
views
GDAL and Fiona conflicting versions but downgrading Fiona leads to a legacy-install-failure error
This question is similar to the questions
Installing fiona: Must the gdal version be compatible with fiona? and
ImportError: the 'read_file' function requires the 'fiona' package, but ...
3
votes
0
answers
502
views
Error Updating GDAL using pip (python3) on Ubuntu 20.04 LTS
I have a Linux Server (Ubuntu 20.04 LTS) and I am trying to update GDAL.
All below has been used to update packages:
/usr/bin/python3 -m pip install --upgrade pip
/usr/bin/python3 -m pip install --...
4
votes
1
answer
2k
views
ValueError: Received a null pointer
I'm writing a code to convert GeoTiff files to png.
Pillow didn't work for me. Hence I am using gdal. Am I missing something in the code?
The code is as below:
from osgeo import gdal
import os
...
0
votes
0
answers
156
views
Trying to install APLS on Google Colab
So basically i'm trying to install Apls from this repo: https://github.com/CosmiQ/apls
However, I keep running into issue with GDAL and Fiona.
First, I tried to install it on my local machine (...
1
vote
1
answer
2k
views
Loading a GRIB from the web in Python without saving the file locally
I would like to download a GRIB file from the web:
Opt1: https://noaa-gfs-bdp-pds.s3.amazonaws.com/gfs.20210801/12/atmos/gfs.t12z.pgrb2.1p00.f000
Opt2: https://www.ncei.noaa.gov/data/global-forecast-...
9
votes
4
answers
11k
views
Error building pygdal: Unknown distribution option: 'use_2to3_fixers' and 'use_2to3_exclude_fixers'
Solution provided below:
Started getting errors when building pygdal on Ubuntu 20.04:
# Command
python3 -m pip install --no-cache-dir pygdal==3.0.4.*
produces the following output
Collecting pygdal==...
1
vote
1
answer
940
views
Unable to import module 'app': No module named 'distutils.util' - Dockerfile GDAL and geopandas python 3
We going to have a AWS Lambda function (python3) created with Docker container (Elastic Container Registry)
When test the Lambda function, we have an error
Unable to import module 'app': No module ...
12
votes
6
answers
5k
views
M1 Mac - GDAL Wrong Architecture Error [Django]
I'm trying to get a django project up and running, which depends on GDAL library. I'm working on a M1 based mac.
Following the instructions on official Django docs, I've installed the necessary ...
1
vote
0
answers
1k
views
Python gdalwarp incorrectly resample raster files
I am using gdalwarp of GDAL3.1.4 to resample a raster from (0.0125, 0.00833 degree) to (0.03125, 0.025 degree).
To do so, I used the following code
ds= gdal.Open("test.tif", gdal.GA_ReadOnly)...
0
votes
3
answers
1k
views
Adding a progress bar to gdal.Translate()
Similar to Adding Progress Bar to gdal.Warp() but for python 3. How to add a progress bar to gdal.Translate() in a python script?
-3
votes
1
answer
70
views
How to deal with the errors when installing natcap.invest?
I try to install natcap.invest package in order to do some research using the InVEST model. But when I use pip to install it, lots of errors occur in the cmd window(like the message below). I don't ...
1
vote
0
answers
250
views
gdalwarp and gdal_translate give different results
I tried splitting the dem into tiled areas
gdal.Warp(dst, src, options=gdal.WarpOptions(outputBounds=(minx, miny, maxx, maxy))
But this code was too slow, so I split the DEM using 'ReadRaster' and '...
0
votes
2
answers
869
views
Pick random pixels' centroids within raster area - Python+gdal
I have a raster file in WGS84 projection and I am trying to get the coordinates of random pixels within the raster GeoTIFF area down left in picture. At first, I calculate the coordinates of each ...
0
votes
1
answer
919
views
Rasterio MemoryFile to Pillow image (Or base64 output)
I'm trying to write an AWS Lambda function that takes a TIFF, converts it to JPEG, then outputs it in base64 so that lambda can serve it. But I keep running into malformed response, or issues with ...
0
votes
0
answers
431
views
Converting SMAP h5 file to GeoTiff
I am trying to convert .h5 SMAP file to geotiff, but I keep getting
File "<ipython-input-17-d6b129648904>", line 1
gdal_translate -a_srs "EPSG:3662" -a_ullr -20037508.3428 ...
1
vote
1
answer
448
views
GDAL 3.1.2 / PROJ 6.2.1 / GCC 10.2 Unable to handle Shape File
Overall Error: gdal_polygonize.py fails with "Cannot guess driver for" I am at a loss here, I have been playing with dependencies and libraries and things but I am getting no where. I ...
1
vote
2
answers
739
views
Unable to install GDAL with Anaconda + Pytorch (2020)
I want to install GDAL in an Anaconda environment along with Pytorch. I am using Ubuntu 18.04 LTS
I tried 3 versions of Anaconda (2019.03, 2019.07, 2020.11).
I followed the advice mentioned in ...
23
votes
1
answer
24k
views
No such file or directory: 'gdal-config'
I am trying to install fiona and geopandas on a mac machine.
I have installed GDAL trough brew install gdal --HEAD
If I try install fiona, I get the following:
sudo pip3 install fiona
Collecting fiona
...
1
vote
1
answer
246
views
How to create a function that returns the raster value at a given latitude and longitude?
Currently, I am working with some tiff files that contain information about precipitation, and I want to combine them with a pre-existing dataframe.
This dataframe has columns that give the latitude ...
1
vote
2
answers
278
views
Read OpenAir File using Python GDAL
I need to read OpenAir files in Python.
According to the following vector driver description, GDAL has built-in OpenAir functionality:
https://gdal.org/drivers/vector/openair.html
However there is no ...
1
vote
0
answers
2k
views
ProjError: Error creating Transformer from CRS.:
I am having an issue with Geopandas and PyProj.
I am loading a premade shp file from GeoPandas
borough = gpd.read_file(gpd.datasets.get_path('nybb'))
When trying to do a crs transformation with the ...
1
vote
1
answer
1k
views
Save projected raster as a variable and not as a file Python
I would like to reproject a raster and keep working on that reprojected raster instead of loading it again from a file.
To project a raster I use either gdal:
# Source
src = gdal.Open(vv_path, ...
0
votes
0
answers
285
views
Mean of 5 X 5 neighbor pixels of raster in Python
I have multiples raster with pixel resolution 10 X 10 meters and the raster value is in float format and I want to keep the out raster value in float format only.
I want to calculate 5 x 5 window ...
0
votes
1
answer
2k
views
Installing GDAL and Fiona on Python 3.7/3.8 and (W10)
I unfortunately can't manage to install Fiona on Windows 10.
What I have tried:
Installing Python 3.7
Installing GDAL according to https://sandbox.idre.ucla.edu/sandbox/tutorials/installing-gdal-for-...
0
votes
1
answer
248
views
Exporting gdal geotiff to MySQL
I am able to read in a geotiff file. I can plot it without problems and so on...
But I want to be able to export it to a MySQL-Server via python code and then read it in from that server again via ...
3
votes
1
answer
4k
views
How do I install GDAL in a Python Docker environment?
I'm using Python 3.7 and Django 3.0. I want to install this requirement
GDAL==2.4.2
in my Django Docker environment. Below is my Docker file ...
FROM python:3.7-slim
RUN apt-get update &&...
1
vote
1
answer
8k
views
Install geopandas in Pycharm
Sorry if this is a repeat question, But I am new to Python and trying to install Geopandas in Pycharm.
My python version is 3.7.2.
I have tried the conventional way of installing library in pycharm ...
1
vote
1
answer
3k
views
installing gdal in pycharm
I have been trying to import "gdal" in PyCharm for a couple of hours now, but without success and I do not know any further now.
In the Anaconda Powershell I installed gdal:
conda install gdal,
and ...
1
vote
1
answer
2k
views
Get image from ee.reduceRegion Google Earth Engine Python
As the function documentation suggests, we know that the reduceRegion() function comes in handy when we get the 'Too many pixels' error due to server restrictions. I'm currently working on Google ...
0
votes
1
answer
2k
views
Save image from byte data with python gdal
I'm retrieving a Sentinel-2 image with metadata from an ArcGIS REST API server. It comes as a byte string. I currently first write the data to a tif-file with f.write(). Then I open it with imageio ...
27
votes
4
answers
54k
views
Set SHAPE_RESTORE_SHX config option to YES to restore or create it
I am not able to read the shape file. It says no such working directory.
!pip install sentinelsat
!pip install geopandas
!pip install folium
from sentinelsat import SentinelAPI
user = '****'
...
0
votes
0
answers
297
views
pip3 install GDAL on Mac Catalina (10.15) problem
I am trying to install GDAL module for python 3 on my mac. So far, I have tried all of the answers available online, but nothing has worked. I have downloaded and installed the GDAL framework from ...
0
votes
0
answers
775
views
gdal-config not found, Ubuntu 18.0.4, deploy on gcloud
So I have been struggling to set gdal with gcloud. I am working with anaconda although my virtual environment was set with pip as gcloud will use pip through my requirements to recreate my venv. I ...