# Filtering out polygons that consists of less than 3 nodes

I have OSM data stored in PostGIS.

After running the following query:

``````select st_astext(st_forcepolygonccw(st_transform(geom,32633))), st_geometrytype(geom) from osm_versions.polygon_v1
limit 10
``````

I get this result.

As you may see only 2 out of 10 spatial objects consist of more than 1 node yet all of them have GeometryType ST_Polygon. As a polygon is "a plane figure that is described by a finite number of straight line segments connected to form a closed polygonal chain" (after Wikipedia) I have no use for "polygons" with less than 3 nodes.

My questions are: Is there any command that returns, given a set of geometries, a subset of geometries that consists of more than 2 nodes? How should I proceed in order to filter out "polygons" with less than 3 nodes?

As for the question how come that points are counted as polygons, I have no idea as the data were provided by an external source.

• Your premise is flawed. A polygon geometry is defined by four vertices (the last must be identical to the first). Apr 17, 2020 at 13:06
• I know, yet I have "polygons" with 1 node. And I got a problem. If my question are badly formulated, then please, do feel free to reformulate them and edit my post. As for the "3 nodes" I forgot about the "closing node", but it should have no practical consequences as points consists of 1 node, lines of 2 and polygons, as you said, of al least 4, thus 4 is the only number in this context that islarger than 3. Apr 17, 2020 at 13:11
• Select the ones having ST_IsValid='true'. OSM has also invalid polygons which have enough vertices but no area because the vertices are along a line. Apr 17, 2020 at 13:15
• Thanks, would you mind writing an answer so I can accept it? Apr 17, 2020 at 13:32