<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--></head><body><div class="ydp593cabfdyahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div></div>
<div dir="ltr" data-setdir="false">Thanks Even,</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">looks like a good workaround for the moment. Hopefully, the USGS will update their files accordingly.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">Thanks Kirk for kicking this up. I'm sure it is not trivial to fix such an issue for a national dataset.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">Have a great day,</div><div dir="ltr" data-setdir="false">Conrad<br></div><div><br></div>
</div><div id="ydp83a0977yahoo_quoted_1902555362" class="ydp83a0977yahoo_quoted">
<div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
<div>
On Friday, March 22, 2024 at 04:57:03 AM EDT, Even Rouault <even.rouault@spatialys.com> wrote:
</div>
<div><br></div>
<div><br></div>
<div><div id="ydp83a0977yiv0394925143"><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 clear="none">
</p>
<p>from osgeo import gdal<br clear="none">
ds = gdal.Open('test.tif')<br clear="none">
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 clear="none">
</p>
<p>ds = gdal.OpenEx('test.tif',
open_options=['IGNORE_COG_LAYOUT_BREAK=YES'])<br clear="none">
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 clear="none">
</p>
<p>Regarding how that is used by gdalwarp, the doc enhancement at
<a shape="rect" href="https://github.com/OSGeo/gdal/pull/9527" class="ydp83a0977yiv0394925143moz-txt-link-freetext" target="_blank" rel="noreferrer noopener">https://github.com/OSGeo/gdal/pull/9527</a> captures my initial
attempt at answering your questions.</p>
<p><span class="ydp83a0977yiv0394925143highlighted"></span></p>
<p><span class="ydp83a0977yiv0394925143highlighted">Even</span></p>
<p><span class="ydp83a0977yiv0394925143highlighted"><br clear="none">
</span></p>
<div class="ydp83a0977yiv0394925143moz-cite-prefix">Le 22/03/2024 à 01:16, Conrad Bielski 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;" class="ydp83a0977yiv0394925143ydp40a02c5yahoo-style-wrap">
<div dir="ltr">Just realised I should have
put you also in CC</div>
<div dir="ltr"><br clear="none">
</div>
<div dir="ltr">Here is my response message
again.</div>
<div dir="ltr"><br clear="none">
</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" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091enhancr_card_1237347669" target="_blank" rel="noreferrer noopener">bad_geotiff - Google Drive</a></div>
<div><br clear="none">
</div>
<div id="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10enhancr_card_1237347669" style="max-width:400px;font-family:YahooSans VF, YahooSans, OpenSans VF, Helvetica Neue, Segoe UI, Helvetica, Arial, sans-serif;position:relative;" data-url="https://drive.google.com/drive/folders/1LVJqoKrnLRf6_5FpE7a5SrUGIWBPQmqa?usp=sharing" data-type="YENHANCER" data-size="MEDIUM" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10yahoo-link-enhancr-card ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10yahoo-link-enhancr-not-allow-cover ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10ymail-preserve-class ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10ymail-preserve-style"><a shape="rect" href="https://drive.google.com/drive/folders/1LVJqoKrnLRf6_5FpE7a5SrUGIWBPQmqa?usp=sharing" style="text-decoration-line:none !important;text-decoration-style:solid !important;text-decoration-color:currentcolor !important;color:rgb(0, 0, 0) !important;" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10yahoo-enhancr-cardlink" target="_blank" rel="noreferrer noopener">
<table style="max-width:400px;" cellspacing="0" cellpadding="0" border="0" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10card-wrapper ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10yahoo-ignore-table"><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" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10card ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10yahoo-ignore-table"><tbody><tr><td colspan="1" rowspan="1">
<table style="background-color:rgb(255, 255, 255);background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;position:relative;z-index:2;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" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10card-info ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10yahoo-ignore-table"><tbody><tr><td colspan="1" rowspan="1" style="background-color:#ffffff;padding:16px 0 16px 12px;vertical-align:top;border-radius:0 0 0 2px;"><img src="https://s.yimg.com/lb/brands/80x80_google.png" style="min-width:36px;margin-top:3px;" height="36" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10card-object-1 ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10yahoo-ignore-inline-image ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10ymail-preserve-class"></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:0 0 2px 0;">
<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;" class="ydp83a0977yiv0394925143ydpbd5ef252yiv1599055091ydpf608df10card-title">bad_geotiff -
Google Drive</h2>
</td></tr></tbody></table>
</td></tr></tbody></table>
</td></tr></tbody></table>
</a>
<div style="width:100%;z-index:3;min-height:0px;" class="ydp83a0977yiv0394925143ydpbd5ef252card-controls-injection-wrapper">
<div class="ydp83a0977yiv0394925143ydpbd5ef252p_a ydp83a0977yiv0394925143ydpbd5ef252T_6Fd5 ydp83a0977yiv0394925143ydpbd5ef252R_6Fd5">
<div style="z-index:3;" class="ydp83a0977yiv0394925143ydpbd5ef252I_ak5mD ydp83a0977yiv0394925143ydpbd5ef252e_dRA ydp83a0977yiv0394925143ydpbd5ef252j_2kgqsw ydp83a0977yiv0394925143ydpbd5ef252P_wpoVE"><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 clear="none">
</div>
<div><br clear="none">
</div>
</div>
<div id="ydp83a0977yiv0394925143ydpe49ee55fyahoo_quoted_1291212430" class="ydp83a0977yiv0394925143ydpe49ee55fyahoo_quoted">
<div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
<div> On Thursday, March 21, 2024 at 04:49:57 PM EDT, Even
Rouault <a shape="rect" href="mailto:even.rouault@spatialys.com" class="ydp83a0977yiv0394925143moz-txt-link-rfc2396E" target="_blank" rel="noreferrer noopener"><even.rouault@spatialys.com></a> wrote: </div>
<div><br clear="none">
</div>
<div><br clear="none">
</div>
<div>
<div id="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766">
<div>
<p><br clear="none">
</p>
<div class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766moz-cite-prefix">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;" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yahoo-style-wrap">
<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="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqtfd56535" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqt2404944011"><br clear="none">
</div>
<div id="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqtfd92313" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqt2404944011"> </div>
<blockquote type="cite">
<div id="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqtfd44669" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqt2404944011"> </div>
<div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yahoo-style-wrap">
<div id="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqtfd29015" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqt2404944011">
<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="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqtfd71024" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqt2404944011">
<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 class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766moz-mime-attachment-header"></fieldset>
<pre class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766moz-quote-pre">_______________________________________________
gdal-dev mailing list
<a shape="rect" href="mailto:gdal-dev@lists.osgeo.org" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766moz-txt-link-abbreviated ydp83a0977yiv0394925143moz-txt-link-freetext" target="_blank" rel="noreferrer noopener">gdal-dev@lists.osgeo.org</a>
<a shape="rect" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766moz-txt-link-freetext ydp83a0977yiv0394925143moz-txt-link-freetext" target="_blank" rel="noreferrer noopener">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766moz-signature">--
<a shape="rect" href="http://www.spatialys.com" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766moz-txt-link-freetext ydp83a0977yiv0394925143moz-txt-link-freetext" target="_blank" rel="noreferrer noopener">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
<div id="ydp83a0977yiv0394925143yqtfd71031" class="ydp83a0977yiv0394925143yqt6933704702"><div id="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqtfd38907" class="ydp83a0977yiv0394925143ydpe49ee55fyiv1570019766yqt2404944011"> </div>
</div></div><div id="ydp83a0977yiv0394925143yqtfd30794" class="ydp83a0977yiv0394925143yqt6933704702">
</div></div><div id="ydp83a0977yiv0394925143yqtfd41919" class="ydp83a0977yiv0394925143yqt6933704702">
</div></div><div id="ydp83a0977yiv0394925143yqtfd52504" class="ydp83a0977yiv0394925143yqt6933704702">
</div></div><div id="ydp83a0977yiv0394925143yqtfd66675" class="ydp83a0977yiv0394925143yqt6933704702">
</div></div><div id="ydp83a0977yiv0394925143yqtfd43574" class="ydp83a0977yiv0394925143yqt6933704702">
<pre class="ydp83a0977yiv0394925143moz-signature">--
<a shape="rect" href="http://www.spatialys.com" class="ydp83a0977yiv0394925143moz-txt-link-freetext" target="_blank" rel="noreferrer noopener">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div></div></div></div>
</div>
</div></body></html>