Casts between spatial data types

You can cast between spatial data types from subtype to supertype.

If you attempt to cast from a supertype to a subtype, or another combination of types that is not compatible, the function returns NULL.

The following example casts to a ST_LineString and filters out any NULL values:

SELECT ST_StartPoint(my_geometry_col::ST_LineString) from mytab
      WHERE ST_GeometryType(my_geometry_col) = 'st_linestring';