<div dir="ltr"><div dir="ltr"><div><span style="background-color:rgb(255,255,255)"><b><font color="#0000ff" style="">I tried to extract data from </font><span style="color:rgb(0,0,255)">.osm.pbf file and write to shapefile as follows:</span></b></span></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">import os, osmium, fiona</font></div><div><span style="background-color:rgb(217,234,211);color:rgb(0,0,255)"><br></span></div><div><span style="background-color:rgb(217,234,211);color:rgb(0,0,255)">fi = 'europe-latest.osm.pbf'</span><br></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">fo = 'europe-latest.shp' </font><span style="background-color:rgb(217,234,211);color:rgb(0,0,255)">   </span></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">drv = 'ESRI Shapefile'</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">crs = {'no_defs': True, 'ellps': 'WGS84', 'datum': 'WGS84', 'proj': 'longlat'}</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"> schema = {'geometry': 'LineString',</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">                   'properties': {'id': 'float', 'name' : 'str', 'kind' : 'str'}}</font><span style="background-color:rgb(217,234,211);color:rgb(0,0,255)">    </span></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"> </font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">outfile = fiona.open(fo, 'w', driver=drv, crs=crs, schema=schema)</font><span style="background-color:rgb(217,234,211);color:rgb(0,0,255)">    </span></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"> </font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">geomfab = osmium.geom.GeoJSONFactory()</font><span style="background-color:rgb(217,234,211);color:rgb(0,0,255)">    </span></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"> </font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">class ShapeConverter(osmium.SimpleHandler):</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">      def way(self, w):</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">           if 'place' in w.tags: </font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">               rec = {'geometry' : eval(geomfab.create_linestring(w)),</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">                      'properties' : {'id' : float(<a href="http://w.id">w.id</a>),</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">                                     'name' : w.tags.get('name'),</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">                                       'kind' : w.tags['place']}}   </font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">               outfile.write(rec)</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"> </font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">ShapeConverter().apply_file(fi, locations=True)</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)">I got the following error after extracting several contents:</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)"> rec = {'geometry' : eval(geomfab.create_linestring(w)),</font></div><div><font color="#0000ff" style="background-color:rgb(217,234,211)">RuntimeError: need at least two points for linestring (way_id=619453148)</font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)">How could I skip that erroneous id and extract data for other working ids?</font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)">Your help is appreciated.</font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)">Thank you so much.</font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)"><br></font></div><div><font color="#0000ff" style="background-color:rgb(255,255,255)">Koji</font></div></div></div>