diff --git a/owslib/catalogue/csw2.py b/owslib/catalogue/csw2.py index 94133c1c..01a1e621 100644 --- a/owslib/catalogue/csw2.py +++ b/owslib/catalogue/csw2.py @@ -849,15 +849,25 @@ def __init__(self, record): for i in record.findall(util.nspath_eval('dc:rights', namespaces)): self.rights.append(util.testXMLValue(i)) - val = record.find(util.nspath_eval('dct:spatial', namespaces)) - self.spatial = util.testXMLValue(val) - val = record.find(util.nspath_eval('ows:BoundingBox', namespaces)) if val is not None: self.bbox = ows.BoundingBox(val, namespaces['ows']) else: self.bbox = None + val = record.find(util.nspath_eval('dct:spatial', namespaces)) + self.spatial = None + if val is not None: + val = util.testXMLValue(val) + if len(val.split(',')) == 4: + self.bbox = ows.BoundingBox(None, namespaces['ows']) + self.bbox.minx = val.split(',')[0] + self.bbox.miny = val.split(',')[1] + self.bbox.maxx = val.split(',')[2] + self.bbox.maxy = val.split(',')[3] + else: + self.spatial = val + val = record.find(util.nspath_eval('ows:WGS84BoundingBox', namespaces)) if val is not None: self.bbox_wgs84 = ows.WGS84BoundingBox(val, namespaces['ows']) diff --git a/owslib/catalogue/csw3.py b/owslib/catalogue/csw3.py index 9d9a842e..a086f0ad 100644 --- a/owslib/catalogue/csw3.py +++ b/owslib/catalogue/csw3.py @@ -757,6 +757,19 @@ def __init__(self, record): else: self.bbox = None + val = record.find(util.nspath_eval('dct:spatial', namespaces)) + self.spatial = None + if val is not None: + val = util.testXMLValue(val) + if len(val.split(',')) == 4: + self.bbox = ows.BoundingBox(None, namespaces['ows']) + self.bbox.minx = val.split(',')[0] + self.bbox.miny = val.split(',')[1] + self.bbox.maxx = val.split(',')[2] + self.bbox.maxy = val.split(',')[3] + else: + self.spatial = val + val = record.find(util.nspath_eval('ows200:WGS84BoundingBox', namespaces)) if val is not None: self.bbox_wgs84 = ows.WGS84BoundingBox(val, namespaces['ows']) diff --git a/tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml b/tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml new file mode 100644 index 00000000..80a84e5f --- /dev/null +++ b/tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml @@ -0,0 +1,15 @@ + + + + Open Access + 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 (Ψ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 Ψstem also produced the highest R2. + evapotranspiration; TSEB; Sentinel-2; Sentinel-3; crop water stress index; vine water status; grapevines + crop water stress index + Science + Joaquim Bellvert, Christian Jofre-Ĉekalović, Ana Pelechá, Mercè Mata, Hector Nieto, + 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 + 10.3390/rs12142299 + document + -180,-90,180,90 + + diff --git a/tests/test_csw_parsing.py b/tests/test_csw_parsing.py new file mode 100644 index 00000000..9c84cc0a --- /dev/null +++ b/tests/test_csw_parsing.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +import io + +from owslib import util +from owslib.etree import etree +from owslib.csw import ( + CswRecord +) +from owslib.namespaces import Namespaces + + +def get_md_resource(file_path): + """Read the file and parse into an XML tree. + + Parameters + ---------- + file_path : str + Path of the file to read. + + Returns + ------- + etree.ElementTree + XML tree of the resource on disk. + + """ + namespaces = Namespaces().get_namespaces(keys=('dc', 'dct', 'ows', 'rdf', 'gml', 'csw')) + + with io.open(file_path, mode='r', encoding='utf-8') as f: + data = f.read().encode('utf-8') + mdelem = etree.fromstring(data) + + return mdelem + + +def test_md_parsing(): + """Test the parsing of a metadatarecord + + GetRecordById response available in + tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc.xml + + """ + md_resource = get_md_resource('tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc.xml') + md = CswRecord(md_resource) + + assert type(md) is CswRecord + + assert md.identifier == '9250AA67-F3AC-6C12-0CB9-0662231AA181' + assert md.title == 'ALLSPECIES' + assert md.format == 'text/xml' + assert md.bbox.minx == '-180' + assert md.contributor == 'EMAN Office' + assert md.creator == 'EMAN Coordinating Office, Environment Canada' + assert md.created == '2009-09-03' + assert md.language == 'eng; CAN' + +def test_spatial_parsing(): + """Test the parsing of a metadatarecord + + GetRecordById response available in + tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml + + """ + md_resource = get_md_resource('tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml') + md = CswRecord(md_resource) + + assert type(md) is CswRecord + 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" + assert md.bbox.minx == '-180' \ No newline at end of file