<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=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Plain Text Char";
margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.PlainTextChar
{mso-style-name:"Plain Text Char";
mso-style-priority:99;
mso-style-link:"Plain Text";
font-family:"Calibri",sans-serif;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@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="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoPlainText">I went with calling ogr2ogr through os.system, but another issue I have been having with the ogr2ogr is that my polygons are not converted to what I guess is considered in AutoCAD as hatches since that is the layer that is shown for
those polygons when I open the DXF. I just get line features. It basically creates a line feature out of the polygon, that is it converts the triangle to a bisecting line. I even specify the
<b>polygon</b> in the command line options as opposed to <b>linestring</b> as well as tried just the
<b>geometry</b> parameter you suggested and writing to a geopackage<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">DXF shown in DWG TrueView 2023 <o:p></o:p></p>
<p class="MsoNormal"><a href="https://pasteboard.co/dit2y9zmJ5YT.png">https://pasteboard.co/dit2y9zmJ5YT.png</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">DXF Converted by QGIS tool Import Layers from DWG/DXF<o:p></o:p></p>
<p class="MsoNormal"><a href="https://pasteboard.co/4XZwHus6NhAj.png">https://pasteboard.co/4XZwHus6NhAj.png</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoPlainText">DXF Converted to Geopackage.<o:p></o:p></p>
<p class="MsoNormal"><a href="https://pasteboard.co/1wIMI9xRymkZ.png">https://pasteboard.co/1wIMI9xRymkZ.png</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<br>
From: Rahkonen Jukka <<a href="mailto:jukka.rahkonen@maanmittauslaitos.fi">jukka.rahkonen@maanmittauslaitos.fi</a>>
<br>
Sent: Wednesday, October 11, 2023 2:12 AM<br>
To: Catania, Luke A ERDC-RDE-GRL-VA CIV <<a href="mailto:Luke.A.Catania@erdc.dren.mil">Luke.A.Catania@erdc.dren.mil</a>>; Scott <<a href="mailto:public@postholer.com">public@postholer.com</a>>;
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
Subject: Re: [gdal-dev] help needed with pygdaltools library, documentation sparse<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Hi,<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">The actual error seems to be that you try to write some geometry that is not a linestring into a GeoPackage table that has created with a constraint that makes it accept only linestrings. You do that by using "-nlt linestring".<o:p></o:p></p>
<p class="MsoPlainText">You have two options. The fast one is to use "-nlt geometry" that makes GeoPackage table to accept all kind of geometries. The other option is to filter the source data by geometry type and select only linestrings. Here is an example
about how to do that with the OGR SQL dialect Blockedhttps://gdal.org/user/ogr_sql_dialect.html#ogr-geometryBlocked<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Don't try to use "-nlt geometry" with shapefiles because that format does not support mixed geometrytypes.<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-Jukka Rahkonen-<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Alkuperäinen viesti-----<o:p></o:p></p>
<p class="MsoPlainText">Lähettäjä: gdal-dev <<a href="mailto:gdal-dev-bounces@lists.osgeo.org"><span style="color:windowtext;text-decoration:none">gdal-dev-bounces@lists.osgeo.org</span></a>> Puolesta Catania, Luke A ERDC-RDE-GRL-VA CIV via gdal-dev<o:p></o:p></p>
<p class="MsoPlainText">Lähetetty: keskiviikko 11. lokakuuta 2023 8.59<o:p></o:p></p>
<p class="MsoPlainText">Vastaanottaja: Scott <<a href="mailto:public@postholer.com"><span style="color:windowtext;text-decoration:none">public@postholer.com</span></a>>;
<a href="mailto:gdal-dev@lists.osgeo.org"><span style="color:windowtext;text-decoration:none">gdal-dev@lists.osgeo.org</span></a><o:p></o:p></p>
<p class="MsoPlainText">Aihe: Re: [gdal-dev] help needed with pygdaltools library, documentation sparse<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">I have not even gotten to see that anything is being ignored because I have not yet added any options. My first attempt was with adding skipfailures, but I can't add any of the options I have listed because I have no idea how to. I
thought it would be gdal_tools.config_options() but I get pylint tells me it is not callable<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-----Original Message-----<o:p></o:p></p>
<p class="MsoPlainText">From: gdal-dev <<a href="mailto:gdal-dev-bounces@lists.osgeo.org"><span style="color:windowtext;text-decoration:none">gdal-dev-bounces@lists.osgeo.org</span></a>> On Behalf Of Scott via gdal-dev<o:p></o:p></p>
<p class="MsoPlainText">Sent: Wednesday, October 11, 2023 1:45 AM<o:p></o:p></p>
<p class="MsoPlainText">To: <a href="mailto:gdal-dev@lists.osgeo.org"><span style="color:windowtext;text-decoration:none">gdal-dev@lists.osgeo.org</span></a><o:p></o:p></p>
<p class="MsoPlainText">Subject: Re: [gdal-dev] help needed with pygdaltools library, documentation sparse<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">-nln is being ignored because the data layer you're -updating -appending to exists. You can't rename a layer if it has a name. Remove -nln option<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Next you are trying to write a collection as a linestring. Use -explodecollections (if exists in your install) and/or use -nlt PROMOTE_TO_MULTI<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">Try not to use -skipfailures<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
<p class="MsoPlainText">On 10/10/23 22:26, Catania, Luke A ERDC-RDE-GRL-VA CIV via gdal-dev wrote:<o:p></o:p></p>
<p class="MsoPlainText">> I am running simple code to convert dxf to gpkg and I get the error
<o:p></o:p></p>
<p class="MsoPlainText">> below. -am an trying to figure out how to add a bunch of options ( -f
<o:p></o:p></p>
<p class="MsoPlainText">> GPKG -append -update --config DXF_ENCODING CP1252 --config
<o:p></o:p></p>
<p class="MsoPlainText">> DXF_INCLUDE_RAW_CODE_VALUES TRUE --config <o:p></o:p></p>
<p class="MsoPlainText">> DXF_TRANSLATE_ESCAPE_SEQUENCES FALSE --config <o:p></o:p></p>
<p class="MsoPlainText">> DXF_MERGE_BLOCK_GEOMETRIES FALSE --config DXF_INLINE_BLOCKS TRUE -nlt
<o:p></o:p></p>
<p class="MsoPlainText">> LINESTRING -nln 32111_F)<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> But can't even figure out how to add the recommended skipfailures flag.<o:p></o:p></p>
<p class="MsoPlainText">> I tried adding<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools.config_options("-skipfailures")<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> but I get pylint tells me it is not callable.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Anyone use pygdaltools? There is some documentation, but nothing
<o:p></o:p></p>
<p class="MsoPlainText">> showing you how to set these command line parameters.<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> import gdaltools<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools = gdaltools.ogr2ogr()<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools.BASEPATH = r"C:\Program Files\QGIS 3.16.16\bin"<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools.set_encoding("UTF-8")<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools.set_input(self.dxf_out_path)<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools.set_output(self.gpkg_out)<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools.execute()<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> And I get the ERROR:root:b"Warning 1: Layer creation options ignored<o:p></o:p></p>
<p class="MsoPlainText">> since an existing layer is\r\n being appended to.\r\nWarning 6:<o:p></o:p></p>
<p class="MsoPlainText">> Normalized/laundered field name: 'EntityHandle' to <o:p>
</o:p></p>
<p class="MsoPlainText">> 'EntityHa_2'\r\nERROR<o:p></o:p></p>
<p class="MsoPlainText">> 1: Attempt to write non-linestring (GEOMETRYCOLLECTION) geometry to
<o:p></o:p></p>
<p class="MsoPlainText">> ARC type shapefile.\r\nERROR 1: Unable to write feature 0 from layer
<o:p></o:p></p>
<p class="MsoPlainText">> entities.\r\nERROR 1: Terminating translation prematurely after
<o:p></o:p></p>
<p class="MsoPlainText">> failed\r\ntranslation of layer entities (use -skipfailures to skip
<o:p></o:p></p>
<p class="MsoPlainText">> errors)\r\n"<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> Traceback (most recent call last):<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> File<o:p></o:p></p>
<p class="MsoPlainText">> "c:\Users\RDTECLAC\AppData\Roaming\QGIS\QGIS3\profiles\default\python\<o:p></o:p></p>
<p class="MsoPlainText">> plugins\site_selection\tools\master_planning\load_mp_designs.py", line
<o:p></o:p></p>
<p class="MsoPlainText">> 227, in <module><o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> main()<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> File<o:p></o:p></p>
<p class="MsoPlainText">> "c:\Users\RDTECLAC\AppData\Roaming\QGIS\QGIS3\profiles\default\python\<o:p></o:p></p>
<p class="MsoPlainText">> plugins\site_selection\tools\master_planning\load_mp_designs.py", line
<o:p></o:p></p>
<p class="MsoPlainText">> 196, in main<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> mp_designs.gdal_convert()<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> File<o:p></o:p></p>
<p class="MsoPlainText">> "c:\Users\RDTECLAC\AppData\Roaming\QGIS\QGIS3\profiles\default\python\<o:p></o:p></p>
<p class="MsoPlainText">> plugins\site_selection\tools\master_planning\load_mp_designs.py", line
<o:p></o:p></p>
<p class="MsoPlainText">> 185, in gdal_convert<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdal_tools.execute()<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> File<o:p></o:p></p>
<p class="MsoPlainText">> "C:\Users\RDTECLAC\AppData\Roaming\Python\Python39\site-packages\gdalt<o:p></o:p></p>
<p class="MsoPlainText">> ools\ogr2ogrcmd.py", line 330, in execute<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> return self._do_execute(args)<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> File<o:p></o:p></p>
<p class="MsoPlainText">> "C:\Users\RDTECLAC\AppData\Roaming\Python\Python39\site-packages\gdalt<o:p></o:p></p>
<p class="MsoPlainText">> ools\basetypes.py", line 108, in _do_execute<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> raise GdalToolsError(rc, err)<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> gdaltools.basetypes.GdalToolsError: (1, b"Warning 1: Layer creation<o:p></o:p></p>
<p class="MsoPlainText">> options ignored since an existing layer is\r\n being appended<o:p></o:p></p>
<p class="MsoPlainText">> to.\r\nWarning 6: Normalized/laundered field name: 'EntityHandle' to
<o:p></o:p></p>
<p class="MsoPlainText">> 'EntityHa_2'\r\nERROR 1: Attempt to write non-linestring<o:p></o:p></p>
<p class="MsoPlainText">> (GEOMETRYCOLLECTION) geometry to ARC type shapefile.\r\nERROR 1:<o:p></o:p></p>
<p class="MsoPlainText">> Unable to write feature 0 from layer entities.\r\nERROR 1: Terminating
<o:p></o:p></p>
<p class="MsoPlainText">> translation prematurely after failed\r\ntranslation of layer entities
<o:p></o:p></p>
<p class="MsoPlainText">> (use -skipfailures to skip errors)\r\n")error:<o:p></o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">><o:p> </o:p></p>
<p class="MsoPlainText">> _______________________________________________<o:p></o:p></p>
<p class="MsoPlainText">> gdal-dev mailing list<o:p></o:p></p>
<p class="MsoPlainText">> <a href="mailto:gdal-dev@lists.osgeo.org"><span style="color:windowtext;text-decoration:none">gdal-dev@lists.osgeo.org</span></a><o:p></o:p></p>
<p class="MsoPlainText">> Blockedhttps://eur06.safelinks.protection.outlook.com/?url=https%3A%2F<o:p></o:p></p>
<p class="MsoPlainText">> %2Flists.osgeo.org%2Fmailman%2Flistinfo%2Fgdal-devBlocked&data=05%7C01<o:p></o:p></p>
<p class="MsoPlainText">> %7Cjukka.rahkonen%40maanmittauslaitos.fi%7C476e640a44f14b283ee008dbca1<o:p></o:p></p>
<p class="MsoPlainText">> f38eb%7Cc4f8a63255804a1c92371d5a571b71fa%7C0%7C0%7C638326007673488940%<o:p></o:p></p>
<p class="MsoPlainText">> 7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik<o:p></o:p></p>
<p class="MsoPlainText">> 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=n2JmJTKxfldyTjy08p5bXOtMxMn<o:p></o:p></p>
<p class="MsoPlainText">> Zw7iy2EwIYpfMnc4%3D&reserved=0<o:p></o:p></p>
<p class="MsoPlainText">_______________________________________________<o:p></o:p></p>
<p class="MsoPlainText">gdal-dev mailing list<o:p></o:p></p>
<p class="MsoPlainText"><a href="mailto:gdal-dev@lists.osgeo.org"><span style="color:windowtext;text-decoration:none">gdal-dev@lists.osgeo.org</span></a><o:p></o:p></p>
<p class="MsoPlainText">Blockedhttps://lists.osgeo.org/mailman/listinfo/gdal-devBlocked<o:p></o:p></p>
<p class="MsoPlainText">_______________________________________________<o:p></o:p></p>
<p class="MsoPlainText">gdal-dev mailing list<o:p></o:p></p>
<p class="MsoPlainText"><a href="mailto:gdal-dev@lists.osgeo.org"><span style="color:windowtext;text-decoration:none">gdal-dev@lists.osgeo.org</span></a><o:p></o:p></p>
<p class="MsoPlainText">Blockedhttps://lists.osgeo.org/mailman/listinfo/gdal-devBlocked<o:p></o:p></p>
<p class="MsoPlainText"><o:p> </o:p></p>
</div>
</body>
</html>