CSIRO-enviro-informatics / loci-integration-api

This application provides a convenient interface for executing common functions across the whole LOCI system.
0 stars 3 forks source link

Querying across hierarchies with common base unit #67

Closed benjaminleighton closed 4 years ago

jyucsiro commented 4 years ago

hi @benjaminleighton - could you include an example query? I've tried http://localhost:8080/api/v1/location/overlaps?uri=http%3A%2F%2Flinked.data.gov.au%2Fdataset%2Fasgs2016%2Flocalgovernmentarea%2F29399&areas=true&proportion=true&contains=false&within=false&output_type=http%3A%2F%2Flinked.data.gov.au%2Fdef%2Fasgs%23StatisticalAreaLevel1&crosswalk=true&count=1000&offset=0

But i get

{'message': 'Internal Server Error', 'code': 500}
jyucsiro commented 4 years ago

Ah i'm trying now with updated URL to sparql endpoint. seems to be doing something now

jyucsiro commented 4 years ago

Test defined in https://github.com/CSIRO-enviro-informatics/loci-scripts/pull/22/files#diff-d90e98a974ceb2c4b916b576d91f1bc1 is passing now.

Using this spot check example with an arbitrarily selected LGA (http://linked.data.gov.au/dataset/asgs2016/localgovernmentarea/12900) and an overlapping SA1 (http://linked.data.gov.au/dataset/asgs2016/statisticalarealevel1/10302106217) - shown below

image

API results returns

{
  "uri": "http://linked.data.gov.au/dataset/asgs2016/statisticalarealevel1/10302106217",
  "intersection_area": "9311120.62301000",
  "forwardPercentage": 0.1976829637,
  "featureArea": "1521018300.00000024",
  "reversePercentage": 0.6121636158
}

QGIS reports the area as 9311049.65402992

So looks like the result is accurate to 4 significant figures. Good enough @benjaminleighton @ashleysommer @dr-shorthair ?

benjaminleighton commented 4 years ago

A possible test here would be to ask the API to get the meshblocks from both the SA1 and LGA then find the intersecting meshblocks, visualise those in QGIS and see whether they fully cover that overlapping area. Also check the area in QGIS is albers.

jyucsiro commented 4 years ago

Ok will extend tests to do a sum. Spot checking the smallest case http://localhost:8080/api/v1/location/overlaps?uri=http%3A%2F%2Flinked.data.gov.au%2Fdataset%2Fasgs2016%2Flocalgovernmentarea%2F35790&areas=true&proportion=true&contains=false&within=false&output_type=http%3A%2F%2Flinked.data.gov.au%2Fdef%2Fasgs%23StatisticalAreaLevel1&crosswalk=true&count=1000&offset=0

Sum returned by API = 71,992,904 Feature area = 71,992,800

So 99.999% accurate...

Will do on others