npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rdmr-eu/rdf-geopackage

v2.0.0

Published

Generate RDF out of a GeoPackage (for further processing)

Downloads

8

Readme

rdf-geopackage

Get latest version

Generate RDF out of a GeoPackage (for further processing)

Usage

Install using NPM locally npm install --global @rdmr-eu/rdf-geopackage as a command line tool.

Check if it's installed correctly with rdf-geopackage --help. That should return the following help info:

Generate RDF from an OGC GeoPackage with rdf-geopackage

Options:
      --help                   Show help                               [boolean]
      --version                Show version number                     [boolean]
  -i, --input                  GeoPackage file                          [string]
  -o, --output                 Output quads file                        [string]
      --format                 Override output format (default: nquads)
            [choices: "nq", "nquads", "trig", "nt", "ntriples", "ttl", "turtle"]
      --bbox                   Limit features to bounding box           [string]
      --bbox-crs               Coordinate Reference System code         [string]
      --only-layers            Only output named feature layers and attribute ta
                               bles                                      [array]
      --include-binary-values  Output binary values                    [boolean]
      --base-iri               Base IRI                                 [string]
      --model                  Data meta model             [choices: "facade-x"]
      --geosparql              Output GeoSPARQL
  [array] [choices: "wkt", "geojson", "bbox", "centroid", "length-area"] [defaul
                                                                     t: ["wkt"]]

Options

Basic input and output serializations can be set with the following options:

  • --input: the path to the input GeoPackage file (required). With -, it reads the GeoPackage from stdin, e.g., piping a file with curl
  • --output: path to the file output. By default, rdf-geopackage outputs nquads to stdout. Its extension sets the serialization format, optionally with .gz to GZip the output. E.g., --output myfile.ttl.gz
  • --format: set the output format explicitly. Provide a file extension with .gz to GZip the output.

Work with large GeoPackages by limiting the output features, output tables and binary values:

  • --bbox limits the the output features to those in this area (default CRS: WGS84)
  • --bbox-crs indicates the CRS for the aforementioned bounding box. Supply a EPSG code (web lookup with EPSG.io) or a projection WKT.
  • --only-layers limits which feature layers (or attribute tables!) are output.
  • --include-binary-values overrides the default of skipping binary values. These will be base64 encoded string values with a ^^xsd:base64Binary data type. NULL values are never output.

Modify the model and types of the output triples or quads:

  • --base-iri: set the relative base for the output RDF data. By default, this value is derived from the present working directory.
  • --model: the GeoPackage tables are not natively RDF data, so a module is programmed to generating triples according to a data meta-model. Included modules:
  • --geosparql: modify which GeoSPARQL geometries, serializations and properties are output. Only the WKT literal is in layer native CRS, all other are calculated and/or projected. Multiple values (space separated) are allowed. Included feature predicates are listed in the table below.

| Option | GeoSPARQL feature predicates | Note | | ------------------- | ----------------------------------------- | --------------------------------------------------------------- | | wkt (default) | geo:hasGeometry/geo:asWKT | Output the feature's geometry as a WKT string literal | | geojson | geo:hasGeometry/geo:asGeoJSON | Output the feature's geometry as a WGS84 GeoJSON string literal | | bbox | geo:hasBoundingBox | Output a feature's bounding box | | centroid | geo:hasCentroid | Output a feature's centroid point | | length-area | geo:hasMetricLength geo:hasMetricArea | Output the length (in m) and area (in m²) of the feature | | always on | rdf:type geo:Feature | Output the feature class |

RDF output

Model: Facade-X

Facade-X is a data meta-model from the SPARQL-Anything project, that can easily represent tabular data. Facade-X uses RDF containers and blank nodes to represent tables and rows. Column metadata is currently very limited (GH-24) and many values are not typed properly.

Features, geometries and CRS’s

Features and their geometries are represented using GeoSPARQL. Only rows from feature tables are a geo:Feature.

A feature has zero or more geometries predicated with geo:hasDefaultGeometry. There might be no geometry if the underlying library does not support the geometry type. There may be multiple geometries if the feature is from a layer not in EPSG:4326.

That's because a GeoJSON serialization (geo:asGeoJSON) is always (reprojected) in EPSG:4326. A geo:Geometry can be in only one CRS, meaning that when the feature is not originally in EPSG:4326, other serializations should also be reprojected. That is undesirable, so in these cases, rdf-geopackage generates a second geo:Geometry for the WKT serialization (geo:asWKT).

Example RDF output

Example data abridged from NGA: the table media is a feature table, nga_properties is an attribute table.

prefix fx: <http://sparql.xyz/facade-x/ns/>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix xyz: <http://sparql.xyz/facade-x/data/>

xyz:nga_properties {  # representing a table
xyz:nga_properties a fx:root ;  # representing a table
  rdf:_1 [  # the first row
    xyz:id 14;
    xyz:property "subject";
    xyz:value "Examples"
  ] .
}

xyz:media {
xyz:media a fx:root ;
  rdf:_1 [
    a geo:Feature ;  # a row from a feature table
    xyz:text "BIT Systems";
    xyz:date "2023-01-23";
    geo:hasDefaultGeometry [  # single geometry as CRS is EPSG:4326
      a geo:Geometry ;
      geo:asWKT "POINT (-104.801918 39.720014)"^^geo:wktLiteral ;
      geo:asGeoJSON "{\"coordinates\":[-104.801918,39.720014],\"type\":\"Point\"}"^^geo:geoJSONLiteral
    ]
  ] .
}

Acknowledgements

This tool was developed for a project funded by the City Deal Openbare ruimte, executed by Stichting Kennisplatform CROW.