From sim at gis-lab.info Sat Sep 6 18:22:38 2008 From: sim at gis-lab.info (Maxim Dubinin) Date: Sat, 6 Sep 2008 17:22:38 -0500 Subject: [Osmlib-user] Skipping unclosed polygons Message-ID: <1113163247.20080906172238@gis-lab.info> Hi I'm trying to figure out what is wrong with my OSM->shapefile (polygons) processing using OSMLib. Here is my rule-file: setup :Shp do polygon :waterway_a do name 'waterway_a' string :Boat, 4 string :Int_name, 20 string :Name, 20 string :Natural, 20 end end ways do if waterway :waterway_a << {:Name => name, :Int_name => int_name, :Boat => boat} end end The error message is the following: > /usr/local/lib/ruby/gems/1.8/gems/osmlib-base-0.1.3/lib/OSM/objects.rb:493:in > `polygon': way is not closed so it can't be represented as Polygon (OSM::NotClosedError) As I understood, OSM XML doesn't have explicit definition for polygon rather then just closed polyline. But even if one of my waterways is not closed, process stops and shapefile has 0 records. May be it is wiser to just skip the object which is not closed? I can provide example of osm-file if this would help. Thanks. Maxim From jochen at remote.org Sun Sep 7 12:45:38 2008 From: jochen at remote.org (Jochen Topf) Date: Sun, 7 Sep 2008 18:45:38 +0200 Subject: [Osmlib-user] Skipping unclosed polygons In-Reply-To: <1113163247.20080906172238@gis-lab.info> References: <1113163247.20080906172238@gis-lab.info> Message-ID: <20080907164537.GA32685@eldorado.topf.org> On Sat, Sep 06, 2008 at 05:22:38PM -0500, Maxim Dubinin wrote: > I'm trying to figure out what is wrong with my OSM->shapefile > (polygons) processing using OSMLib. Here is my rule-file: > > setup :Shp do > polygon :waterway_a do > name 'waterway_a' > string :Boat, 4 > string :Int_name, 20 > string :Name, 20 > string :Natural, 20 > end > end > > ways do > if waterway > :waterway_a << {:Name => name, :Int_name => int_name, :Boat => boat} > end > end > > > The error message is the following: > > > /usr/local/lib/ruby/gems/1.8/gems/osmlib-base-0.1.3/lib/OSM/objects.rb:493:in > > `polygon': way is not closed so it can't be represented as Polygon (OSM::NotClosedError) > > As I understood, OSM XML doesn't have explicit definition for polygon > rather then just closed polyline. But even if one of my waterways is not > closed, process stops and shapefile has 0 records. May be it is wiser to > just skip the object which is not closed? > > I can provide example of osm-file if this would help. Thanks. Generally waterway=* is a line feature. So you shouldn't expect it to contain polygons. Use natural=water for lakes. That beeing said, try the following: In OSM/Export/Shp.rb change the line rescue OSM::GeometryError into rescue OSM::GeometryError, OSM::NotClosedError That should ignore this error. Jochen -- Jochen Topf jochen at remote.org http://www.remote.org/jochen/ +49-721-388298