On Thu, 10 Feb 2022 17:40:09 -0500, Neel Patel wrote:
> Thank you so much for your reply, I am still having issues with it, I
> was able to read a Point geometry but, the same does not work with a
> string. I had a tuff time understanding the header itself from the
> original source can you please suggest to me a better solution or
> read
> for the same.
>
Hi Neel,
please note that in your SQL query you are not using SpatiaLite
at all:
SELECT geom FROM NRN_ON_14_0_FERRYSEG;
this is just a pure and simple SQLite query that will return
a generic BLOB (that is an opaque binary string).
in your specific case it will be a GeoPackage's own Geometry
adopting a binary encoding that is notably different from
WKB as you seem to naively expect.
just for the sake of completness: SpatiaLite has its own
internal binary encoding for Geometries that differs from
both GPKS and WKB, exactly as PostGIS has its own encodings
and so on.
general lesson: any Spatial DBMS has its specific binary
Geometries and none of them are pure WKB just because
WKB is a format intended for transparent data exchange
but is not well suited for storage purposes.
however any Spatial DBMS supports lots of SQL functions
allowing for converting back and forth from a binary
encoding to another one, so you just have to invoke
the appropriate SQL function for retriving a WKB from
your SQL query as you are expecting:
SELECT ST_AsBinary(geom) FROM NRN_ON_14_0_FERRYSEG;
ST_AsBinary() is a standard OGC function supported by
SpatiaLite and its role is to transform an internal
BLOB geometry into a standard WKB expression; it
works both with SpatiaLite and GPKG BLOBs.
bye Sandro