Skip to content

Commit e81b2e5

Browse files
committed
capture dct:spatial as bbox, if it contains a box + add csw parse tests
1 parent 1354d06 commit e81b2e5

File tree

4 files changed

+110
-3
lines changed

4 files changed

+110
-3
lines changed

owslib/catalogue/csw2.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,15 +849,25 @@ def __init__(self, record):
849849
for i in record.findall(util.nspath_eval('dc:rights', namespaces)):
850850
self.rights.append(util.testXMLValue(i))
851851

852-
val = record.find(util.nspath_eval('dct:spatial', namespaces))
853-
self.spatial = util.testXMLValue(val)
854-
855852
val = record.find(util.nspath_eval('ows:BoundingBox', namespaces))
856853
if val is not None:
857854
self.bbox = ows.BoundingBox(val, namespaces['ows'])
858855
else:
859856
self.bbox = None
860857

858+
val = record.find(util.nspath_eval('dct:spatial', namespaces))
859+
self.spatial = None
860+
if val is not None:
861+
val = util.testXMLValue(val)
862+
if len(val.split(',')) == 4:
863+
self.bbox = ows.BoundingBox(None, namespaces['ows'])
864+
self.bbox.minx = val.split(',')[0]
865+
self.bbox.miny = val.split(',')[1]
866+
self.bbox.maxx = val.split(',')[2]
867+
self.bbox.maxy = val.split(',')[3]
868+
else:
869+
self.spatial = val
870+
861871
val = record.find(util.nspath_eval('ows:WGS84BoundingBox', namespaces))
862872
if val is not None:
863873
self.bbox_wgs84 = ows.WGS84BoundingBox(val, namespaces['ows'])

owslib/catalogue/csw3.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,19 @@ def __init__(self, record):
757757
else:
758758
self.bbox = None
759759

760+
val = record.find(util.nspath_eval('dct:spatial', namespaces))
761+
self.spatial = None
762+
if val is not None:
763+
val = util.testXMLValue(val)
764+
if len(val.split(',')) == 4:
765+
self.bbox = ows.BoundingBox(None, namespaces['ows'])
766+
self.bbox.minx = val.split(',')[0]
767+
self.bbox.miny = val.split(',')[1]
768+
self.bbox.maxx = val.split(',')[2]
769+
self.bbox.maxy = val.split(',')[3]
770+
else:
771+
self.spatial = val
772+
760773
val = record.find(util.nspath_eval('ows200:WGS84BoundingBox', namespaces))
761774
if val is not None:
762775
self.bbox_wgs84 = ows.WGS84BoundingBox(val, namespaces['ows'])
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="ISO-8859-1"?>
2+
<rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
3+
<rdf:Description rdf:about="https://doi.org/10.3390/rs12142299">
4+
<dct:license>Open Access</dct:license>
5+
<dc:description>In viticulture, detailed spatial information about actual evapotranspiration (ETa) and vine water status within a vineyard may be of particular utility when applying site-specific, precision irrigation management. Over recent decades, extensive research has been carried out in the use of remote sensing energy balance models to estimate and monitor ETa at the field level. However, one of the major limitations remains the coarse spatial resolution in the thermal infrared (TIR) domain. In this context, the recent advent of the Sentinel missions of the European Space Agency (ESA) has greatly improved the possibility of monitoring crop parameters and estimating ETa at higher temporal and spatial resolutions. In order to bridge the gap between the coarse-resolution Sentinel-3 thermal and the fine-resolution Sentinel-2 shortwave data, sharpening techniques have been used to downscale the Sentinel-3 land surface temperature (LST) from 1 km to 20 m. However, the accurate estimates of high-resolution LST through sharpening techniques are still unclear, particularly when intended to be used for detecting crop water stress. The goal of this study was to assess the feasibility of the two-source energy balance model (TSEB) using sharpened LST images from Sentinel-2 and Sentinel-3 (TSEB-PTS2+3) to estimate the spatio-temporal variability of actual transpiration (T) and water stress in a vineyard. T and crop water stress index (CWSI) estimates were evaluated against a vine water consumption model and regressed with in situ stem water potential (&#936;stem). Two different TSEB approaches, using very high-resolution airborne thermal imagery, were also included in the analysis as benchmarks for TSEB-PTS2+3. One of them uses aggregated TIR data at the vine+inter-row level (TSEB-PTairb), while the other is based on a contextual method that directly, although separately, retrieves soil and canopy temperatures (TSEB-2T). The results obtained demonstrated that when comparing airborne Trad and sharpened S2+3 LST, the latter tend to be underestimated. This complicates the use of TSEB-PTS2+3 to detect crop water stress. TSEB-2T appeared to outperform all the other methods. This was shown by a higher R2 and slightly lower RMSD when compared with modelled T. In addition, regressions between T and CWSI-2T with &#936;stem also produced the highest R2.</dc:description>
6+
<dc:subject>evapotranspiration; TSEB; Sentinel-2; Sentinel-3; crop water stress index; vine water status; grapevines</dc:subject>
7+
<dc:subject>crop water stress index</dc:subject>
8+
<dc:subject>Science</dc:subject>
9+
<dc:creator>Joaquim Bellvert, Christian Jofre-&#264;ekalovi&#263;, Ana Pelech&#225;, Merc&#232; Mata, Hector Nieto, </dc:creator>
10+
<dc:title>Feasibility of Using the Two-Source Energy Balance Model (TSEB) with Sentinel-2 and Sentinel-3 Images to Analyze the Spatio-Temporal Variability of Vine Water Status in a Vineyard</dc:title>
11+
<dc:identifier>10.3390/rs12142299</dc:identifier>
12+
<dc:type>document</dc:type>
13+
<dct:spatial>-180,-90,180,90</dct:spatial>
14+
</rdf:Description>
15+
</rdf:RDF>

tests/test_csw_parsing.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import io
4+
5+
from owslib import util
6+
from owslib.etree import etree
7+
from owslib.csw import (
8+
CswRecord
9+
)
10+
from owslib.namespaces import Namespaces
11+
12+
13+
def get_md_resource(file_path):
14+
"""Read the file and parse into an XML tree.
15+
16+
Parameters
17+
----------
18+
file_path : str
19+
Path of the file to read.
20+
21+
Returns
22+
-------
23+
etree.ElementTree
24+
XML tree of the resource on disk.
25+
26+
"""
27+
namespaces = Namespaces().get_namespaces(keys=('dc', 'dct', 'ows', 'rdf', 'gml', 'csw'))
28+
29+
with io.open(file_path, mode='r', encoding='utf-8') as f:
30+
data = f.read().encode('utf-8')
31+
mdelem = etree.fromstring(data)
32+
33+
return mdelem
34+
35+
36+
def test_md_parsing():
37+
"""Test the parsing of a metadatarecord
38+
39+
GetRecordById response available in
40+
tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc.xml
41+
42+
"""
43+
md_resource = get_md_resource('tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc.xml')
44+
md = CswRecord(md_resource)
45+
46+
assert type(md) is CswRecord
47+
48+
assert md.identifier == '9250AA67-F3AC-6C12-0CB9-0662231AA181'
49+
assert md.title == 'ALLSPECIES'
50+
assert md.format == 'text/xml'
51+
assert md.bbox.minx == '-180'
52+
assert md.contributor == 'EMAN Office'
53+
assert md.creator == 'EMAN Coordinating Office, Environment Canada'
54+
assert md.created == '2009-09-03'
55+
assert md.language == 'eng; CAN'
56+
57+
def test_spatial_parsing():
58+
"""Test the parsing of a metadatarecord
59+
60+
GetRecordById response available in
61+
tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml
62+
63+
"""
64+
md_resource = get_md_resource('tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml')
65+
md = CswRecord(md_resource)
66+
67+
assert type(md) is CswRecord
68+
assert md.title == "Feasibility of Using the Two-Source Energy Balance Model (TSEB) with Sentinel-2 and Sentinel-3 Images to Analyze the Spatio-Temporal Variability of Vine Water Status in a Vineyard"
69+
assert md.bbox.minx == '-180'

0 commit comments

Comments
 (0)