Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BDRSPS-918] First stab adding coordinateUncertaintyInMeters #290

Merged
merged 12 commits into from
Nov 6, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,6 @@
<http://createme.org/sampling/field/14> a tern:Sampling ;
void:inDataset <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
geo:hasGeometry _:N7b30d47b6a23a645ada08e200000001a ;
geo:hasMetricSpatialAccuracy 2e+01 ;
rdfs:comment "field-sampling" ;
time:hasTime [ a time:Instant ;
time:inXSDDate "2019-09-26"^^xsd:date ] ;
Expand All @@ -1523,7 +1522,6 @@
<http://createme.org/sampling/field/15> a tern:Sampling ;
void:inDataset <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
geo:hasGeometry _:N7b30d47b6a23a645ada08e200000001c ;
geo:hasMetricSpatialAccuracy 5e+01 ;
rdfs:comment "field-sampling" ;
time:hasTime [ a time:Instant ;
time:inXSDDate "2019-09-26"^^xsd:date ] ;
Expand All @@ -1537,7 +1535,6 @@
<http://createme.org/sampling/field/16> a tern:Sampling ;
void:inDataset <http://createme.org/dataset/Example-Incidental-Occurrence-Dataset> ;
geo:hasGeometry _:N7b30d47b6a23a645ada08e200000001e ;
geo:hasMetricSpatialAccuracy 3e+01 ;
rdfs:comment "field-sampling" ;
time:hasTime [ a time:Instant ;
time:inXSDDate "2019-09-26"^^xsd:date ] ;
Expand Down Expand Up @@ -2080,23 +2077,26 @@

[] a rdf:Statement ;
geo:hasGeometry [ a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.86 115.02)"^^geo:wktLiteral ] ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.86 115.02)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 2e+01 ] ;
rdf:object _:N7b30d47b6a23a645ada08e200000001a ;
rdf:predicate geo:hasGeometry ;
rdf:subject <http://createme.org/sampling/field/14> ;
rdfs:comment "supplied as" .

[] a rdf:Statement ;
geo:hasGeometry [ a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ] ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 5e+01 ] ;
rdf:object _:N7b30d47b6a23a645ada08e200000001c ;
rdf:predicate geo:hasGeometry ;
rdf:subject <http://createme.org/sampling/field/15> ;
rdfs:comment "supplied as" .

[] a rdf:Statement ;
geo:hasGeometry [ a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ] ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 3e+01 ] ;
rdf:object _:N7b30d47b6a23a645ada08e200000001e ;
rdf:predicate geo:hasGeometry ;
rdf:subject <http://createme.org/sampling/field/16> ;
Expand Down Expand Up @@ -2182,13 +2182,16 @@ _:N7b30d47b6a23a645ada08e2000000018 a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.86 115.02)"^^geo:wktLiteral .

_:N7b30d47b6a23a645ada08e200000001a a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.86 115.02)"^^geo:wktLiteral .
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.86 115.02)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 2e+01 .

_:N7b30d47b6a23a645ada08e200000001c a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral .
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 5e+01 .

_:N7b30d47b6a23a645ada08e200000001e a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral .
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 3e+01 .

_:Nfc9ba55a50d500211c02e20000000001 a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.86 115.02)"^^geo:wktLiteral ;
Expand Down
13 changes: 7 additions & 6 deletions abis_mapping/templates/incidental_occurrence_data_v3/mapping.py
chungvl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -1441,13 +1441,20 @@ def add_sampling_field(
graph.add((geometry_node, a, utils.namespaces.GEO.Geometry))
graph.add((geometry_node, utils.namespaces.GEO.asWKT, geometry.to_transformed_crs_rdf_literal()))

spatial_accuracy = row["coordinateUncertaintyInMeters"]
accuracy = None
if spatial_accuracy is not None:
accuracy = rdflib.Literal(spatial_accuracy, datatype=rdflib.XSD.double)
graph.add((geometry_node, utils.namespaces.GEO.hasMetricSpatialAccuracy, accuracy))

# Add 'supplied as' geometry
self.add_geometry_supplied_as(
chungvl marked this conversation as resolved.
Show resolved Hide resolved
subj=uri,
pred=utils.namespaces.GEO.hasGeometry,
obj=geometry_node,
geom=geometry,
graph=graph,
spatial_accuracy=accuracy,
)

# Add temporal members
Expand Down Expand Up @@ -1476,12 +1483,6 @@ def add_sampling_field(
# Add Location Description
graph.add((uri, utils.namespaces.TERN.locationDescription, rdflib.Literal(row["locality"])))

# Check for coordinateUncertaintyInMeters
if row["coordinateUncertaintyInMeters"]:
# Add Spatial Accuracy
accuracy = rdflib.Literal(row["coordinateUncertaintyInMeters"], datatype=rdflib.XSD.double)
graph.add((uri, utils.namespaces.GEO.hasMetricSpatialAccuracy, accuracy))

def add_provider_record_id_agent(
self,
uri: rdflib.URIRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,6 @@
<http://createme.org/sampling/field/14> a tern:Sampling ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Occurrence-Dataset> ;
geo:hasGeometry _:N80c91623373a353a57a815210000001b ;
geo:hasMetricSpatialAccuracy 2e+01 ;
rdfs:comment "field-sampling" ;
time:hasTime [ a time:Instant ;
time:inXSDDate "2019-09-26"^^xsd:date ] ;
Expand All @@ -1523,7 +1522,6 @@
<http://createme.org/sampling/field/15> a tern:Sampling ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Occurrence-Dataset> ;
geo:hasGeometry _:N80c91623373a353a57a815210000001d ;
geo:hasMetricSpatialAccuracy 5e+01 ;
rdfs:comment "field-sampling" ;
time:hasTime [ a time:Instant ;
time:inXSDDate "2019-09-26"^^xsd:date ] ;
Expand All @@ -1539,7 +1537,6 @@
<http://createme.org/sampling/field/16> a tern:Sampling ;
void:inDataset <http://createme.org/dataset/Example-Systematic-Survey-Occurrence-Dataset> ;
geo:hasGeometry _:N80c91623373a353a57a815210000001f ;
geo:hasMetricSpatialAccuracy 3e+01 ;
rdfs:comment "field-sampling" ;
time:hasTime [ a time:Instant ;
time:inXSDDate "2019-09-26"^^xsd:date ] ;
Expand Down Expand Up @@ -2123,23 +2120,26 @@

[] a rdf:Statement ;
geo:hasGeometry [ a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.86 115.02)"^^geo:wktLiteral ] ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.86 115.02)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 2e+01 ] ;
rdf:object _:N80c91623373a353a57a815210000001b ;
rdf:predicate geo:hasGeometry ;
rdf:subject <http://createme.org/sampling/field/14> ;
rdfs:comment "supplied as" .

[] a rdf:Statement ;
geo:hasGeometry [ a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ] ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 5e+01 ] ;
rdf:object _:N80c91623373a353a57a815210000001d ;
rdf:predicate geo:hasGeometry ;
rdf:subject <http://createme.org/sampling/field/15> ;
rdfs:comment "supplied as" .

[] a rdf:Statement ;
geo:hasGeometry [ a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ] ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 3e+01 ] ;
rdf:object _:N80c91623373a353a57a815210000001f ;
rdf:predicate geo:hasGeometry ;
rdf:subject <http://createme.org/sampling/field/16> ;
Expand Down Expand Up @@ -2201,13 +2201,16 @@ _:N80c91623373a353a57a8152100000019 a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.86 115.02)"^^geo:wktLiteral .

_:N80c91623373a353a57a815210000001b a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.86 115.02)"^^geo:wktLiteral .
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.86 115.02)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 2e+01 .

_:N80c91623373a353a57a815210000001d a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral .
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 5e+01 .

_:N80c91623373a353a57a815210000001f a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral .
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral ;
geo:hasMetricSpatialAccuracy 3e+01 .

_:N97499f6e93a23881f212924400000001 a geo:Geometry ;
geo:asWKT "<http://www.opengis.net/def/crs/EPSG/0/7844> POINT (-33.8 115.21)"^^geo:wktLiteral ;
Expand Down
14 changes: 8 additions & 6 deletions abis_mapping/templates/survey_occurrence_data_v2/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,13 @@ def add_sampling_field(
graph.add((uri, utils.namespaces.GEO.hasGeometry, geometry_node))
graph.add((geometry_node, a, utils.namespaces.GEO.Geometry))
graph.add((geometry_node, utils.namespaces.GEO.asWKT, geometry.to_transformed_crs_rdf_literal()))

spatial_accuracy = row["coordinateUncertaintyInMeters"]
accuracy = None
if spatial_accuracy is not None:
accuracy = rdflib.Literal(spatial_accuracy, datatype=rdflib.XSD.double)
graph.add((geometry_node, utils.namespaces.GEO.hasMetricSpatialAccuracy, accuracy))

graph.add((uri, rdflib.SOSA.hasResult, sample_field))

# Conditionally add survey
Expand All @@ -1800,6 +1807,7 @@ def add_sampling_field(
obj=geometry_node,
geom=geometry,
graph=graph,
spatial_accuracy=accuracy,
)

# Add site if one provided
Expand Down Expand Up @@ -1827,12 +1835,6 @@ def add_sampling_field(
# Add Location Description
graph.add((uri, utils.namespaces.TERN.locationDescription, rdflib.Literal(row["locality"])))

# Check for coordinateUncertaintyInMeters
if row["coordinateUncertaintyInMeters"]:
# Add Spatial Accuracy
accuracy = rdflib.Literal(row["coordinateUncertaintyInMeters"], datatype=rdflib.XSD.double)
graph.add((uri, utils.namespaces.GEO.hasMetricSpatialAccuracy, accuracy))

def add_provider_record_id_agent(
self,
uri: rdflib.URIRef,
Expand Down
Loading