[GIS] Convert GML to DXF using ogr2ogr

gdalogr2ogr

I cannot make ogr2ogr.exe work. I'm using GDAL 1.11.

I keep getting the following error message:

ERROR 1: Did not get at least 2 values or invalid number of set of
coordinates 709993.98 6181946.65 32.36 709990.65
6181946.07
32.36 709992.47 6181935.8 32.36 709995.78 6181936.38 32.36 709993.98 6181946.65
32.36 ERROR 1: Invalid exterior ring

I run the following command:

C:\Python34\Lib\site-packages\osgeo\ogr2ogr.exe -skipfailures -nlt
MULTILINESTRING25D -dim 3 -f "DXF" -a_srs "EPSG:25832" -spat 711000
6168300 713000 6168600 -geomfield posList bygning.DXF Bygning.gml

I'm working on a relatively big file 4.2GB.

UPDATE: Example of data to import

<gml:surfaceProperty>
    <gml:Surface srsName="EPSG:25832" srsDimension="3">
        <gml:patches>
            <gml:PolygonPatch>
                <gml:exterior>
                    <gml:LinearRing>
                        <gml:posList>
                            710820.22 6180637.52 36 710818.14 6180633.83 36 710825.47 6180629.71 36 710827.55 6180633.4 38.25 710828.6 6180637.3 38.25 710825.18 6180638.36 38.25 710824.22 6180635.27 36 710820.22 6180637.52 36
                        </gml:posList>
                    </gml:LinearRing>
                </gml:exterior>
            </gml:PolygonPatch>
        </gml:patches>
    </gml:Surface>
</gml:surfaceProperty>

Does the GML3 driver in org2ogr support surfaces?

UPDATE 2 – making it simple

I tried making a gml consisting of only one feature, same namespace etc. as before. I then output the feature to WKT.

Output WKT

"POLYGON ((711383.39 6182528.23,36.49 711379.31,6182528.35
36.48,711379.06 6182520.08,36.48 711383.15,6182519.97 36.48,711383.37 6182527.56,36.49 711383.39,6182528.23 36.49))"

Input GML
http://pastebin.com/76AGLWH0

Cleary the commas is placed in the wrong positions. The z-coordinate of the first point is parsed as the x-coordinate of the second feature. If I add -dim 3 or -nlt GEOMETRY, it adds zeroes.

BR
Thomas

Best Answer

The problem is caused by GDAL which seems to require that 3-dimensional coordinates are specified in GML at position level as

<gml:posList srsDimension="3">

In the data dimensions are expressed only at geometry level

 <gml:Surface srsName="EPSG:25832" srsDimension="3">

This may be a bug or missing feature in GDAL and corresponding GDAL ticket http://trac.osgeo.org/gdal/ticket/5606 will show the resolution. First aid for making the data readable for GDAL is to add srsDimensions attribute to occasions of "posList" with a text editor.

<gml:posList>  =>  <gml:posList srsDimension="3">