<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thank you Even for your help.</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Even Rouault <even.rouault@spatialys.com><br>
<b>Sent:</b> August 24, 2021 3:28 PM<br>
<b>To:</b> ni hao <ni_hao88@hotmail.com>; gdal-dev@lists.osgeo.org <gdal-dev@lists.osgeo.org><br>
<b>Subject:</b> Re: [gdal-dev] NITF DES</font>
<div> </div>
</div>
<div>
<p style="margin-top: 0px; margin-bottom: 0px;"><br>
</p>
<div class="x_moz-cite-prefix">Le 24/08/2021 à 20:07, ni hao a écrit :<br>
</div>
<blockquote type="cite">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Hi <span style="">Even,</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style=""><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="">Thank you for your reply.</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="">Is there a simpler example to remove DES (say DES ID = 1) from an existing NITF, or replace DES with a null string?</span></div>
</blockquote>
No, there's no code to update/remove a DES . You'll need to edit the file at byte level, or rewrite a new one without them<br>
<blockquote type="cite">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style=""><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style=""><br>
</span></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Even Rouault
<a class="x_moz-txt-link-rfc2396E" href="mailto:even.rouault@spatialys.com"><even.rouault@spatialys.com></a><br>
<b>Sent:</b> August 24, 2021 1:50 PM<br>
<b>To:</b> ni hao <a class="x_moz-txt-link-rfc2396E" href="mailto:ni_hao88@hotmail.com">
<ni_hao88@hotmail.com></a>; <a class="x_moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">
gdal-dev@lists.osgeo.org</a> <a class="x_moz-txt-link-rfc2396E" href="mailto:gdal-dev@lists.osgeo.org">
<gdal-dev@lists.osgeo.org></a><br>
<b>Subject:</b> Re: [gdal-dev] NITF DES</font>
<div> </div>
</div>
<div>
<p style="margin-top: 0px; margin-bottom: 0px;">Hello,</p>
<p style="margin-top: 0px; margin-bottom: 0px;">yes, first look:</p>
<p style="margin-top: 0px; margin-bottom: 0px;">- at the doc of the DES creation option in
<a class="x_x_moz-txt-link-freetext" href="https://gdal.org/drivers/raster/nitf.html#creation-issues">
https://gdal.org/drivers/raster/nitf.html#creation-issues</a></p>
<p style="margin-top: 0px; margin-bottom: 0px;">- at <a class="x_x_moz-txt-link-freetext" href="https://gdal.org/drivers/raster/nitf_advanced.html#data-extension-segments-xml-des">
https://gdal.org/drivers/raster/nitf_advanced.html#data-extension-segments-xml-des</a></p>
<p style="margin-top: 0px; margin-bottom: 0px;">you will need to compose the DES segment in a relatively low level.</p>
<p style="margin-top: 0px; margin-bottom: 0px;">Look at examples in :</p>
<p style="margin-top: 0px; margin-bottom: 0px;">- <a class="x_x_moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/de6a6b44302be5c6a294d86f6ca35ebcdce563ff/autotest/gdrivers/nitf.py#L3728">
https://github.com/OSGeo/gdal/blob/de6a6b44302be5c6a294d86f6ca35ebcdce563ff/autotest/gdrivers/nitf.py#L3728</a></p>
<p style="margin-top: 0px; margin-bottom: 0px;">- <a class="x_x_moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/de6a6b44302be5c6a294d86f6ca35ebcdce563ff/autotest/gdrivers/nitf.py#L3795">
https://github.com/OSGeo/gdal/blob/de6a6b44302be5c6a294d86f6ca35ebcdce563ff/autotest/gdrivers/nitf.py#L3795</a><br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px;">Note: <span class="x_x_pl-s1">gdal</span>.<span class="x_x_pl-v"><span class="x_x_pl-token">EscapeString</span></span>(<span class="x_x_pl-s1">des_data</span>,
<span class="x_x_pl-s1">gdal</span>.<span class="x_x_pl-v">CPLES_BackslashQuotable</span>) with binary data only works since a commit done yesterday in GDAL master!</p>
<p style="margin-top: 0px; margin-bottom: 0px;">If using an older version, backslash escaping can be done with :</p>
<pre>escaped_data = data.replace(b'\\', b'\\\\').replace(b'\0', b'\\0') \
                   .replace(b'\"', b'\\"').replace(b'\n', b'\\n')</pre>
<p style="margin-top: 0px; margin-bottom: 0px;">Best regards,<br>
</p>
<p style="margin-top: 0px; margin-bottom: 0px;">Even<br>
</p>
<div class="x_x_moz-cite-prefix">Le 24/08/2021 à 18:45, ni hao a écrit :<br>
</div>
<blockquote type="cite">
<div>Hi List,</div>
<div><br>
</div>
<div>Is there a GDAL utility or Python code to delete/alter/write to NITF Data Extension Segments (DES) ?<span></span></div>
<div><br>
</div>
<div>Thanks.</div>
<br>
<fieldset class="x_x_mimeAttachmentHeader"></fieldset>
<pre class="x_x_moz-quote-pre">_______________________________________________
gdal-dev mailing list
<a class="x_x_moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="x_x_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="x_x_moz-signature" cols="72">-- 
<a class="x_x_moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
</blockquote>
<pre class="x_moz-signature" cols="72">-- 
<a class="x_moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
</body>
</html>