<div dir="ltr">I put in a ticket to the USGS National Map help desk so they'll know it needs to be fixed. I'm sure some USGS folks watch this forum too.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">Kirk Waters, PhD </font></div><div><font face="arial, helvetica, sans-serif">NOAA Office for Coastal Management<br></font></div><div><font face="arial, helvetica, sans-serif">Applied Sciences Program </font></div><div>Phone: 843-284-6962 (email preferred) <font face="arial, helvetica, sans-serif"> </font><div><font face="arial, helvetica, sans-serif"><a href="http://coast.noaa.gov/digitalcoast" target="_blank">coast.noaa.gov/digitalcoast</a></font></div></div><div>[he/him]</div><div><br><br></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 22, 2024 at 4:57 AM Even Rouault via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<p>Hi,</p>
<p>having looked at the file, I believe GDAL behaves correctly given
the metadata in the file. This is clearly a unit type attached to
the Band, and it should be corrected by the data producer to
reflect what is really used in it</p>
<p>One way to correct it on your side is for example this little
Python snippet<br>
</p>
<p>from osgeo import gdal<br>
ds = gdal.Open('test.tif')<br>
ds.GetRasterBand(1).SetUnitType('metre')</p>
<p>As the file is used in read-only mode, this will generate an
auxiliary .aux.xml side car file overriding the unit.</p>
<p>You can also directly override the wrong metadata inside the TIFF
with<br>
</p>
<p>ds = gdal.OpenEx('test.tif',
open_options=['IGNORE_COG_LAYOUT_BREAK=YES'])<br>
ds.GetRasterBand(1).SetUnitType('metre')</p>
<p>The IGNORE_COG_LAYOUT_BREAK=YES open option is because modifying
TIFF metadata causes it to be rewritten at the end of the file,
which "breaks" the COG convention. But that's still a perfectly
valid GeoTIFF file, and will not change anything for local use of
such file. You could reprocess that to a fully compliant COG with
gdal_translate -of COG<br>
</p>
<p>Regarding how that is used by gdalwarp, the doc enhancement at
<a href="https://github.com/OSGeo/gdal/pull/9527" target="_blank">https://github.com/OSGeo/gdal/pull/9527</a> captures my initial
attempt at answering your questions.</p>
<p><span></span></p>
<p><span>Even</span></p>
<p><span><br>
</span></p>
<div>Le 22/03/2024 à 01:16, Conrad Bielski a
écrit :<br>
</div>
<blockquote type="cite">
<div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px">
<div dir="ltr">Just realised I should have
put you also in CC</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Here is my response message
again.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">
<div>
<div dir="ltr">Thanks <span>Even,</span></div>
<div dir="ltr"><span><br clear="none">
</span></div>
<div dir="ltr"><span>you are correct about the tag number (I
sent the incorrrect one).</span></div>
<div dir="ltr"><span><br clear="none">
</span></div>
<div dir="ltr"><span>I have provided a sample tif and some
other descriptions of the issue here:</span></div>
<div dir="ltr"><a shape="rect" href="https://drive.google.com/drive/folders/1LVJqoKrnLRf6_5FpE7a5SrUGIWBPQmqa?usp=sharing" rel="noreferrer noopener" target="_blank">bad_geotiff - Google Drive</a></div>
<div><br clear="none">
</div>
<div id="m_-7689708504940424091ydpbd5ef252yiv1599055091ydpf608df10enhancr_card_1237347669" style="max-width:400px;font-family:"YahooSans VF",YahooSans,"OpenSans VF","Helvetica Neue","Segoe UI",Helvetica,Arial,sans-serif"><a shape="rect" href="https://drive.google.com/drive/folders/1LVJqoKrnLRf6_5FpE7a5SrUGIWBPQmqa?usp=sharing" style="text-decoration-line:none;text-decoration-style:solid;text-decoration-color:currentcolor;color:rgb(0,0,0)" rel="noreferrer noopener" target="_blank">
<table style="max-width:400px" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td colspan="1" rowspan="1" width="400">
<table style="max-width:400px;border-width:1px;border-style:solid;border-color:rgb(224,228,233);border-radius:2px" width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td colspan="1" rowspan="1">
<table style="background-color:rgb(255,255,255);background-repeat:repeat;background-image:none;background-size:auto;width:100%;max-width:400px;border-radius:0px 0px 2px 2px;border-top:1px solid rgb(224,228,233)" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td colspan="1" rowspan="1" style="background-color:rgb(255,255,255);padding:16px 0px 16px 12px;vertical-align:top;border-radius:0px 0px 0px 2px"><img src="https://s.yimg.com/lb/brands/80x80_google.png" style="min-width: 36px; margin-top: 3px;" height="36"></td>
<td colspan="1" rowspan="1" style="vertical-align:middle;padding:12px 24px 16px 12px;width:99%;font-family:"YahooSans VF",YahooSans,"OpenSans VF","Helvetica Neue","Segoe UI",Helvetica,Arial,sans-serif;border-radius:0px 0px 2px">
<h2 style="font-size:14px;line-height:19px;margin:0px 0px 6px;font-family:"YahooSans VF",YahooSans,"OpenSans VF","Helvetica Neue","Segoe UI",Helvetica,Arial,sans-serif;color:rgb(29,34,40);max-width:314px">bad_geotiff -
Google Drive</h2>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</a>
<div style="width:100%;min-height:0px">
<div>
<div><span></span></div>
</div>
</div>
</div>
<div><br clear="none">
</div>
<div dir="ltr">The three files there are the following:</div>
<div dir="ltr">
<div>
<div>1. A bad tiff (this is slightly smaller; they are
all pretty big).</div>
<div>2. A GDAL info dump (survey feet is almost at the
bottom)</div>
<div>3. A PDF with an explanation of the issue</div>
</div>
</div>
<div dir="ltr"><br clear="none">
</div>
<div dir="ltr">thanks for your help.</div>
Conrad</div>
</div>
<div dir="ltr"><br>
</div>
<div><br>
</div>
</div>
<div id="m_-7689708504940424091ydpe49ee55fyahoo_quoted_1291212430">
<div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;color:rgb(38,40,42)">
<div> On Thursday, March 21, 2024 at 04:49:57 PM EDT, Even
Rouault <a href="mailto:even.rouault@spatialys.com" target="_blank"><even.rouault@spatialys.com></a> wrote: </div>
<div><br>
</div>
<div><br>
</div>
<div>
<div id="m_-7689708504940424091ydpe49ee55fyiv1570019766">
<div>
<p><br clear="none">
</p>
<div>Le
21/03/2024 à 21:45, Conrad Bielski via gdal-dev a
écrit :<br clear="none">
</div>
<blockquote type="cite"> </blockquote>
</div>
<div>
<div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px">
<div dir="ltr">
<div>Hello GDALers,<br clear="none">
<br clear="none">
I have a question about reading USGS 3DEP (3D
Elevation Program) data. Inside of this data, a
GEOTIFF tag 42114 is provided which is causing
problems with datum shifts.<br clear="none">
</div>
</div>
</div>
<p>There's no such thing as a GEOTIFF tag 42114.</p>
<p>The closest tags are:<br clear="none">
</p>
<p>#define TIFFTAG_GDAL_METADATA 42112<br clear="none">
#define TIFFTAG_GDAL_NODATA 42113<br clear="none">
</p>
<p>It would be helpuful if you could provide the file,
or the result of a "tiffdump -m 1000 the.tif" and
"listgeo the.tif" on it.</p>
<p>And was the .tif.aux.xml provided with the TIFF, or
computed by GDAL. Because the information might come
from it too.</p>
<div id="m_-7689708504940424091ydpe49ee55fyiv1570019766yqtfd56535"><br clear="none">
</div>
<div id="m_-7689708504940424091ydpe49ee55fyiv1570019766yqtfd92313"> </div>
<blockquote type="cite">
<div id="m_-7689708504940424091ydpe49ee55fyiv1570019766yqtfd44669"> </div>
<div style="font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px">
<div id="m_-7689708504940424091ydpe49ee55fyiv1570019766yqtfd29015">
<div dir="ltr">
<div><br clear="none">
So when I use GDAL to compute the datum
shifts, the tag is read and interprets that
the DEM is showing elevation in 'feet' while
the DEM is actually in metres. The DEMs are in
fact in meter elevations and meter UTM
horizontal coordinates. This is obviously
erroneously integrated into the tag.<br clear="none">
<br clear="none">
So my question is whether anyone has come
across this issue and found a solution? Is
there a way to edit the offending tag so that
it is correctly interpreted as metres instead
of feet? Other potential solutions so that
GDAL interprets the elevation correctly?<br clear="none">
<br clear="none">
Thanks in advance for your help. I provide
below the output of gdalinfo which I hope
could help with the offending info in bold.<br clear="none">
<br clear="none">
Have a great day,<br clear="none">
Conrad<br clear="none">
<br clear="none">
</div>
<br clear="none">
</div>
<div><br clear="none">
</div>
<div><br clear="none">
</div>
</div>
<div dir="ltr">
<div id="m_-7689708504940424091ydpe49ee55fyiv1570019766yqtfd71024">
<div>Driver: GTiff/GeoTIFF<br clear="none">
Files:
I:\v3_us_3dep\asheville\ashevilleUSGS_1M_17_x34y392_NC_Phase5_2018_A18.tif<br clear="none">
I:\v3_us_3dep\asheville\ashevilleUSGS_1M_17_x34y392_NC_Phase5_2018_A18.tif.aux.xml<br clear="none">
Size is 10012, 10012<br clear="none">
Coordinate System is:<br clear="none">
PROJCRS["NAD83 / UTM zone 17N",<br clear="none">
BASEGEOGCRS["NAD83",<br clear="none">
DATUM["North American Datum 1983",<br clear="none">
ELLIPSOID["GRS
1980",6378137,298.257222101,<br clear="none">
LENGTHUNIT["metre",1]]],<br clear="none">
PRIMEM["Greenwich",0,<br clear="none">
ANGLEUNIT["degree",0.0174532925199433]],<br clear="none">
ID["EPSG",4269]],<br clear="none">
CONVERSION["UTM zone 17N",<br clear="none">
METHOD["Transverse Mercator",<br clear="none">
ID["EPSG",9807]],<br clear="none">
PARAMETER["Latitude of natural
origin",0,<br clear="none">
ANGLEUNIT["degree",0.0174532925199433],<br clear="none">
ID["EPSG",8801]],<br clear="none">
PARAMETER["Longitude of natural
origin",-81,<br clear="none">
ANGLEUNIT["degree",0.0174532925199433],<br clear="none">
ID["EPSG",8802]],<br clear="none">
PARAMETER["Scale factor at natural
origin",0.9996,<br clear="none">
SCALEUNIT["unity",1],<br clear="none">
ID["EPSG",8805]],<br clear="none">
PARAMETER["False easting",500000,<br clear="none">
LENGTHUNIT["metre",1],<br clear="none">
ID["EPSG",8806]],<br clear="none">
PARAMETER["False northing",0,<br clear="none">
LENGTHUNIT["metre",1],<br clear="none">
ID["EPSG",8807]]],<br clear="none">
CS[Cartesian,2],<br clear="none">
AXIS["(E)",east,<br clear="none">
ORDER[1],<br clear="none">
LENGTHUNIT["metre",1]],<br clear="none">
AXIS["(N)",north,<br clear="none">
ORDER[2],<br clear="none">
LENGTHUNIT["metre",1]],<br clear="none">
USAGE[<br clear="none">
SCOPE["Engineering survey, topographic
mapping."],<br clear="none">
AREA["North America - between 84°W and
78°W - onshore and offshore. Canada - Nunavut;
Ontario; Quebec. United States (USA) -
Florida; Georgia; Kentucky; Maryland;
Michigan; New York; North Carolina; Ohio;
Pennsylvania; South Carolina; Tennessee;
Virginia; West Virginia."],<br clear="none">
BBOX[23.81,-84,84,-78]],<br clear="none">
ID["EPSG",26917]]<br clear="none">
Data axis to CRS axis mapping: 1,2<br clear="none">
Origin =
(339993.999958705157042,3920005.999981591943651)<br clear="none">
Pixel Size =
(1.000000000000000,-1.000000000000000)<br clear="none">
Metadata:<br clear="none">
AREA_OR_POINT=Area<br clear="none">
Image Structure Metadata:<br clear="none">
COMPRESSION=LZW<br clear="none">
INTERLEAVE=BAND<br clear="none">
LAYOUT=COG<br clear="none">
PREDICTOR=3<br clear="none">
Corner Coordinates:<br clear="none">
Upper Left ( 339994.000, 3920006.000) (
82d45'43.98"W, 35d24'38.21"N)<br clear="none">
Lower Left ( 339994.000, 3909994.000) (
82d45'36.92"W, 35d19'13.36"N)<br clear="none">
Upper Right ( 350006.000, 3920006.000) (
82d39' 7.17"W, 35d24'43.82"N)<br clear="none">
Lower Right ( 350006.000, 3909994.000) (
82d39' 0.55"W, 35d19'18.95"N)<br clear="none">
Center ( 345000.000, 3915000.000) (
82d42'22.15"W, 35d21'58.63"N)<br clear="none">
Band 1 Block=512x512 Type=Float32,
ColorInterp=Gray<br clear="none">
Min=669.509 Max=1604.949 <br clear="none">
Minimum=669.509, Maximum=1604.949,
Mean=988.295, StdDev=159.804<br clear="none">
NoData Value=-999999<br clear="none">
Overviews: 5006x5006, 2503x2503, 1251x1251,
625x625, 312x312<br clear="none">
<b>Unit Type: US survey foot</b><br clear="none">
Metadata:<br clear="none">
STATISTICS_APPROXIMATE=YES<br clear="none">
STATISTICS_MAXIMUM=1604.9490966797<br clear="none">
STATISTICS_MEAN=988.29463693706<br clear="none">
STATISTICS_MINIMUM=669.50915527344<br clear="none">
STATISTICS_STDDEV=159.80361228109<br clear="none">
STATISTICS_VALID_PERCENT=100</div>
</div>
</div>
<div dir="ltr"><br clear="none">
</div>
</div>
<br clear="none">
<fieldset></fieldset>
<pre>_______________________________________________
gdal-dev mailing list
<a shape="rect" href="mailto:gdal-dev@lists.osgeo.org" rel="noreferrer noopener" target="_blank">gdal-dev@lists.osgeo.org</a>
<a shape="rect" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer noopener" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre>--
<a shape="rect" href="http://www.spatialys.com" rel="noreferrer noopener" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
<div id="m_-7689708504940424091ydpe49ee55fyiv1570019766yqtfd38907"> </div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<pre cols="72">--
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>