CSIRO-enviro-informatics / geofabric-dataset

A Linked Data version of the Australian Hydrological Geospatial Fabric product
http://geofabricld.net
Apache License 2.0
5 stars 2 forks source link

Convert Geofabric data to use simplified/aligned version of the ontology #26

Open dr-shorthair opened 4 years ago

dr-shorthair commented 4 years ago

https://github.com/CSIRO-enviro-informatics/loci.cat/wiki/Simplifying-the-initial-ontologies describes a simplification of the Geofabric datasets to match a more unified Loc-I ontology pattern. The goal is to simplify/harmonize the SPARQL queries.

The transformations required are illustrated by-example as follows.

Original format from test data

<http://linked.data.gov.au/dataset/geofabric/contractedcatchment/12101547>
  rdf:type geof:ContractedCatchment ;
  geof:perimeterLength [
      qudt:numericValue "0.839999999999691"^^xsd:float ;
      qudt:unit <http://qudt.org/vocab/unit/DEG> ;
    ] ;
  geof:shapeArea [
      qudt:numericValue "0.0179125000000005"^^xsd:float ;
      qudt:unit <http://qudt.org/vocab/unit/DEG2> ;
    ] ;
  geox:hasAreaM2 [
      data:value 173807875.618321 ;
      qb4st:crs <http://www.opengis.net/def/crs/EPSG/0/3577> ;
    ] ;
  geox:hasAreaM2 [
      data:value 173889207.14082238 ;
      qb4st:crs <http://www.opengis.net/def/crs/EPSG/0/4938> ;
    ] ;
  reg:register <http://linked.data.gov.au/dataset/geofabric/contractedcatchment/> ;
  dc:source "Bureau of Meteorology" ;
  geo:sfWithin <http://linked.data.gov.au/dataset/geofabric/drainagedivision/9400210> ;
  geo:sfWithin <http://linked.data.gov.au/dataset/geofabric/riverregion/9400345> ;
.

Minor regularization

  1. reg:registerloci:isMemberOf and inverse
  2. add explicit geo:hasGeometry link to geometry service
    
    <http://linked.data.gov.au/dataset/geofabric/contractedcatchment/12101547>
    rdf:type geof:ContractedCatchment ;
    geof:perimeterLength [
      qudt:numericValue "0.839999999999691"^^xsd:float ;
      qudt:unit <http://qudt.org/vocab/unit/DEG> ;
    ] ;
    geof:shapeArea [
      qudt:numericValue "0.0179125000000005"^^xsd:float ;
      qudt:unit <http://qudt.org/vocab/unit/DEG2> ;
    ] ;
    geox:hasAreaM2 [
      data:value 173807875.618321 ;
      qb4st:crs <http://www.opengis.net/def/crs/EPSG/0/3577> ;
    ] ;
    geox:hasAreaM2 [
      data:value 173889207.14082238 ;
      qb4st:crs <http://www.opengis.net/def/crs/EPSG/0/4938> ;
    ] ;
    loci:isMemberOf <http://linked.data.gov.au/dataset/geofabric/contractedcatchment/> ;
    dc:source "Bureau of Meteorology" ;
    geo:hasGeometry <http://linked.data.gov.au/dataset/loci-geometry/contractedcatchment/12101547> ;
    geo:sfWithin <http://linked.data.gov.au/dataset/geofabric/drainagedivision/9400210> ;
    geo:sfWithin <http://linked.data.gov.au/dataset/geofabric/riverregion/9400345> ;
    .

http://linked.data.gov.au/dataset/geofabric/contractedcatchment/ rdfs:member http://linked.data.gov.au/dataset/geofabric/contractedcatchment/12101547 .

dr-shorthair commented 4 years ago

Item 1.:

INSERT { 
        ?gf loci:isMemberOf ?reg . 
        ?reg a rdf:Bag , loci:Dataset ; rdfs:member ?gf . 
}
WHERE { 
    { ?gf a geof:ContractedCatchment . } UNION { ?gf a geof:DrainageDivision . } UNION { ?gf a geof:RiverRegion . }
    BIND(  IRI ( REPLACE ( STR (?gf), "(#|/)[^#/]*$", "$1" )) AS ?reg )
}
dr-shorthair commented 4 years ago

Item 2.:

INSERT { ?gf geo:hasGeometry ?gg . }
WHERE { 
     ?gf a geof:RiverRegion .  
     BIND( IRI( CONCAT( "http://gds.loci.cat/geometry/geofabric2_1_1_riverregion/" , REPLACE( str( ?gf), '^.*(#|/)', "" ))) AS ?gg )
}

INSERT { ?gf geo:hasGeometry ?gg . }
WHERE { 
     ?gf a geof:DrainageDivision.  
     BIND( IRI( CONCAT( "http://gds.loci.cat/geometry/geofabric2_1_1_awradrainagedivision/" , REPLACE( str( ?gf), '^.*(#|/)', "" ))) AS ?gg )
}

INSERT { ?gf geo:hasGeometry ?gg . }
WHERE { 
     ?gf a geof:ContractedCatchment.  
     BIND( IRI( CONCAT( "http://gds.loci.cat/geometry/geofabric2_1_1_ahgfcontractedcatchment/" , REPLACE( str( ?gf), '^.*(#|/)', "" ))) AS ?gg )
}
dr-shorthair commented 4 years ago

Item 3.:

INSERT { ?gf dcterms:identifier ?id. }
WHERE { 
    { ?gf a geof:ContractedCatchment . } UNION { ?gf a geof:DrainageDivision . } UNION { ?gf a geof:RiverRegion . }
        BIND( STRDT( REPLACE( str( ?gf), '^.*(#|/)', "" ), geof:geofabric-id ) AS ?id)
}
ashleysommer commented 4 years ago

geofabric view adapted by commit: https://github.com/CSIRO-enviro-informatics/geofabric-dataset/commit/26eb1f6abaea37196f18bd1e63ac7c6c0a252d69

ashleysommer commented 4 years ago

This can probably be closed now.

jyucsiro commented 4 years ago

@ashleysommer i can see you've implemented externalising the link to the geometry to gds.loci.cat so thanks for that.

The URI isn't quite right. We're using links like this. http://gds.loci.cat/geometry/geofabric2_1_1_awradrainagedivision/9400203

In geofabricld.net drainagedivision features, eg. https://geofabricld.net/drainagedivision/9400203?_view=geofabric&_format=text/turtle

... could you change this:

    geo:hasDefaultGeometry <http://gds.loci.cat/geometry/geofabric2_1_1_drainagedivision/9400203> ;
    geo:hasGeometry <http://gds.loci.cat/geometry/geofabric2_1_1_drainagedivision/9400203> .

to

    geo:hasDefaultGeometry <http://gds.loci.cat/geometry/geofabric2_1_1_awradrainagedivision/9400203> ;
    geo:hasGeometry <http://gds.loci.cat/geometry/geofabric2_1_1_awradrainagedivision/9400203> .

(missing awra in the uri)

ashleysommer commented 4 years ago

@jyucsiro Ok, made that change.