<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.m-167853682444867102apple-style-span
{mso-style-name:m_-167853682444867102apple-style-span;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;
font-weight:bold;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
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]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Paul,<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">You could call gdal_calc.py and pass it the numpy formulas on the command line…Otherwise it might be best to bring the raster in to OpenCV.
<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--Eric<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> gdal-dev [mailto:gdal-dev-bounces@lists.osgeo.org]
<b>On Behalf Of </b>Paul Meems<br>
<b>Sent:</b> Thursday, August 03, 2017 2:51 PM<br>
<b>To:</b> Chris Waigl<br>
<b>Cc:</b> gdal-dev@lists.osgeo.org<br>
<b>Subject:</b> Re: [gdal-dev] Raster statistics<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Thanks Chris for your reply.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I forgot to mention I'm not using GDAL with Python.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I use it with C++ and/or C#.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
Paul<o:p></o:p></p>
<div>
<div style="border:solid #E5E5E5 1.0pt;padding:10.0pt 10.0pt 4.0pt 10.0pt">
<div style="margin-bottom:6.0pt">
<p style="margin:0in;margin-bottom:.0001pt;background:#F8F8F8"><b><span style="font-size:10.0pt;font-family:"Verdana","sans-serif""><img width="160" height="120" id="_x0000_i1025" src="http://www.bontepaarden.nl/bontepaarden/images/newButton.png">Paul Meems </span></b><span style="font-size:10.0pt;font-family:"Verdana","sans-serif""><br>
Release manager, configuration manager<br>
and forum moderator of MapWindow GIS.<br>
<a href="http://www.mapwindow.org/" target="_blank">www.mapwindow.org</a><br>
<br>
Owner of MapWindow.nl - Support for<br>
Dutch speaking users.<br>
<a href="http://www.mapwindow.nl/" target="_blank">www.mapwindow.nl</a><o:p></o:p></span></p>
<p style="margin:0in;margin-bottom:.0001pt;background:#F8F8F8"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif""><o:p> </o:p></span></p>
<p style="margin:0in;margin-bottom:.0001pt;background:#F8F8F8"><b><span style="font-size:10.0pt;font-family:"Verdana","sans-serif"">The MapWindow GIS project has moved to
<a href="https://github.com/MapWindow" target="_blank">GitHub</a>!</span></b><span style="font-size:10.0pt;font-family:"Verdana","sans-serif""><o:p></o:p></span></p>
<p style="margin:0in;margin-bottom:.0001pt;background:#F8F8F8"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif""><br>
<a href="https://github.com/MapWindow/MapWinGIS/releases" target="_blank">Download the latest MapWinGIS mapping engine.</a><o:p></o:p></span></p>
<p style="margin:0in;margin-bottom:.0001pt;background:#F8F8F8"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif""><a href="https://github.com/MapWindow/MapWindow5/releases" target="_blank">Download the latest MapWindow 5 open source desktop application.</a><o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana","sans-serif""><img border="0" width="1" height="1" id="_x0000_i1026" src="http://portal.mxlogic.com/images/transparent.gif"><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">2017-08-03 20:05 GMT+02:00 Chris Waigl <<a href="mailto:cwaigl@alaska.edu" target="_blank">cwaigl@alaska.edu</a>>:<o:p></o:p></p>
<div>
<p class="MsoNormal">I would not use gdal for this particular task. I presume you have the band data in a 2D numpy array. Then I’d get the 80th percentile for example with np.percentile() and use a boolean expression to generate a mask for the array (droneraster
> perc80value ).<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Chris<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span class="m-167853682444867102apple-style-span"><span style="font-family:"Courier New";color:black">-- </span></span><span style="font-family:"Helvetica","sans-serif";color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span class="m-167853682444867102apple-style-span"><span style="font-family:"Courier New";color:black">Christine (Chris) Waigl -
<a href="mailto:cwaigl@alaska.edu" target="_blank">cwaigl@alaska.edu</a> - <a href="tel:(907)%20474-5483" target="_blank">+1-907-474-5483</a> - Skype: cwaigl_work</span></span><span style="font-family:"Helvetica","sans-serif";color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span class="m-167853682444867102apple-style-span"><span style="font-family:"Courier New";color:black">Geophysical Institute, UAF, 903 Koyukuk Drive, Fairbanks, AK 99775-7320, USA</span></span><span style="font-family:"Helvetica","sans-serif";color:black"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-family:"Helvetica","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-family:"Helvetica","sans-serif";color:black"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-family:Consolas;color:black"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<p class="MsoNormal">On Aug 3, 2017, at 5:43 AM, Paul Meems <<a href="mailto:bontepaarden@gmail.com" target="_blank">bontepaarden@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">I have a drone raster file which I want to use for some calculation.<o:p></o:p></p>
<div>
<p class="MsoNormal">Before the calculation, I need to loose some extreme values.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I want to do something like a percentile calculation where you get all values, order them and loose the top 10%.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">For this, I need to get all values first which can be slow when using a large file.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I looked at the statistics (band.GetStatistics) but that doesn't work well.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I thought I could use 2 times the standard deviation added to the mean to get roughly 97%.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">But with these statistics:<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> STATISTICS_MAXIMUM=33.186080932617</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> STATISTICS_MEAN=24.840205979603</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> STATISTICS_MINIMUM=1.5951598882675</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> STATISTICS_STDDEV=4.7285348016053</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Mean + 2*std is larger than the max.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">So I moved to the histogram. It is also very fast, but I'm not sure how to use it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I have this:<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> 256 buckets from 1.53322 to 33.248:</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New""> 410 77 66 66 65 58 56 45 42 87 57 72 61 65 68 70 73 82 93 ...</span><o:p></o:p></p>
</div>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Does this mean, bucket 1 = 410 that I have 410 pixels of value 1.53322 and the second bucket means I have 77 pixels between 1.53322 and 1.657? 1.657 = 1.53322 + ((33.248 - 1.53322)/256)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is this a good approach? Or can/should I use a different one.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<br>
<br>
Paul<o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>