I suspect this is a bit of a longshot...but...

Has anyone had any dealings with reading a Geo Package .gpkg file using Perl. I cannot find anything in CPAN that might help.

A .gpkg file is a SQLite3 DB file. Of course, Perl can handle this. I have used DBD::SQLite to access the Geo Package. The file I am trying to use only has one layer so it only has one row in the gpkg_contents table. This defines the content I need as being in the openUSRN table.

I've used this code to peek at this table....

use DBD::SQLite; use Data::Dumper; use strict; use warnings; my $dbh = DBI->connect("dbi:SQLite:uri=file:osopenusrn_202203.gpkg?mod +e=rwc"); my $tab = $dbh->prepare("SELECT * FROM openUSRN"); $tab->execute; while (my $n = $tab->fetchrow_hashref) { print Dumper $n; }

There are four fields in the table. Three are human-readable text. However, the one I am most interested in, geometry, is gobbledegook. A quick look at the specification seems to show that it is not going to be trivial to work out how to decode this from scratch. So I am hopeful that someone has trodden this path before to give me a head start or even a solution.

I suspect that the geometry is actually a linestring. I am only interested in getting the co-ordinates of the start and the end of the linestring.

Here is a sample of the output...

$VAR1 = { 'geometry' => 'GP ♣4l ►Îú░ü~▬A ]m&# +9827;↓⌂▬A└¯╔├☼$→A&#94 +92;╚v■[$→A ☺Ý♥ ☻ + ☺Û♥ ☻ ]m♣↓⌂▬A└& +#9562;v■[$→A ░¡Ï▀¤~▬A└¯&#9 +556;├☼$→A ☺Û♥ ☻ ► +Îú░ü~▬A`©▲E+$→A ░¡Ï▀¤~&#96 +44;A└¯╔├☼$→A ', 'usrn' => 2900534, 'id' => 1497, 'street_type' => 'Designated Street Name' };


In reply to Geo Package files by Bod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.