CRAFTS Config 101

0. Sign up in CRAFTS

You need to sign up in CRAFTS in order to follow this guide. Please do it here.

1. The simplest API

API configuration

{
  "apiId": "test",
  "endpoints": [
    {
      "id": "crossforest",
      "sparqlURI": "https://forestexplorer.gsic.uva.es/sparql/",
      "graphURI": "http://crossforest.eu",
      "httpMethod": "GET"
    }
  ],
  "model": [
    {
      "id": "Tree",
      "oprops": [ ],
      "dprops": [
        {
          "label": "heightM",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasTotalHeightInMeters",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    }
  ],
  "queryTemplates": [ ]
}

Testing

2. Including positions and additional members

API configuration

Changes from previous step

{
  "apiId": "test",
  "endpoints": [
    {
      "id": "crossforest",
      "sparqlURI": "https://forestexplorer.gsic.uva.es/sparql/",
      "graphURI": "http://crossforest.eu",
      "httpMethod": "GET"
    }
  ],
  "model": [
    {
      "id": "Tree",
      "oprops": [ 
        {
          "label": "position",
          "targetId": "Position",
          "iri": "http://crossforest.eu/position/ontology/hasPosition",
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "dbh1mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH1InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "dbh2mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH2InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "heightM",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasTotalHeightInMeters",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    },
    {
      "id": "Position",
      "oprops": [
        {
          "label": "crs",
          "iri": "http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem",
          "endpoint": "crossforest"
        },
        {
          "label": "reference",
          "iri": "http://crossforest.eu/position/ontology/hasReference",
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "latWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/1",
          "endpoint": "crossforest"
        },
        {
          "label": "lngWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/2",
          "endpoint": "crossforest"
        },
        {
          "label": "latUTM",
          "iri": "http://epsg.w3id.org/ontology/axis/47",
          "endpoint": "crossforest"
        },
        {
          "label": "lngUTM",
          "iri": "http://epsg.w3id.org/ontology/axis/48",
          "endpoint": "crossforest"
        },
        {
          "label": "distRefM",
          "iri": "http://crossforest.eu/position/ontology/hasDistanceInMeters",
          "endpoint": "crossforest"
        },
        {
          "label": "dirGons",
          "iri": "http://crossforest.eu/position/ontology/hasDirectionInGradians",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    }
  ],
  "queryTemplates": [ ]
}

Testing

3. Refining the model

API configuration

Changes from previous step

{
  "apiId": "test",
  "endpoints": [
    {
      "id": "crossforest",
      "sparqlURI": "https://forestexplorer.gsic.uva.es/sparql/",
      "graphURI": "http://crossforest.eu",
      "httpMethod": "GET"
    }
  ],
  "model": [
    {
      "id": "Tree",
      "oprops": [ 
        {
          "label": "position",
          "targetId": "Position",
          "iri": "http://crossforest.eu/position/ontology/hasPosition",
          "embed": true,
          "restrictions": [
            "?value <http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem> <http://epsg.w3id.org/data/crs/4326> ."
          ],
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "dbh1mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH1InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "dbh2mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH2InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "heightM",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasTotalHeightInMeters",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    },
    {
      "id": "Position",
      "oprops": [
        {
          "label": "crs",
          "iri": "http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem",
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "latWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/1",
          "endpoint": "crossforest"
        },
        {
          "label": "lngWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/2",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    }
  ],
  "queryTemplates": [ ]
}

Testing

4. A query template for finding trees in a box

API configuration

Changes from previous step

{
  "apiId": "test",
  "endpoints": [
    {
      "id": "crossforest",
      "sparqlURI": "https://forestexplorer.gsic.uva.es/sparql/",
      "graphURI": "http://crossforest.eu",
      "httpMethod": "GET"
    }
  ],
  "model": [
    {
      "id": "Tree",
      "oprops": [ 
        {
          "label": "position",
          "targetId": "Position",
          "iri": "http://crossforest.eu/position/ontology/hasPosition",
          "embed": true,
          "restrictions": [
            "?value <http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem> <http://epsg.w3id.org/data/crs/4326> ."
          ],
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "dbh1mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH1InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "dbh2mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH2InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "heightM",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasTotalHeightInMeters",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    },
    {
      "id": "Position",
      "oprops": [
        {
          "label": "crs",
          "iri": "http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem",
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "latWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/1",
          "endpoint": "crossforest"
        },
        {
          "label": "lngWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/2",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    }
  ],
  "queryTemplates": [ 
    {
      "id": "treesinbox",
      "description": "Obtain trees (variable \"tree\") and their coordinates (variables \"tlat\", \"tlng\") in a box (parameters \"lngwest\", \"lngeast\", \"latsouth\", \"latnorth\"). This template query can be paginated with the optional parameters \"limit\" and \"offset\"",
      "template": "SELECT DISTINCT ?tree ?tlat ?tlng WHERE {\n?tree a <https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/Tree> ;\n  <http://crossforest.eu/position/ontology/hasPosition> ?pos .\n?pos <http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem> <http://epsg.w3id.org/data/crs/4326> ;\n  <http://epsg.w3id.org/ontology/axis/1> ?tlat ;\n  <http://epsg.w3id.org/ontology/axis/2> ?tlng .\n{{#latsouth}} FILTER (?tlat > {{latsouth}}) .\n{{/latsouth}}{{#latnorth}} FILTER (?tlat < {{latnorth}}) .\n{{/latnorth}}{{#lngwest}} FILTER (?tlng > {{lngwest}}) .\n{{/lngwest}}{{#lngeast}} FILTER (?tlng < {{lngeast}}) .\n{{/lngeast}}} \n{{#limit}}LIMIT {{limit}}{{/limit}}{{^limit}}LIMIT 100{{/limit}}{{#offset}}\nOFFSET {{offset}}{{/offset}}",
      "variables": [
        "tree",
        "tlat",
        "tlng"
      ],
      "parameters": [
        {
          "label": "lngwest",
          "type": "number",
          "optional": true
        },
        {
          "label": "lngeast",
          "type": "number",
          "optional": true
        },
        {
          "label": "latnorth",
          "type": "number",
          "optional": true
        },
        {
          "label": "latsouth",
          "type": "number",
          "optional": true
        },
        {
          "label": "limit",
          "type": "integer",
          "optional": true
        },
        {
          "label": "offset",
          "type": "integer",
          "optional": true
        }
      ],
      "endpoint": "crossforest"
    }  
  ]
}

Testing

5. Improving the model to include tree species

API configuration

Changes from previous step

{
  "apiId": "test",
  "endpoints": [
    {
      "id": "crossforest",
      "sparqlURI": "https://forestexplorer.gsic.uva.es/sparql/",
      "graphURI": "http://crossforest.eu",
      "httpMethod": "GET"
    }
  ],
  "model": [
    {
      "id": "Tree",
      "oprops": [ 
        {
          "label": "position",
          "targetId": "Position",
          "iri": "http://crossforest.eu/position/ontology/hasPosition",
          "embed": true,
          "restrictions": [
            "?value <http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem> <http://epsg.w3id.org/data/crs/4326> ."
          ],
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "dbh1mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH1InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "dbh2mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH2InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "heightM",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasTotalHeightInMeters",
          "endpoint": "crossforest"
        }
      ],
      "types": [
        {
          "label": "species",
          "targetId": "Species",
          "embed": true,
          "endpoint": "crossforest"
        }
      ]
    },
    {
      "id": "Position",
      "oprops": [
        {
          "label": "crs",
          "iri": "http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem",
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "latWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/1",
          "endpoint": "crossforest"
        },
        {
          "label": "lngWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/2",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    },
    {
      "id": "Species",
      "oprops": [ ],
      "dprops": [
        {
          "label": "scientificName",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasAcceptedName>/<https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/name",
          "endpoint": "crossforest"
        },
        {
          "label": "vulgarName",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/vulgarName",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    }
  ],
  "queryTemplates": [ 
    {
      "id": "treesinbox",
      "description": "Obtain trees (variable \"tree\") and their coordinates (variables \"tlat\", \"tlng\") in a box (parameters \"lngwest\", \"lngeast\", \"latsouth\", \"latnorth\"). This template query can be paginated with the optional parameters \"limit\" and \"offset\"",
      "template": "SELECT DISTINCT ?tree ?tlat ?tlng WHERE {\n?tree a <https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/Tree> ;\n  <http://crossforest.eu/position/ontology/hasPosition> ?pos .\n?pos <http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem> <http://epsg.w3id.org/data/crs/4326> ;\n  <http://epsg.w3id.org/ontology/axis/1> ?tlat ;\n  <http://epsg.w3id.org/ontology/axis/2> ?tlng .\n{{#latsouth}} FILTER (?tlat > {{latsouth}}) .\n{{/latsouth}}{{#latnorth}} FILTER (?tlat < {{latnorth}}) .\n{{/latnorth}}{{#lngwest}} FILTER (?tlng > {{lngwest}}) .\n{{/lngwest}}{{#lngeast}} FILTER (?tlng < {{lngeast}}) .\n{{/lngeast}}} \n{{#limit}}LIMIT {{limit}}{{/limit}}{{^limit}}LIMIT 100{{/limit}}{{#offset}}\nOFFSET {{offset}}{{/offset}}",
      "variables": [
        "tree",
        "tlat",
        "tlng"
      ],
      "parameters": [
        {
          "label": "lngwest",
          "type": "number",
          "optional": true
        },
        {
          "label": "lngeast",
          "type": "number",
          "optional": true
        },
        {
          "label": "latnorth",
          "type": "number",
          "optional": true
        },
        {
          "label": "latsouth",
          "type": "number",
          "optional": true
        },
        {
          "label": "limit",
          "type": "integer",
          "optional": true
        },
        {
          "label": "offset",
          "type": "integer",
          "optional": true
        }
      ],
      "endpoint": "crossforest"
    }  
  ]
}

Testing

6. Federating Cross-Forest and DBpedia data

API configuration

Changes from previous step

{
  "apiId": "test",
  "endpoints": [
    {
      "id": "crossforest",
      "sparqlURI": "https://forestexplorer.gsic.uva.es/sparql/",
      "graphURI": "http://crossforest.eu",
      "httpMethod": "GET"
    },
    {
      "id": "dbpedia",
      "sparqlURI": "http://dbpedia.org/sparql",
      "graphURI": "http://dbpedia.org",
      "httpMethod": "GET"
    }
  ],
  "model": [
    {
      "id": "Tree",
      "oprops": [ 
        {
          "label": "position",
          "targetId": "Position",
          "iri": "http://crossforest.eu/position/ontology/hasPosition",
          "embed": true,
          "restrictions": [
            "?value <http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem> <http://epsg.w3id.org/data/crs/4326> ."
          ],
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "dbh1mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH1InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "dbh2mm",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasDBH2InMillimeters",
          "endpoint": "crossforest"
        },
        {
          "label": "heightM",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasTotalHeightInMeters",
          "endpoint": "crossforest"
        }
      ],
      "types": [
        {
          "label": "species",
          "targetId": "Species",
          "embed": true,
          "restrictions": [
            "?type rdfs:subClassOf+ <https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/Plantae> ."
          ],
          "endpoint": "crossforest"
        }
      ]
    },
    {
      "id": "Position",
      "oprops": [
        {
          "label": "crs",
          "iri": "http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem",
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "latWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/1",
          "endpoint": "crossforest"
        },
        {
          "label": "lngWGS84",
          "iri": "http://epsg.w3id.org/ontology/axis/2",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    },
    {
      "id": "Species",
      "oprops": [
        {
          "label": "dbpedia",
          "targetId": "DbpediaSpecies",
          "iri": "http://schema.org/sameAs",
          "restrictions": [
            "FILTER contains(str(?value), \"dbpedia\" )"
          ],
          "embed": true,
          "endpoint": "crossforest"
        }
      ],
      "dprops": [
        {
          "label": "scientificName",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/hasAcceptedName>/<https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/name",
          "endpoint": "crossforest"
        },
        {
          "label": "vulgarName",
          "iri": "https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/vulgarName",
          "endpoint": "crossforest"
        }
      ],
      "types": []
    },
    {
      "id": "DbpediaSpecies",
      "oprops": [
        {
          "label": "image",
          "iri": "http://dbpedia.org/ontology/thumbnail",
          "endpoint": "dbpedia"
        }
      ],
      "dprops": [
        {
          "label": "comment",
          "iri": "http://www.w3.org/2000/01/rdf-schema#comment",
          "restrictions": [
            "FILTER (lang(?value) = \"es\" OR lang(?value) = \"en\" OR lang(?value) = \"\")"
          ],
          "endpoint": "dbpedia"
        }
      ],
      "types": []
    }
  ],
  "queryTemplates": [ 
    {
      "id": "treesinbox",
      "description": "Obtain trees (variable \"tree\"), their species (variable \"tsps\") and their coordinates (variables \"tlat\", \"tlng\") in a box (parameters \"lngwest\", \"lngeast\", \"latsouth\", \"latnorth\") of species \"species\". This template query can be paginated with the optional parameters \"limit\" and \"offset\"",
      "template": "SELECT DISTINCT ?tree ?tsps ?tlat ?tlng WHERE {\n?tree a <https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/Tree>, ?tsps ;\n  <http://crossforest.eu/position/ontology/hasPosition> ?pos .\n?pos <http://crossforest.eu/position/ontology/hasCoordinateReferenceSystem> <http://epsg.w3id.org/data/crs/4326> ;\n  <http://epsg.w3id.org/ontology/axis/1> ?tlat ;\n  <http://epsg.w3id.org/ontology/axis/2> ?tlng .\n?tsps rdfs:subClassOf+ <https://datos.iepnb.es/def/sector-publico/medio-ambiente/ifn/Plantae> .\n{{#species}} FILTER (?tsps IN (<{{{species}}}>)) .\n{{/species}}{{#latsouth}} FILTER (?tlat > {{latsouth}}) .\n{{/latsouth}}{{#latnorth}} FILTER (?tlat < {{latnorth}}) .\n{{/latnorth}}{{#lngwest}} FILTER (?tlng > {{lngwest}}) .\n{{/lngwest}}{{#lngeast}} FILTER (?tlng < {{lngeast}}) .\n{{/lngeast}}} \n{{#limit}}LIMIT {{limit}}{{/limit}}{{^limit}}LIMIT 100{{/limit}}{{#offset}}\nOFFSET {{offset}}{{/offset}}",
      "variables": [
        "tree",
        "tlat",
        "tlng",
        "tsps"
      ],
      "parameters": [
        {
          "label": "species",
          "type": "iri",
          "optional": true
        },
        {
          "label": "lngwest",
          "type": "number",
          "optional": true
        },
        {
          "label": "lngeast",
          "type": "number",
          "optional": true
        },
        {
          "label": "latnorth",
          "type": "number",
          "optional": true
        },
        {
          "label": "latsouth",
          "type": "number",
          "optional": true
        },
        {
          "label": "limit",
          "type": "integer",
          "optional": true
        },
        {
          "label": "offset",
          "type": "integer",
          "optional": true
        }
      ],
      "endpoint": "crossforest"
    }  
  ]
}

Testing