2

This question already has an answer here:

The OGC Simple Features standard (OGC 06-103r4, Version: 1.2.1), section 7, defines the formal grammar of Well Known Text (WKT) representation. A small excerpt (omitting a large subset of geometry types and most of the terminals):

<empty set> ::= EMPTY
<point> ::= <x> <y>
<geometry tagged text> ::= <point tagged text>
                         | <linestring tagged text>
                         | <polygon tagged text>
                         | …
<point tagged text> ::= point <point text>
<linestring tagged text> ::= linestring <linestring text>
<polygon tagged text> ::= polygon <polygon text>
<point text> ::= <empty set> | <left paren> <point> <right paren>
<linestring text> ::= <empty set> 
                    | <left paren> 
                      <point> {<comma> <point>}*
                      <right paren>
<polygon text> ::= <empty set>
                 | <left paren>
                   <linestring text>
                   {<comma> <linestring text>}*
                   <right paren>

Interpreting this grammar as written, one might conclude that all of the following are syntactically valid WKT:

  • POINT EMPTY — an empty point
  • LINESTRING EMPTY — an empty linestring
  • LINESTRING(EMPTY) — a linestring having a single vertex which is empty
  • LINESTRING(0 0, EMPTY) — a linestring whose one vertex is at the origin and the other is empty
  • POLYGON EMPTY — an empty polygon
  • POLYGON(EMPTY) — a polygon whose exterior boundary is empty, and which has no interior boundaries
  • POLYGON(EMPTY, EMPTY) — a polygon with an empty exterior boundary and a single empty interior boundary
  • POLYGON(EMPTY, (0 0, 0 1, 1 1, 1 0, 0 0)) — a polygon with an empty exterior boundary and an interior boundary delimiting a unit square
  • POLYGON((0 0, 1 0, 1 1, 0 1, 0 0), EMPTY) — a polygon with an exterior boundary delimiting a unit square and an empty interior boundary
  • POLYGON((0 0, EMPTY, 0 0)) — a polygon with a two-vertex exterior ring whose one vertex is empty

What I’d like to know is which of these are semantically valid, and what they specifically mean.


Here’s my own take, based on the section 6.1 (Geometry object model).

A Point (6.1.4) has two Double coordinates, X() and Y(), which are always present. (The optional Z() and M() are explicitly described as such and have the NIL value if absent.) Therefore, an empty point must also have valid Double X() and Y(), and the only sane way is to say that the empty point has both coordinates of NaN.

On the class hierarchy diagram (6.1.1), a LineString is defined as a subclass of Curve and has an aggregation to Point with a multiplicity of 2..*. Therefore, LINESTRING(EMPTY) and LINESTRING(0 0) are invalid because they violate that multiplicity.

Furthermore, a Curve (6.1.6) is defined to be a homeomorphic image of a real closed interval. This precludes LINESTRING EMPTY because empty geometries are defined as the empty set of points.

Additionally, a LineString (6.1.7) is a curve with linear interpolation between consecutive Points. Linear interpolation involving NaN coordinations will yield NaN again. Therefore, any linear segment whose either or both ends are the empty point is a single-element set containing the empty point.

If such a linear segment joins a regular linear segment in a linestring, e.g. LINESTRING(0 0, 1 1, EMPTY), there is a discontinuity at the join point (1 1). Thus, the only valid linestring whose any vertex is empty is the single-empty-point linestring. By definition, it is closed.

By the class hierarchy diagram, a Polygon is a Surface and aggregates 1..* LinearRings. Thus POLYGON EMPTY is invalid because it has no rings, and no boundary of a polygon can be empty because linestrings cannot be empty.

POLYGON((0 0, EMPTY, 0 0)) is invalid because it has to include its own boundary (which, as explained above, consists of the single empty point) but its interior is empty (as is the interior of any single point), thus breaking rule 6.1.11.1(d): P = P.Interior.Closure. So is any polygon having this kind of degenerate ring as an inner boundary.


All in all, it seems, the use of empty geometries is severely limited. A point, multipoint, multiline, multipolygon, multisurface, or a geometry collection can be empty, but not a linestring, polygon, triangle, polyhedral surface or a TIN. A linestring whose any vertex is empty degenerates into a single set containing only the empty point. Neither empty nor degenerate linestrings cannot be external or internal boundaries of polygons.

Is my reasoning correct?


I have seen the previous question about EMPTY and find it insufficient. It only talks about the use of EMPTY immediately following the geometry type tag. However, the grammar allows the EMPTY keyword nested in compound structures and I want to know the meaning or intent of such constructs.

marked as duplicate by Ian Turton Nov 4 '15 at 9:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I have added the explanation. – Yuri Khan Nov 4 '15 at 12:28

Browse other questions tagged or ask your own question.