3

Despite reading a lot of materials on the subject, including the PostGIS manual I still haven't been able to understand, I'm a beginner in this world of geographic objects. I have two tables in my database that have a column called the_geom. Table ways and ways_vertices_pgr.

  • ways: the_geom -> geometry (Point, 4326)

Example of the_geom data with a select in a column:

POINT (-48.2486036 -18.8790378)
  • ways_vertices_pgr: the_geom -> geometry (LineString, 4326)

Example of the_geom data with a select in a column:

LINESTRING (-48.2662325 -18.9026985, -48.2657083 -18.902022)

The geometry type is a PostGIS spatial data type used to represent a feature in coordinate systems. OpenGIS Consortium has defined two ways to represent spatial objects in a bank, WKT and WKB.

In my example, I am using WKT and not EWKT, correct? Because I'm using a Cartesian coordinate system, 2D plane. From my database, is it correct to say that the geometry type is represented in my database as a WKT text representation? With Point and SRID? Explaining better, is it correct to say that the entire the_geom column is represented in WKT format?

Or not, the WKT text representation is only for the POINT type, and does PostGIS extend this pattern by adding the SRID?

3
  • are your tables already in postgis? the geometry column name becomes wkb_geometry
    – Elio Diaz
    Commented Apr 29, 2021 at 23:10
  • 1
    @ElioDiaz I'm using pgRouting + osm2pgrouting. Osm2pgrouting creates these tables.
    – Adriano
    Commented Apr 29, 2021 at 23:28
  • 1
    Well-Known Text (WKT and EWKT) is an ASCII transfer format. Developers would have to be deranged to store coordinate streams in ASCII in a database. You need to split apart the datatype from the representation that manifests in an ASCII environment.
    – Vince
    Commented Apr 30, 2021 at 0:22

1 Answer 1

6

PostGIS internally stores geometry data as binary objects which are optimized for scanning and processing. Geometry objects include the SRID.

WKT, EWKT, WKB and EWKB are just representations for external use. As per the OGC spec WKT and WKB do not include the SRID. EWKT and EWKB do include the SRID, so they can be used as full-fidelity representations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.