[gdal-dev] Get max elevation on "squares"

Alan Snow alansnow21 at gmail.com
Tue Dec 28 07:45:21 PST 2021


This resource is useful to help you get started exploring raster data with
Python:

https://carpentries-incubator.github.io/geospatial-python/05-raster-structure/index.html

https://www.earthdatascience.org/courses/use-data-open-source-python/intro-raster-data-python/raster-data-processing/


If the CRS of your raster is not in meters, you will need to reproject your
raster. I recommend changing the grid cell size in the same operation and
using Resampling.max. Here are some helpful references:

https://rasterio.readthedocs.io/en/latest/topics/virtual-warping.html

https://corteva.github.io/rioxarray/stable/examples/reproject.html#Reproject-Large-Rasters-with-Virtual-Warping

On Tue, Dec 28, 2021, 12:56 AM Luca Bertoncello <lucabert at lucabert.de>
wrote:

> Am 28.12.2021 um 04:54 schrieb Alan Snow:
>
> Hi Alan
>
> > After some thought, you may achieve what you want by resampling the file
> > to a 5km grid size with the Resampling.max option:
>
> This is a good idea... I will need to write some code in Python (I don't
> really know this language), but I think I'll get it...
>
> > You can then store the centroid of the grid cell and the value in a
> > database.
>
> Yes, I already see with gdalinfo -mm (maybe there is a possibility to
> check it with Python?) I can get the maximum elevation and the centroid.
>
> Just some question, to correctly understand the code sample:
>
> 1) I think, dataset.read get the size as parameter, correct? Are there
> meter/kilometer/something other?
> I searched some information about DatasetReader.read but I didn't found
> anything...
> 2) In the example the new image will not be saved, is it correct? How
> can I do that? I didn't found any function DatasetReader.save...
> 3) Maybe is it possible to do that in BASH? As I sayd, I'm not really
> fit in Python... :(
>
> Thanks a lot
> Luca Bertoncello
> (lucabert at lucabert.de)
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20211228/45d50e6a/attachment.html>


More information about the gdal-dev mailing list