Changeset 1023
- Timestamp:
- 01/21/08 06:11:47
- Files:
-
- OWSLib/branches/wcstemp/owslib/coverage/wcs100.py (modified) (3 diffs)
- OWSLib/branches/wcstemp/owslib/coverage/wcs110.py (modified) (14 diffs)
- OWSLib/branches/wcstemp/owslib/coverage/wcsBase.py (modified) (2 diffs)
- OWSLib/branches/wcstemp/owslib/coverage/wcsdecoder.py (modified) (4 diffs)
- OWSLib/branches/wcstemp/owslib/interfaces.py (modified) (2 diffs)
- OWSLib/branches/wcstemp/tests/wcs_newiface.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
OWSLib/branches/wcstemp/owslib/coverage/wcs100.py
r1020 r1023 10 10 # ============================================================================= 11 11 12 from wcsBase import WCSBase, WCSCapabilitiesReader, CoverageInfo, ServiceInfo,RereadableURL12 from wcsBase import WCSBase, WCSCapabilitiesReader, RereadableURL 13 13 from urllib import urlencode 14 14 from urllib2 import urlopen … … 34 34 return self.__getattribute__('servicecontents')[name] 35 35 #otherwise behave normally: 36 return self.__getattribute__( self,name)36 return self.__getattribute__(name) 37 37 38 38 def __init__(self,url,xml): 39 39 self.version='1.0.0' 40 40 self.url = url 41 self._capabilities = None42 41 # initialize from saved capability document or access the server 43 42 reader = WCSCapabilitiesReader(self.version) … … 48 47 49 48 #serviceIdentification metadata 50 self.serviceidentification =None51 49 subelem=self._capabilities.find(ns('Service/')) 52 50 self.serviceidentification=ServiceIdenfication(subelem) 53 51 54 52 #serviceProvider metadata 55 self.serviceprovider =None56 53 subelem=self._capabilities.find(ns('Service/')+ns('responsibleParty')) 57 54 self.serviceprovider=ServiceProvider(subelem) OWSLib/branches/wcstemp/owslib/coverage/wcs110.py
r1020 r1023 12 12 ##########NOTE: Does not conform to new interfaces yet ################# 13 13 14 from wcsBase import WCSBase, WCSCapabilitiesReader, CoverageInfo, ServiceInfo,RereadableURL14 from wcsBase import WCSBase, WCSCapabilitiesReader, RereadableURL 15 15 from urllib import urlencode 16 16 from urllib2 import urlopen … … 29 29 Implements IWebCoverageService. 30 30 """ 31 def __init__(self, url, xml): 31 32 def __getitem__(self, name): 33 ''' check contents dictionary to allow dict like access to service layers''' 34 if 'servicecontents' in self.__dict__.keys(): 35 if name in self.__getattribute__('servicecontents').keys(): 36 return self.__getattribute__('servicecontents')[name] 37 #otherwise behave normally: 38 return self.__getattribute__(name) 39 40 def __init__(self,url,xml): 32 41 self.version='1.1.0' 33 self.url = url 34 self._capabilities = None35 # initialize from saved capability document42 self.url = url 43 # initialize from saved capability document or access the server 44 reader = WCSCapabilitiesReader(self.version) 36 45 if xml: 37 reader = WCSCapabilitiesReader(self.version) 38 self._capabilities = Capabilities(reader.readString(xml)) 39 40 41 def _getcapproperty(self): 42 if not self._capabilities: 43 reader = WCSCapabilitiesReader(self.version) 44 self._capabilities = Capabilities(reader.read(self.url)) 45 return self._capabilities 46 capabilities = property(_getcapproperty, None) 47 48 49 def getcapabilities(self): 50 """Request and return capabilities document from the WMS as a 51 file-like object.""" 52 reader = WCSCapabilitiesReader(self.version) 53 u = urlopen(reader.capabilities_url(self.url)) 54 # check for service exceptions, and return 55 if u.info().gettype() == 'application/vnd.ogc.se_xml': 56 se_xml = u.read() 57 se_tree = etree.fromstring(se_xml) 58 raise ServiceException, \ 59 str(se_tree.find('ServiceException').text).strip() 60 return u 61 62 def _getSupportedCRS110(self,identifier): 46 self._capabilities = reader.readString(xml) 47 else: 48 self._capabilities = reader.read(self.url) 49 50 #build metadata objects: 51 52 #serviceIdentification metadata 53 elem=self._capabilities.find('{http://www.opengis.net/wcs/1.1/ows}ServiceIdentification') 54 self.serviceidentification=ServiceIdentification(elem) 55 56 #serviceProvider 57 elem=self._capabilities.find('{http://www.opengis.net/ows}ServiceProvider') 58 self.serviceprovider=ServiceProvider(elem) 59 60 #serviceOperations 61 self.serviceoperations = [] 62 for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1/ows}OperationsMetadata/{http://www.opengis.net/wcs/1.1/ows}Operation/'): 63 self.serviceoperations.append(Operation(elem)) 64 65 # exceptions - ***********TO DO ************* 66 self.exceptions = [f.text for f \ 67 in self._capabilities.findall('Capability/Exception/Format')] 68 69 # serviceContents: our assumption is that services use a top-level layer 70 # as a metadata organizer, nothing more. 71 self.servicecontents = {} 72 top = self._capabilities.find('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary') 73 for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary/{http://www.opengis.net/wcs/1.1}CoverageSummary'): 74 cm=ContentMetadata(elem, top) 75 #make the describeCoverage requests to populate the supported formats/crs attributes 76 cm.supportedFormats=self._getSupportedFormats(cm.id) 77 cm.supportedCRS=self._getSupportedCRS(cm.id) 78 cm.timelimits=self._getTimes(cm.id) 79 self.servicecontents[cm.id]=cm 80 81 if self.servicecontents=={}: 82 #non-hierarchical. 83 top=None 84 for elem in self._capabilities.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary'): 85 cm=ContentMetadata(elem, top) 86 #make the describeCoverage requests to populate the supported formats/crs attributes 87 cm.supportedFormats=self._getSupportedFormats(cm.id) 88 cm.supportedCRS=self._getSupportedCRS(cm.id) 89 cm.timelimits=self._getTimes(cm.id) 90 self.servicecontents[cm.id]=cm 91 92 def items(self): 93 '''supports dict-like items() access''' 94 items=[] 95 for item in self.servicecontents: 96 items.append((item,self.servicecontents[item])) 97 return items 98 99 100 def _getSupportedCRS(self,identifier): 63 101 # version specific method 64 102 crss=[] … … 68 106 69 107 70 def _getSupportedFormats 110(self,identifier): #maybe can get this from the capabilites doc?108 def _getSupportedFormats(self,identifier): #maybe can get this from the capabilites doc? 71 109 # version specific method 72 110 frmts=[] … … 82 120 return timelimits 83 121 84 def _buildGenericCoverages(self): 85 genericCoverageList=[] 86 for item in self.capabilities.contents: 87 ci = CoverageInfo(identifier=item.identifier, labelordescription=item.title, wgs84bbox=item.WGS84BoundingBox) 88 ci._supCRS=self._getSupportedCRS110 # version specific method 89 ci._supFormats=self._getSupportedFormats110 90 ci._times=self._getTimes 91 genericCoverageList.append(ci) 92 return genericCoverageList 93 94 def _buildGenericProviderInfo(self): 95 pn=self.capabilities.serviceProvider.providerName 96 cn=self.capabilities.serviceProvider.contactName 97 #cp= 98 #ad= 99 #ph= 100 #fx= 101 #em= 102 103 return ProviderInfo(providerName=pn, contactName=cn) 104 105 def _getaddressString(self): 106 #todo 107 address=self.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint 108 return address 109 110 def _buildGenericServiceInfo(self): 111 ''' enables generic interface''' 112 _fees=self.capabilities.serviceIdentification.fees 113 _accessConstraints=self.capabilities.serviceIdentification.accessConstraints 114 _providerName=self.capabilities.serviceProvider.providerName 115 _contactName=self.capabilities.serviceProvider.serviceContact.individualName 116 _contactPosition=self.capabilities.serviceProvider.serviceContact.positionName 117 _addressString=self._getaddressString() 118 _phone=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.voice 119 _fax=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.facsimile 120 _email=self.capabilities.serviceProvider.serviceContact.contactInfo.address.email 121 return ServiceInfo(fees=_fees, accessConstraints=_accessConstraints ,providerName=_providerName, contactName=_contactName,contactPosition=_contactPosition, addressString=_addressString, phone=_phone, fax=_fax, email=_email) 122 123 def getData(self, directory='outputdir', outputfile='coverage.nc', **kwargs): 124 u=self.getCoverageRequest(**kwargs) 125 #create the directory if it doesn't exist: 126 try: 127 os.mkdir(directory) 128 except OSError, e: 129 # Ignore directory exists error 130 if e.errno <> errno.EEXIST: 131 raise 132 #elif wcs.version=='1.1.0': 133 #Could be multipart mime or XML Coverages document, need to use the decoder... 134 decoder=wcsdecoder.WCSDecoder(u) 135 x=decoder.getCoverages() 136 if type(x) is wcsdecoder.MpartMime: 137 filenames=x.unpackToDir(directory) 138 #print 'Files from 1.1.0 service written to %s directory'%(directory) 139 else: 140 filenames=x 141 return filenames 142 143 144 def getCoverageRequest(self, identifier=None, bbox=None, timeSequence=None, format = None, store=None, method='Get',**kwargs): 122 #def _getaddressString(self): 123 ##todo 124 #address=self.capabilities.serviceProvider.serviceContact.contactInfo.address.deliveryPoint 125 #return address 126 127 #def _buildGenericServiceInfo(self): 128 #''' enables generic interface''' 129 #_fees=self.capabilities.serviceIdentification.fees 130 #_accessConstraints=self.capabilities.serviceIdentification.accessConstraints 131 #_providerName=self.capabilities.serviceProvider.providerName 132 #_contactName=self.capabilities.serviceProvider.serviceContact.individualName 133 #_contactPosition=self.capabilities.serviceProvider.serviceContact.positionName 134 #_addressString=self._getaddressString() 135 #_phone=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.voice 136 #_fax=self.capabilities.serviceProvider.serviceContact.contactInfo.phone.facsimile 137 #_email=self.capabilities.serviceProvider.serviceContact.contactInfo.address.email 138 #return ServiceInfo(fees=_fees, accessConstraints=_accessConstraints ,providerName=_providerName, contactName=_contactName,contactPosition=_contactPosition, addressString=_addressString, phone=_phone, fax=_fax, email=_email) 139 140 #repackage? 141 #def getData(self, directory='outputdir', outputfile='coverage.nc', **kwargs): 142 #u=self.getCoverageRequest(**kwargs) 143 ##create the directory if it doesn't exist: 144 #try: 145 #os.mkdir(directory) 146 #except OSError, e: 147 ## Ignore directory exists error 148 #if e.errno <> errno.EEXIST: 149 #raise 150 ##elif wcs.version=='1.1.0': 151 ##Could be multipart mime or XML Coverages document, need to use the decoder... 152 #decoder=wcsdecoder.WCSDecoder(u) 153 #x=decoder.getCoverages() 154 #if type(x) is wcsdecoder.MpartMime: 155 #filenames=x.unpackToDir(directory) 156 ##print 'Files from 1.1.0 service written to %s directory'%(directory) 157 #else: 158 #filenames=x 159 #return filenames 160 161 162 def getCoverage(self, identifier=None, bbox=None, timeSequence=None, format = None, store=None, method='Get',**kwargs): 145 163 """Request and return a coverage from the WCS as a file-like object 146 164 note: additional **kwargs helps with multi-version implementation … … 154 172 if store = true, returns a coverages XML file 155 173 if store = false, returns a multipart mime 156 157 158 174 """ 159 #use fully qualified namespace 175 160 176 if method == 'Get': 161 177 method='{http://www.opengis.net/wcs/1.1/ows}Get' 162 md = self.capabilities 163 base_url = md.getOperationByName('GetCoverage').methods[method]['url'] 178 base_url = self.__getOperationByName('GetCoverage').methods[method]['url'] 164 179 165 180 … … 193 208 return u 194 209 195 class OperationMetadata(object): 210 211 def __getOperationByName(self, name): 212 """Return a named operation item.""" 213 for item in self.serviceoperations: 214 if item.name == name: 215 return item 216 raise KeyError, "No operation named %s" % name 217 218 class Operation(object): 196 219 """Abstraction for operation metadata 197 220 Implements IOperationMetadata. … … 206 229 self.methods = dict(methods) 207 230 208 class ServiceIdentification Metadata(object):231 class ServiceIdentification(object): 209 232 """ Abstraction for ServiceIdentification Metadata 210 233 implements IServiceIdentificationMetadata""" … … 215 238 self.abstract = elem.find('{http://www.opengis.net/ows}Abstract').text 216 239 self.keywords = [f.text for f in elem.findall('{http://www.opengis.net/ows}Keywords/{http://www.opengis.net/ows}Keyword')] 217 self.rights='' #TODO218 240 #self.link = elem.find('{http://www.opengis.net/wcs/1.1}Service/{http://www.opengis.net/wcs/1.1}OnlineResource').attrib.get('{http://www.w3.org/1999/xlink}href', '') 219 241 … … 223 245 224 246 225 class ServiceProvider Metadata(object):247 class ServiceProvider(object): 226 248 """ Abstraction for ServiceProvider metadata 227 249 implements IServiceProviderMetadata """ … … 229 251 self.provider=elem.find('{http://www.opengis.net/ows}ProviderName').text 230 252 self.contact=ServiceContact(elem.find('{http://www.opengis.net/ows}ServiceContact')) 231 self.url='' #URL for provider's web site (string) 253 self.contact='How to contact the service provider (string).' 254 self.url="URL for provider's web site (string)." 232 255 233 256 class Address(object): … … 266 289 267 290 268 class Co verageSummary(object):291 class ContentMetadata(object): 269 292 """Abstraction for WCS CoverageSummary 270 293 """ … … 275 298 self._elem=elem 276 299 self._parent=parent 277 self.id entifier=self._checkChildAndParent('{http://www.opengis.net/wcs/1.1}Identifier')300 self.id=self._checkChildAndParent('{http://www.opengis.net/wcs/1.1}Identifier') 278 301 self.description =self._checkChildAndParent('{http://www.opengis.net/wcs/1.1}Description') 279 302 self.title =self._checkChildAndParent('{http://www.opengis.net/ows}Title') … … 293 316 294 317 295 self. WGS84BoundingBox= None318 self.boundingBoxWGS84 = None 296 319 b = elem.find('{http://www.opengis.net/ows}WGS84BoundingBox') 297 320 if b is not None: 298 321 lc=b.find('{http://www.opengis.net/ows}LowerCorner').text 299 322 uc=b.find('{http://www.opengis.net/ows}UpperCorner').text 300 self. WGS84BoundingBox= (323 self.boundingBoxWGS84 = ( 301 324 float(lc.split()[0]),float(lc.split()[1]), 302 325 float(uc.split()[0]), float(uc.split()[1]), … … 335 358 value = None 336 359 return value 337 338 339 class Capabilities(object): 340 """Abstraction for WCS metadata. 341 342 Implements ICapabilities. 343 """ 344 def __init__(self, infoset): 345 """Initialize from an element tree root element.""" 346 self._root = infoset 347 #need to handle exception report 348 #print infoset.tag 349 #print infoset.text 350 #serviceIdentification 351 elem=self._root.find('{http://www.opengis.net/wcs/1.1/ows}ServiceIdentification') 352 self.serviceIdentification=ServiceIdentification(elem) 353 354 #serviceProvider 355 elem=self._root.find('{http://www.opengis.net/ows}ServiceProvider') 356 self.serviceProvider=ServiceProvider(elem) 357 358 359 # operations [] 360 self.operations = [] 361 for elem in self._root.findall('{http://www.opengis.net/wcs/1.1/ows}OperationsMetadata/{http://www.opengis.net/wcs/1.1/ows}Operation/'): 362 self.operations.append(OperationMetadata(elem)) 363 364 # exceptions - ***********TO DO ************* 365 self.exceptions = [f.text for f \ 366 in self._root.findall('Capability/Exception/Format')] 367 368 # contents: our assumption is that services use a top-level layer 369 # as a metadata organizer, nothing more. 370 self.contents = [] 371 top = self._root.find('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary') 372 for elem in self._root.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary/{http://www.opengis.net/wcs/1.1}CoverageSummary'): 373 self.contents.append(CoverageSummary(elem, top)) 374 if self.contents==[]: 375 #non-hierarchical. 376 top=None 377 for elem in self._root.findall('{http://www.opengis.net/wcs/1.1}Contents/{http://www.opengis.net/wcs/1.1}CoverageSummary'): 378 self.contents.append(CoverageSummary(elem, top)) 379 380 # contact person TODO 381 #self.provider = ContactMetadata(self._root.find('Service/ContactInformation')) 382 383 384 def getOperationByName(self, name): 385 """Return a named operation item.""" 386 for item in self.operations: 387 if item.name == name: 388 return item 389 raise KeyError, "No operation named %s" % name 360 361 362 OWSLib/branches/wcstemp/owslib/coverage/wcsBase.py
r1019 r1023 32 32 def __init__(self): 33 33 pass 34 35 def _getGenCovListProperty(self): 36 '''genericCoverages attribute is used to hold a list of CoverageInfo objects which are generic and independent of the WCS version. As a result of this they may be lossy compared to interrogating the version specific capabilities document, but they serve the purpose of providing a uniform view of different WCS versions ''' 37 if not hasattr(self, '_genericCoverages'): 38 self._genericCoverages=self._buildGenericCoverages() 39 return self._genericCoverages 40 genericCoverages=property(_getGenCovListProperty, None) 41 42 43 def _getGenServiceProperty(self): 44 '''genericService attribute is used to hold a list of non-version specific info about the service ''' 45 if not hasattr(self, '_genericService'): 46 self._genericService=self._buildGenericServiceInfo() 47 return self._genericService 48 serviceInfo=property(_getGenServiceProperty, None) 49 50 def _buildGenericCoverages(self): 51 ''' must be overridden to provide enable generic interface''' 52 return [] 53 54 def _buildGenericProviderInfo(self): 55 ''' must be overridden to provide enable generic interface''' 56 return ProviderInfo() 57 58 59 def _buildGenericServiceInfo(self): 60 ''' must be overridden to provide enable generic interface''' 61 return ServiceInfo() 62 63 64 #def listCoverages(self): 65 #''' returns a dictionary contining the {id, name} values for each coverageSummary''' 66 #coverages={} 67 #for item in self.genericCoverages: 68 #coverages[item.identifier]=item.labelordescription 69 #return coverages 70 71 def getCvgByIdentifier(self,identifier): 72 ''' returns a version independent coverage object ''' 73 for item in self.genericCoverages: 74 if item.identifier == identifier: 75 return item 76 raise KeyError, "No coverage summary with identifier %s" %identifier 77 78 def getCvgByLabel(self,label): 79 ''' returns a version independent coverage object ''' 80 for item in self.genericCoverages: 81 if item.labelordescription == label: 82 return item 83 raise KeyError, "No coverage summary with label %s" %label 84 34 85 35 def getDescribeCoverage(self,identifier): 86 36 reader = DescribeCoverageReader(self.version, identifier) … … 203 153 u = urlopen(request) 204 154 return etree.fromstring(u.read()) 205 206 155 207 208 class CoverageInfo(object):209 '''' Information about a coverage, not tied to any particular WCS version '''210 def __init__(self, identifier= None, labelordescription=None, wgs84bbox=None, otherbbox=None, _timeLimits=None):211 self.identifier=identifier212 self.labelordescription=labelordescription213 self.wgs84bbox=wgs84bbox214 self.otherbbox=otherbbox215 self._timeLimits=_timeLimits216 self._supCRS=lambda(i):None217 self._supFormats=lambda(i):None218 219 def getSupportedCRS(self):220 '''the supCRS method should be altered by the calling object so that the correct value is returned. This will probably require a DescribeCoverage request, which is version specific '''221 return self._supCRS(self.identifier)222 223 def getSupportedFormats(self):224 '''the supFormats method should be altered by the calling object so that the correct value is returned. This will probably require a DescribeCoverage request, which is version specific '''225 return self._supFormats(self.identifier)226 227 def getTimeLimits(self):228 if not self._timeLimits:229 try:230 return self._times(self.identifier) #some versions (eg 1.1.0) may require a describe coverage request to get time limits231 except:232 return None233 else:234 return self._timeLimits#others (eg 1.0.0) may have retrieved it from the original getcapabilites requests235 236 supportedCRS=property(getSupportedCRS, None)237 supportedFormats=property(getSupportedFormats, None)238 timeLimits=property(getTimeLimits, None)239 240 241 class ServiceInfo(object):242 '''' Information about the service available and the provider, not tied to any particular WCS version '''243 def __init__(self, fees=None, accessConstraints=None, providerName=None,contactName=None,contactPosition=None,addressString=None,phone=None,fax=None,email=None):244 self.fees=fees245 self.accessConstraints=accessConstraints246 self.providerName=providerName247 self.contactName=contactName248 self.contactPosition=contactPosition249 self.addressString=addressString250 self.phone=phone251 self.fax=fax252 self.email=email253 156 254 157 class RereadableURL(StringIO, object): OWSLib/branches/wcstemp/owslib/coverage/wcsdecoder.py
r1019 r1023 12 12 #u=wcs.getcoverage(identifier=['TuMYrRQ4'], timeSequence=['2792-06-01T00:00:00.0'], bbox=(-112,36,-106,41),format='application/netcdf', store='true') 13 13 #decoder=wcsdecoder.WCSDecoder(u) 14 # print decoder.getCoveragePaths()14 #decoder.getCoverages() 15 15 16 16 import os … … 18 18 import email 19 19 import errno 20 21 22 20 23 21 class WCSDecoder(object): … … 39 37 40 38 41 def getCoverages(self ):39 def getCoverages(self, unpackdir='./unpacked'): 42 40 if self.urlType=='XML': 43 41 paths=[] … … 46 44 for ref in u_tree.findall('{http://www.opengis.net/wcs/1.1}Coverage/{http://www.opengis.net/wcs/1.1}Reference'): 47 45 path = ref.attrib['{http://www.w3.org/1999/xlink}href'] 48 paths.append(path) 49 return paths 46 paths.append(path) 50 47 elif self.urlType=='Multipart': 51 48 #Decode multipart mime and return fileobjects 52 49 u_mpart=self.u.read() 53 return MpartMime(u_mpart) 54 50 mpart =MpartMime(u_mpart) 51 paths= mpart.unpackToDir(unpackdir) 52 return paths 55 53 56 54 class MpartMime(object): OWSLib/branches/wcstemp/owslib/interfaces.py
r954 r1023 10 10 version = property("""Protocol version (string)""") 11 11 capabilities = property("""Implementation of IServiceMetadata (object)""") 12 13 12 #remove capabilities? 13 14 14 class IWebMapService(IService): 15 15 """Abstraction for an OGC Web Map Service (WMS). … … 61 61 abstract = property("""Text describing the service (string).""") 62 62 keywords = property("""Keyword list (list).""") 63 rights = property("""Explanation of rights associated with service (string).""") 63 accessconstraints = property("""Explanation of access constraints associated with service (string).""") 64 fees = property("""Explanation of fees associated with service (string).""") 64 65 65 66 OWSLib/branches/wcstemp/tests/wcs_newiface.txt
r1020 r1023 2 2 ==================== 3 3 4 Version 1.0.0 5 ======== 6 4 7 >>> from owslib.wcs import WebCoverageService 5 8 >>> wcs=WebCoverageService('http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc', version='1.0.0') 9 >>> wcs.url 10 'http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc' 11 >>> wcs.version 12 '1.0.0' 13 >>> wcs.serviceidentification.service 14 'WCS' 15 >>> wcs.serviceidentification.version 16 '1.0.0' 17 >>> wcs.serviceidentification.title 18 'BADC OGC WCS Server' 19 >>> wcs.serviceidentification.abstract 20 '\n Web Map Server maintained by BADC\n Contact: webmaster@badc.nerc.ac.uk ' 21 >>> wcs.serviceidentification.keywords 22 ['atmospheric', 'climate'] 23 >>> wcs.serviceidentification.fees 24 'NONE' 25 >>> wcs.serviceidentification.accessConstraints 26 'NONE' 6 27 >>> wcs.serviceprovider.provider 7 28 'British Atmospheric Data Centre' … … 33 54 >>> f.write(output.read()) 34 55 >>> f.close() 56 57 Version 1.1.0 58 ======== 59 >>> from owslib.coverage import wcsdecoder 60 >>> wcs=WebCoverageService('http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc', version='1.1.0') 61 >>> wcs.url 62 'http://ndgbeta.badc.rl.ac.uk/wcs/badc.nerc.ac.uk__NDG-A0__AWQX8gTc' 63 >>> wcs.version 64 '1.1.0' 65 >>> wcs.serviceidentification.service 66 'WCS' 67 >>> wcs.serviceidentification.version 68 '1.1.0' 69 >>> wcs.serviceidentification.title 70 'BADC OGC WCS Server' 71 >>> wcs.serviceidentification.abstract 72 '\n Web Map Server maintained by BADC\n Contact: webmaster@badc.nerc.ac.uk ' 73 >>> wcs.serviceidentification.keywords 74 ['atmospheric', 'climate'] 75 >>> wcs.serviceidentification.fees 76 'NONE' 77 >>> wcs.serviceidentification.accessConstraints 78 'NONE' 79 >>> wcs.serviceprovider.provider 80 'British Atmospheric Data Centre' 81 >>> wcs.serviceprovider.url 82 "URL for provider's web site (string)." 83 >>> wcs.serviceprovider.contact 84 'How to contact the service provider (string).' 85 >>> type(wcs.items()) 86 <type 'list'> 87 >>> cvg=wcs['ZI4al0r8'] 88 >>> cvg.title 89 'Vapour pressure' 90 >>> cvg.keywords 91 ['NONE', 'NONE'] 92 >>> wcs.serviceidentification.accessConstraints 93 'NONE' 94 >>> wcs.serviceidentification.fees 95 'NONE' 96 >>> cvg.boundingBoxWGS84 97 (1.875, -88.767123287700002, 358.125, 88.767123287700002) 98 >>> cvg.timelimits 99 ['2024-01-15', '2054-12-15'] 100 >>> cvg.supportedFormats 101 ['cf-netcdf'] 102 >>> cvg.supportedCRS 103 ['srstba'] 104 105 GetCoverage returning Multipart Mime: 106 >>> output=wcs.getCoverage(identifier='ZI4al0r8',timeSequence=['2024-01-15T00:00:00.0'],bbox=(-80,30,50,60), format='cf-netcdf', store='false') 107 108 Need to use the decoder class to handle 1.1.0 type outputs 109 (coverages xml docs or multipart mime) 110 -------------------------------------------------------------------------------------------- 111 >>> decoder=wcsdecoder.WCSDecoder(output) 112 >>> decoder.getCoverages(unpackdir='mydir') 113 ['mydir/coverage.xml', 'mydir/coverage.nc'] 114 115 GetCoverage returning Coverages.xml: 116 >>> output=wcs.getCoverage(identifier='ZI4al0r8',timeSequence=['2024-01-15T00:00:00.0'],bbox=(-80,30,50,60), format='cf-netcdf', store='true') 117 118 Use the decoder class to extract the url from the coverages doc. 119 -------------------------------------------------------------------------------------------- 120 121 >>> decoder2=wcsdecoder.WCSDecoder(output) 122 >>> outputurl= decoder2.getCoverages() 123 >>> outputurl[0][:7] 124 'http://' 125 126 127 128 129
