gdal

How do I access a shapefile using gdal?

How do I access a shapefile using gdal? Question: I am trying to use the following code to access a shapefile: import os from osgeo import gdal from osgeo import ogr from osgeo import osr shp_path = "xxxxxxxx" if __name__==’__main__’: ogr.RegisterAll() gdal.SetConfigOption("SHAPE_ENCODING", "UTF-8") gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES") oDriver = ogr.GetDriverByName("ESRI Shapefile") path_list= os.listdir(shp_path) for dir in path_list: …

Total answers: 1

ImportError: cannot import name '_gdal_array' from 'osgeo'

ImportError: cannot import name '_gdal_array' from 'osgeo' Question: I create a fresh environment, install numpy, then install GDAL. GDAL imports successfully and I can open images using gdal.Open(, but I get the ImportError: cannot import name ‘_gdal_array’ from ‘osgeo’ error when trying to use ReadAsRaster. pip list returns: GDAL 3.6.2 numpy 1.24.2 pip 23.0 setuptools …

Total answers: 1

How to read a H5 file containing satellite data in Python?

How to read a H5 file containing satellite data in Python? Question: As part of a project I’m exploring satellite data and the data is available in H5 format. I’m new to this format and I’m unable to process the data. I’m able to open the file in a software called Panoply and found that …

Total answers: 1

get elevation from lat/long of geotiff data in gdal

get elevation from lat/long of geotiff data in gdal Question: I have a mosaic tif file (gdalinfo below) I made (with some additional info on the tiles here) and have looked extensively for a function that simply returns the elevation (the z value of this mosaic) for a given lat/long. The functions I’ve seen want …

Total answers: 1

pip uninstall GDAL gives AttributeError: 'PathMetadata' object has no attribute 'isdir'

pip uninstall GDAL gives AttributeError: 'PathMetadata' object has no attribute 'isdir' Question: I’m trying to pip install geopandas as a fresh installation, so I want to remove existing packages like GDAL and fiona. I’ve already managed to pip uninstall fiona, but when I try to uninstall or reinstall GDAL it gives the following error message: …

Total answers: 2

Trying to install GDAL – Python 3.9.9 – Pip – Windows 10

Trying to install GDAL – Python 3.9.9 – Pip – Windows 10 Question: I’m trying to install gdal library with pip install gdal I’m using: python 3.9.9 Windows 10 But i’m having this error : C:UsersThomas>pip install gdal Collecting gdal Using cached GDAL-3.4.1.tar.gz (755 kB) Preparing metadata (setup.py) … done Building wheels for collected packages: …

Total answers: 2

Determine version of package to install via bash command's output in Poetry

Determine version of package to install via bash command's output in Poetry Question: I am trying to install a Python package via Poetry whose version to install should be determined based on the output (~return value) of a Bash command. Is it possible doing something (in the pyproject.toml) along the lines of: [tool.poetry.dependencies] python = …

Total answers: 1

M1 Mac – GDAL Wrong Architecture Error [Django]

M1 Mac – GDAL Wrong Architecture Error [Django] Question: 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 packages via brew $ brew install postgresql $ brew install postgis $ brew …

Total answers: 5

(M1 Mac) Geodjango GDAL: mach-o, but wrong architecture

(M1 Mac) Geodjango GDAL: mach-o, but wrong architecture Question: I am trying to get GeoDjango running on mac os and have hit a problem with GDAL. I have downloaded and installed GDAL without problem (Gdal Complete Binary) also installed from homebrew too. Unfortunately when i was installed gdal with homebrew django can’t find the gdal …

Total answers: 3

How to speed up extracting data from raster file for points using GDAL python

How to speed up extracting data from raster file for points using GDAL python Question: I have 366 raster image files (MODIS satellite daily data) in tif format containing snow data and another csv file containing 19,000 locations (latitude and longitudes). I need to collect the snow data from raster files. I have tried collecting …

Total answers: 2