<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<p>See <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/pull/11200">https://github.com/OSGeo/gdal/pull/11200</a> for an API and
sample script to offer that capability (that can scale to datasets
that don't fit in RAM)</p>
<p>Even<br>
</p>
<div class="moz-cite-prefix">Le 30/10/2024 à 01:31, Rahkonen Jukka
via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:DB9PR09MB688709C9E2EF933987BE0FCDFD542@DB9PR09MB6887.eurprd09.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator"
content="Microsoft Word 15 (filtered medium)">
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}span.Shkpostityyli17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
mso-ligatures:none;
mso-fareast-language:EN-US;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">I would like to know the
georeferenced coordinates of the min and max values of a DEM
file. Even better if I could forward them into a vector
file. If the minimum or maximum happens to be on a flat area
like seabed I would be happy with the first pixel at the
moment.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">By copy-pasting from </span><a
href="https://stackoverflow.com/questions/41996079/how-do-i-open-geotiff-images-with-gdal-in-python"
moz-do-not-send="true"><span lang="EN-US">How do I open
geotiff images with GDAL in Python? - Stack Overflow</span></a>
<span lang="EN-US">and </span><a
href="https://en.moonbooks.org/Articles/How-to-find-the-indexes-of-the-minimum-or-maximum-values-in-a-matrix-using-python-/"
moz-do-not-send="true"><span lang="EN-US">How to find the
indexes of the minimum or maximum value(s) in a matrix
using python ?</span></a> <span lang="EN-US">I think I
managed to get the correct points as numpy indexes<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> import
numpy as np<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> from osgeo
import gdal<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> ds =
gdal.Open('P3412A.tif', gdal.GA_ReadOnly)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> rb =
ds.GetRasterBand(1)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> img_array =
rb.ReadAsArray()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> vmin =
img_array.min()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> vmax =
img_array.max()<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> vmin<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">-0.929<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>> vmax<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">17.246<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>>
np.where(img_array==vmin)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">(array([1504],
dtype=intg64), array([1189], dtype=int64))<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>>
np.where(img_array==vmax)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">(array([1545],
dtype=int64), array([2423], dtype=int64))<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">>>><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">But now I have no idea
about how to get the georeferenced coordinates.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The task feels rather
simple and I was sure that someone has already made an
utility or a QGIS plugin, but all I have found yet is for R.
I was thinking that perhaps some of the gdaldem modes could
be misused for this purpose, but I believe they cannot. For
QGIS I found advice to use an obvious but clumsy method of
polygonising the raster and finding the extremes from the
vector data. And one OpenJUMP developer took the challenge
and wrote a prototype with Java but it is not complete yet.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.
Butcher of all kinds of standards, open or closed formats. At the end, this is just about bytes.</pre>
</body>
</html>