0

Consider the following queries:

SELECT ST_GeomFromEWKT('SRID=32632;POINT(10 20)')::varchar
UNION ALL
SELECT ST_GeomFromEWKT('SRID=4326;POINT(10 20)')::varchar;
UNION ALL
SELECT ST_AsEWKT(ST_GeomFromEWKT('SRID=32632;POINT(10 20)'))
UNION ALL
SELECT ST_AsEWKT(ST_GeomFromEWKT('SRID=4326;POINT(10 20)'))

(Note: the UNION ALL is just so you can copy and paste the whole thing easily)

Results:

0101000020787F000000000000000024400000000000003440
0101000020E610000000000000000024400000000000003440
SRID=32632;POINT(10 20)
SRID=4326;POINT(10 20)

According to the PostGIS documentation, ST_GeomFromEWKT returns a ST_Geometry object. From my first two queries it looks like the resulting objects are identical. They are not, however (see queries 3 and 4).

Now my question is, where is this additional information stored and how can I access the "complete" ST_Geometry object (so all data that are contained in it)?


Version info:

  • PostgreSQL: PostgreSQL 10.3 (Debian 10.3-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit
  • PostGIS: POSTGIS="2.4.3 r16312" PGSQL="100" GEOS="3.5.1-CAPI-1.9.1 r4246" SFCGAL="1.3.0" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.2, released 2017/09/15" LIBXML="2.9.4" LIBJSON="0.12.1" LIBPROTOBUF="1.2.1" (core procs from "2.4.1 r16012" need upgrade) TOPOLOGY (topology procs from "2.4.1 r16012" need upgrade) RASTER (raster procs from "2.4.1 r16012" need upgrade) (sfcgal procs from "2.4.1 r16012" need upgrade)
  • 2
    They are not the same (see characters 11 to 14), as they don't have the same projection – JGH Apr 10 '18 at 16:10
  • True. I messed around with a whole lot of functions and parameters and must have mixed something up. Thanks anyway for the clarification! – karpfen Apr 11 '18 at 15:40
1

Here you can see how data is stored

https://trac.osgeo.org/postgis/browser/trunk/liblwgeom/g_serialized.txt

To access for instace srid use st_srid

With other geometry access functions you can get information about dimmensions and so on http://postgis.net/docs/manual-2.4/reference.html#Geometry_Accessors

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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