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

capture dct:spatial as bbox, if it contains a box #963

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions owslib/catalogue/csw2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
13 changes: 13 additions & 0 deletions owslib/catalogue/csw3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
15 changes: 15 additions & 0 deletions tests/resources/9250AA67-F3AC-6C12-0CB9-0662231AA181_dc2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<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#">
<rdf:Description rdf:about="https://doi.org/10.3390/rs12142299">
<dct:license>Open Access</dct:license>
<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>
<dc:subject>evapotranspiration; TSEB; Sentinel-2; Sentinel-3; crop water stress index; vine water status; grapevines</dc:subject>
<dc:subject>crop water stress index</dc:subject>
<dc:subject>Science</dc:subject>
<dc:creator>Joaquim Bellvert, Christian Jofre-&#264;ekalovi&#263;, Ana Pelech&#225;, Merc&#232; Mata, Hector Nieto, </dc:creator>
<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>
<dc:identifier>10.3390/rs12142299</dc:identifier>
<dc:type>document</dc:type>
<dct:spatial>-180,-90,180,90</dct:spatial>
</rdf:Description>
</rdf:RDF>
69 changes: 69 additions & 0 deletions tests/test_csw_parsing.py
Original file line number Diff line number Diff line change
@@ -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'
Loading