<html><body><div id="zimbraEditorContainer" style="font-family: garamond,new york,times,serif; font-size: 12pt; color: #000000" class="2"><div>Hi,</div><div><br data-mce-bogus="1"></div><div>As far as I understood, shapefile is not able to handle several geometry types and you should produce a shapefile for each one. Shape file does not support geometry collections.</div><div><br data-mce-bogus="1"></div><div>HTH</div><div>Hug</div><div><br></div><div data-marker="__SIG_PRE__"><br><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>De: </b>"Kristijan Cindrić" <kcindric@gmail.com><br><b>À: </b>gdal-dev@lists.osgeo.org<br><b>Envoyé: </b>Vendredi 29 Novembre 2019 08:58:11<br><b>Objet: </b>[gdal-dev] geojson to shp and vice versa<br></div><div><br></div><div data-marker="__QUOTED_TEXT__"><div dir="ltr">
<div>Dear all,</div><br><div>
<p>I have a headache inducing problem. Whenever I try to convert a GeoJSON feature collection which contains
 multiple different geometry shapes (i.e. polygon, linestring and point)
 I get this type of error:</p>
<blockquote>
<p>"ERROR 1: Attempt to write non-polygon (LINESTRING) geometry to 
POLYGON type shapefile.\nERROR 1: Unable to write feature 1 from layer 
OGRGeoJSON.\nERROR 1: Terminating translation prematurely after 
failed\ntranslation of layer OGRGeoJSON (use -skipfailures to skip 
errors)\n"</p>
</blockquote>
<p>This is the sample GeoJSON I'm trying to convert:</p>
<p><code></code><font size="2"><span style="font-family:times new roman,serif">{<br>    "type": "FeatureCollection",<br>    "features": [{<br>        "type": "Feature",<br>        "properties": {},<br>        "geometry": {<br>            "type": "Polygon",<br>            "coordinates": [<br>                [<br>                    [31.816406250000004, 55.27911529201564],<br>                    [34.27734375000001, 51.944264879028765],<br>                    [43.94531250000001, 51.944264879028765],<br>                    [46.93359375000001, 58.35563036280967],<br>                    [40.42968750000001, 60.1524422143808],<br>                    [34.45312500000001, 59.085738569819505],<br>                    [31.816406250000004, 55.27911529201564]<br>                ]<br>            ]<br>        }<br>    }, {<br>        "type": "Feature",<br>        "properties": {},<br>        "geometry": {<br>            "type": "LineString",<br>            "coordinates": [<br>                [0.5273437500000001, 21.289374355860424],<br>                [30.585937500000004, 20.632784250388028]<br>            ]<br>        }<br>    }, {<br>        "type": "Feature",<br>        "properties": {},<br>        "geometry": {<br>            "type": "Point",<br>            "coordinates": [14.062500000000002, 50.064191736659104]<br>        }<br>    }]<br>}</span></font></p><p><br></p>
<p>I validated the GeoJSON on <a href="http://geojsonlint.com/" rel="nofollow" target="_blank">geojsonlint</a> and it's all good. It happens every time I have a stack of different geometry types. It happens using <a href="http://ogre.adc4gis.com" target="_blank">ogre.adc4gis.com</a>
 or ogr2ogr. It happens in the opposite way also and when I use the 
skipfailure option I just get the first feature in my shapefile.</p><p>Any ideas what's going on?<br></p><p><br></p><p>Thanks!</p><p><br></p><p>Chris</p></div>

</div>
<br>_______________________________________________<br>gdal-dev mailing list<br>gdal-dev@lists.osgeo.org<br>https://lists.osgeo.org/mailman/listinfo/gdal-dev<br></div></div></body></html>