Vanity package for geopython projects
pip install geopython
>>> import geopython
OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
Home Page: https://owslib.readthedocs.io
License: BSD 3-Clause "New" or "Revised" License
Vanity package for geopython projects
pip install geopython
>>> import geopython
Here is a sample snippet that does this outside of OWSLib.
{{{
descCov=metadata._service.getDescribeCoverage(projected_tif.typename)
envelope = descCov.find(ns('CoverageOffering/')+ns('domainSet/')+ns('spatialDomain/')+'{http://www.opengis.net/gml}Envelope')
nativeSrs = envelope.attrib['srsName']
logger.info(nativeSrs)
gmlpositions=envelope.findall('{http://www.opengis.net/gml}pos')
lc=gmlpositions[0].text
uc=gmlpositions[1].text
bboxNative = (
float(lc.split()[0]),float(lc.split()[1]),
float(uc.split()[0]), float(uc.split()[1]),
)
logger.info(bboxNative)
}}}
I've been working on a simple csw client to hit our CSW server. We use ISO19139 metadata that has multiple srv_Serviceidentification sections. Looking at line 85 through 96 of iso.py, it appears that MD_DataIdentification and SV_ServiceIdentification will only get parsed once for one or the other.
A chunk of code to return title, abstract, and a url list is pasted below. Note that if you set "anyText" to 'nlcd', this code works because that record puts the urls of interest in the distributioninfo section. Setting "anyText" to 'gmo' returns a record that does not return any urls because of the use of both MD_DataIndentification and SV_ServiceIdentification.
This might be a quick fix, it looks like the SV_ServiceIdentification class would be parsed to get at our needs if the parser for MD_MetaData tried to go in there. Ideas?
from owslib.csw import CatalogueServiceWeb
def getDataSetURI(anyText='gmo',CSWURL='http://cida.usgs.gov/gdp/geonetwork/srv/en/csw',BBox=None):
"""
Searches a given CSW server and returns metadata content for the datasets found.
Arguments
---------
- CSWURL - A base URL for the CSW server to be searched. (Optional, defaults to the CDIA/GDP CSW server.)
- anyText - A string that will be submitted to the CSW search. (Optional, deafualt is empty which will return all records.)
- BBox - A bounding box in WGS84 lat/lon that will be used to limit results to datasets that atleast partially intersect. (Optional)
"""
csw = CatalogueServiceWeb(CSWURL)
csw.getrecords(keywords=[anyText], outputschema='http://www.isotc211.org/2005/gmd', esn='full')
dataSetURIs = [['title','abstract',['urls']]]
for rec in csw.records:
title=csw.records[rec].identification.title
abstract=csw.records[rec].identification.abstract
urls=[]
for onlineresource in range(len(csw.records[rec].distribution.online)):
urls.append(csw.records[rec].distribution.online[onlineresource].url)
# Should be another loop here that goes through all urls in the serviceidentification section of a metadata record as well.
entry=[title,abstract,urls]
dataSetURIs.append(entry)
return dataSetURIs
dataseturis=getDataSetURI(anyText='gmo')
dataseturis
requirements.txt lists python-dateutil==2.1
but according to the maintainer's site [1]:
If you need dateutil for Python 2.X, please continue using the 1.X series.
Is OWSLib targeting python 3?
We found out about this due to conflicts with CKAN when importing OWSLib as a requirement. Happy to provide a PR but not sure which version do you guys want to target.
[1] http://labix.org/python-dateutil#head-b57873b28af6ab8b1c4ae48d522ce0c691abbdf2
Similar to #76, send GET request instead.
When the WMS server returns an error, this error is raised:
{{{
'NoneType' attribute has no element 'Name'
}}}
Instead a proper exception being raised. The attached patch makes sure the exception is properly raised.
WFS 1.0.0 does not read the keywords, this patch fixes that.
The spec is unclear as to what the text content of the Extent element should be when there is no data. Geoserver responds in this case with an empty element. wms.py does not check for this case.
The following diff illustrates a fix:
438,439c438
< if extent.text:
self.timepositions=extent.text.split(',')
Some of the changes are possible to do automatically with 2to3: http://pythonhosted.org/distribute/python3.html. I already tried that and manually tested some features. Some parts works but there is still code which doesn't work.
Blockers:
When running tests setup.py loads modules from source directory instead of build directory. Explained and fixed in: http://www.hackzine.org/python-testing-with-pytest-and-2to3-plus-tox-and-travis-ci.html. Anyone familiar enough with (2to3, )test.py and doctests to fix this?
None
Was testing out some CSW calls that parse various xml files. I found an error regarding a "missing" field with a nilReason tag. Not sure exactly what the hangup is, but I've attached two files. One with and one without the empty tag.
Do
from lxml import etree
from owslib.iso import MD_Metadata
md = MD_Metadata(etree.parse('nlcd.xml'))
to reproduce. There is also a file at nlcd.xml that does not have the empty purpose element that parses fine.
I'm fine removing the element rather than leaving it empty, but figured you'd want to know, I think a nillreason and empty tag is valid, atleast Oxygen thinks it is.
Example files are here: ftp://ftpext.usgs.gov/pub/er/wi/middleton/dblodgett/example_iso_files/
cc @kwilcox
FYI when pushing to pypi with python setup.py sdist upload
, requirements.txt
does not get included.
This causes a build error when doing pip install OWSLib
because setup.py
sets install_requires
by reading requirements.txt
:
(foo)tkralidi@www:/tmp/OWSLib$ pip install OWSLib
Downloading/unpacking OWSLib
Running setup.py egg_info for package OWSLib
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/tkralidi/work/foss4g/pycsw/pycsw-master/build/OWSLib/setup.py", line 17, in <module>
reqs = [line.strip() for line in open('requirements.txt')]
IOError: [Errno 2] No such file or directory: 'requirements.txt'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/tkralidi/work/foss4g/pycsw/pycsw-master/build/OWSLib/setup.py", line 17, in <module>
reqs = [line.strip() for line in open('requirements.txt')]
IOError: [Errno 2] No such file or directory: 'requirements.txt'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/tkralidi/work/foss4g/pycsw/pycsw-master/build/OWSLib
Storing complete log in /home/tkralidi/.pip/pip.log
Options:
install_requires
requirements.txt
is added when doing python setup.py sdist upload
I will do the first option now as this is a blocker, but it would be neat to have requirements.txt
be included and thus read as intended.
I've been debugging an owslib-using application. WMS getcapabilities doesn't work in the 1.3.0 version because of the way owslib queries the xml file with etree:
Traceback (most recent call last):
...
self.type = self._root.find('Name').text
AttributeError: 'NoneType' object has no attribute 'find'
self._root
is None because it is a query for .find('Service'), which does find the service tag for 1.1.1, but in 1.3.0 it is a fully namespaced xml file. Only
.find('{http://url.to.wms.namespace/}Service')` now finds the Service tag...
I don't know if there are other changes in the 1.3.0 format, but this is at least a python-level thing that needs fixing before the actual format changes can be taken into account.
(Possible solution: some wrapper function that does the 'find' which adds the namespace? A small function to add the namespace to the string?)
Per #60, implementation owslib.csw.getrecords2
to cover what owslib.csw.getrecords
does, then deprecate owslib.csw.getrecords
This patch will be commited on http://svn.gispython.org/svn/gispy/OWSLib/trunk but it will be probably lost in the migration...
Original message:
Hello,
using OWSLib's WebMapService, one may browse the details of a WMS
layer (see [1]).
I notice that the element is not supported (see [2])
whereas it is defined as an optional child element of in the
WMS GetCapabilities specifications.
The attached patch adds the support of MetadataURL. Would it be useful
to create a ticket and join this patch? If yes, what is the procedure
to do so?
Best regards,
Alexandre
[1] http://gispython.org/owslib/docs/en/trunk/#wms
[2] http://trac.gispython.org/lab/browser/OWSLib/trunk/owslib/wms.py#L303
line 410: self.crsOptions=None
if that's a parent, in the child layer,
self.crsOptions = list(self.parent.crsOptions)
blows up.
line 410 should be self.crsOptions = []
A potential solution is to remove the tests directory from the debian package as described here:
6b9aedb#L1R14 introduced the register_namespace
function, which is only available on lxml>=2.3
. I know this is quite an old version, but for the poor guys (like me) working with old versions of lxml it'd be good to have the lxml version requirement listed somewhere.
When the getrecords procedure is called (from pyGDP) a deprecation warning is printed and then the program exits instead of continuing execution.
It would be very nice feature for OWSlib to have WPS client support. I will investigate this a bit further.
I am no expert with git, but the given command does not work for me. Here is a patch with a working version ;)
diff --git a/docs/en/index.rst b/docs/en/index.rst index 093337a..d6103dc 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -80,7 +80,7 @@ Git: .. code-block:: bash - $ git clone [email protected]:geopython/OWSLib.git + $ git clone git://github.com/geopython/OWSLib.git openSUSE:
Per http://lists.gispython.org/pipermail/community/2011-April/002959.html. Patch attached.
This getCapabilities File generated by ArcGIS Server 9.3.1 contains nested Layer definitions, where the non-queryable layers don't have a name.
owslib does not allow to get a valid list of layernames out of this getcapabilities response.
there are several issues: 1) the layer-reading should be fully recursive 2) if the layer has got no name defined, there is a problem in the dictionary, as the id is set to the name and thus the layer is not correctly inserted into the dictionnary.
As discussed on mailing list, add support for OGC SOS 1.0.0. Notes:
I've started working on this.
Handle geometries with respect to axis order as specified by a given CRS URN, in the spirit of http://svn.osgeo.org/mapserver/trunk/mapserver/mapaxisorder.csv
tests/wfs2_ndg3betaPSeries.txt
tests/wfs2_ndg3betaGrid.txt
are containg not existing services
http://ndg3beta.badc.rl.ac.uk/cows/demo_hadcm3/wfs
http://ndg3beta.badc.rl.ac.uk/cows/mst_sample/wfs?
Proposal: fix or remove
Author of the file is Dominik Loewe
Current support for WFS 2.0.0 is very bad. We need to fix that.
@bradh can you take a look in latest master at the WMTS tests? I get the following test issues:
$ py.test tests/doctests/wmts*
================================================================================ test session starts ================================================================================
platform linux2 -- Python 2.7.3 -- pytest-2.3.5
plugins: cov
collected 6 items
tests/doctests/wmts_EOSDISWMTSCapabilities.txt .
tests/doctests/wmts_ERDAS13WMTSCapabilities.txt F
tests/doctests/wmts_ERDASWMTSCapabilities.txt F
tests/doctests/wmts_geoserver21.txt .
tests/doctests/wmts_SFSWorldWMTSCapabilities.txt .
tests/doctests/wmts.txt .
===================================================================================== FAILURES ======================================================================================
_____________________________________________________________________________________ [doctest] _____________________________________________________________________________________
071 'ogc:1.0:googlemapscompatible'
072 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].crs
073 'urn:ogc:def:crs:EPSG:6.18:3:3857'
074 >>> sorted(wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix.keys())
075 ['0', '1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '2', '3', '4', '5', '6', '7', '8', '9']
076 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].identifier
077 '0'
078 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].scaledenominator
079 559082264.0287178
080 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].topleftcorner
Expected:
(20037508.34279, -20037508.34279)
Got:
(-20037508.34279, 20037508.34279)
/home/tkralidi/work/foss4g/OWSLib/OWSLib/tests/doctests/wmts_ERDAS13WMTSCapabilities.txt:80: DocTestFailure
_____________________________________________________________________________________ [doctest] _____________________________________________________________________________________
071 'ogc:1.0:googlemapscompatible'
072 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].crs
073 'urn:ogc:def:crs:EPSG:6.18:3:3857'
074 >>> sorted(wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix.keys())
075 ['0', '1', '10', '11', '12', '13', '14', '15', '16', '17', '18', '2', '3', '4', '5', '6', '7', '8', '9']
076 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].identifier
077 '0'
078 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].scaledenominator
079 559082264.0287178
080 >>> wmts.tilematrixsets['ogc:1.0:googlemapscompatible'].tilematrix['0'].topleftcorner
Expected:
(20037508.34279, -20037508.34279)
Got:
(-20037508.34279, 20037508.34279)
/home/tkralidi/work/foss4g/OWSLib/OWSLib/tests/doctests/wmts_ERDASWMTSCapabilities.txt:80: DocTestFailure
======================================================================== 2 failed, 4 passed in 3.09 seconds =========================================================================
(OWSLib)tkralidi@www:~/work/foss4g/OWSLib/OWSLib$
Would it be possible to push the latest version to PyPI?
pyioos
has a dependency on the owslib.namespace
, so pip install pyoos
isn't currently working.
ioos/pyoos#9
Dear,
I was doing several tests and I got this error:
wms = WebMapService('http://frameworkwfs.usgs.gov/framework/wms/wms.cgi')
Traceback (most recent call last):
File "", line 1, in
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 86, in init
self._buildMetadata(parse_remote_metadata)
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 126, in _buildMetadata
gather_layers(caps, None)
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 120, in gather_layers
cm = ContentMetadata(elem, parent=parent_metadata, index=index+1, parse_remote_metadata=parse_remote_metadata)
File "/srv/virtualenvs/fm/local/lib/python2.7/site-packages/owslib/wms.py", line 327, in init
self.queryable = int(elem.attrib.get('queryable', 0))
ValueError: invalid literal for int() with base 10: 'false'
OWSLib==0.7.2
Using QGis the service works.
Thanks!
D
Testing trace and repository version are listed below. Diff file correcting this issue is attached.
Tested using: Python 2.6.4
{{{
$ svn info
Path: .
URL: http://svn.gispython.org/svn/gispy/OWSLib/trunk
Repository Root: http://svn.gispython.org/svn/gispy
Repository UUID: b426a367-1105-0410-b9ff-cdf4ab011145
Revision: 1675
Node Kind: directory
Schedule: normal
Last Changed Author: domlowe
Last Changed Rev: 1675
Last Changed Date: 2010-09-02 05:10:13 -0600 (Thu, 02 Sep 2010)
}}}
Traceback (most recent call last):
File "/usr/lib/python2.6/doctest.py", line 2145, in runTest
raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for wms_JPLCapabilities.txt
File "/usr/local/OWSLib/trunk/tests/wms_JPLCapabilities.txt", line 0
File "/usr/local/OWSLib/trunk/tests/wms_JPLCapabilities.txt", line 57, in wms_JPLCapabilities.txt
Failed example:
wms.contents.keys()
Expected:
['us_landsat_wgs84', 'modis', 'global_mosaic_base',
'huemapped_srtm', 'srtm_mag', 'daily_terra', 'us_ned',
'us_elevation', 'global_mosaic', 'daily_terra_ndvi',
'daily_aqua_ndvi', 'daily_aqua_721', 'daily_aqua', 'BMNG',
'srtmplus', None, 'us_colordem', 'worldwind_dem', 'daily_terra_721']
Got:
[None, 'us_landsat_wgs84', 'global_mosaic_base',
'huemapped_srtm', 'srtm_mag', 'daily_terra', 'modis',
'us_elevation', 'global_mosaic', 'daily_terra_ndvi',
'daily_aqua_ndvi', 'daily_aqua_721', 'daily_aqua', 'BMNG',
'srtmplus', 'us_colordem', 'worldwind_dem', 'us_ned',
'daily_terra_721']
Ran 13 tests in 223.622s
FAILED (failures=1)
}}}
The specification (http://www.isotc211.org/2005/gmd/identification.xsd) states that various <gmd:extent>
elements may be present:
<xs:element
name="extent"
type="gmd:EX_Extent_PropertyType"
minOccurs="0"
maxOccurs="unbounded"
/>
for example, as defined in the <gmd:extent>
specification (http://www.isotc211.org/2005/gmd/extent.xsd), both temporal extent and BoundingBox extent may be present.
Using the owslib.iso
parser, it seems to be only possible to get one of these <gmd:extent>
elements, the other ones being discarded.
Test with http://geo.gob.bo/geonetwork/srv/es/iso19139.xml?id=171 for example. Download it to /tmp/test.xml
and parse with
from owslib.iso import *
m=MD_Metadata(etree.parse('/tmp/test.xml'))
The two temporal extent fields are filled:
m.identificationinfo[0].temporalextent_start
value is '2006-01-15T18:08:00'
m.identificationinfo[0].temporalextent_end
value is '2006-12-30T18:09:00'
but the BoundingBox field is empty
m.identificationinfo[0].bbox is None
or m.identificationinfo[0].extent.boundingBox is None
give True
whereas it is not in the metadata XML file:
<gmd:extent>
<gmd:EX_Extent>
<gmd:geographicElement>
<gmd:EX_GeographicBoundingBox>
<gmd:westBoundLongitude>
<gco:Decimal>-69.6562</gco:Decimal>
</gmd:westBoundLongitude>
<gmd:eastBoundLongitude>
<gco:Decimal>-57.5211</gco:Decimal>
</gmd:eastBoundLongitude>
<gmd:southBoundLatitude>
<gco:Decimal>-22.9011</gco:Decimal>
</gmd:southBoundLatitude>
<gmd:northBoundLatitude>
<gco:Decimal>-9.6792</gco:Decimal>
</gmd:northBoundLatitude>
</gmd:EX_GeographicBoundingBox>
</gmd:geographicElement>
</gmd:EX_Extent>
</gmd:extent>
I'm using the latest OWSlib code (code that fixed issue 78), and still getting an error getting records from this CSW. Note sure if this is an OWSLib problem or a provider problem:
from owslib.csw import CatalogueServiceWeb
endpoint = 'http://cwic.csiss.gmu.edu/cwicv1/discovery'
csw = CatalogueServiceWeb(endpoint,timeout=60)
csw.getrecords2(maxrecords=2)
gives this error:
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
<ipython-input-7-3cf19d5d4035> in <module>()
----> 1 csw.getrecords2(maxrecords=2)
C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\lib\site-packages\owslib-0.7_dev-py2.7.egg\owslib\csw.pyc in getrecords2(self, constraints, sortby, typenames, esn, outputschema, format, startposition, maxrecords, cql, xml, resulttype)
339 self.request = node0
340
--> 341 self._invoke()
342
343 if self.exceptionreport is None:
C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\lib\site-packages\owslib-0.7_dev-py2.7.egg\owslib\csw.pyc in _invoke(self)
573 self.request = util.xml2string(etree.tostring(self.request))
574
--> 575 self.response = util.http_post(self.url, self.request, self.lang, self.timeout)
576
577 # parse result see if it's XML
C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\lib\site-packages\owslib-0.7_dev-py2.7.egg\owslib\util.pyc in http_post(url, request, lang, timeout)
285
286 try:
--> 287 up = urllib2.urlopen(r,timeout=timeout);
288 except TypeError:
289 import socket
C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in urlopen(url, data, timeout)
124 if _opener is None:
125 _opener = build_opener()
--> 126 return _opener.open(url, data, timeout)
127
128 def install_opener(opener):
C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in open(self, fullurl, data, timeout)
404 for processor in self.process_response.get(protocol, []):
405 meth = getattr(processor, meth_name)
--> 406 response = meth(req, response)
407
408 return response
C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in http_response(self, request, response)
517 if not (200 <= code < 300):
518 response = self.parent.error(
--> 519 'http', request, response, code, msg, hdrs)
520
521 return response
C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in error(self, proto, *args)
442 if http_err:
443 args = (dict, 'default', 'http_error_default') + orig_args
--> 444 return self._call_chain(*args)
445
446 # XXX probably also want an abstract factory that knows when it makes
C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in _call_chain(self, chain, kind, meth_name, *args)
376 func = getattr(handler, meth_name)
377
--> 378 result = func(*args)
379 if result is not None:
380 return result
C:\Users\rsignell\AppData\Local\ENTHOU~1\Canopy32\App\appdata\canopy-1.0.3.1262.win-x86\lib\urllib2.pyc in http_error_default(self, req, fp, code, msg, hdrs)
525 class HTTPDefaultErrorHandler(BaseHandler):
526 def http_error_default(self, req, fp, code, msg, hdrs):
--> 527 raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
528
529 class HTTPRedirectHandler(BaseHandler):
HTTPError: HTTP Error 500: Internal Server Error
Add support for http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification
http://geopython.github.io/OWSLib
is reporting:
Error 503 Backend is unhealthy
Backend is unhealthy
Guru Meditation:
XID: 2411363103
Varnish cache server
See patch submitted by Servais Nabil
I would like to suggest 2 patchs. The first is for supporting custom parameters of WMS, I don't know if it's normalize by OGC, but it's supported by Mapserver.
For exemple I have this request in openlayers:
url_wms = ' http://wmshost/cgi-bin/xyea' layers = [ 'oursindep', 'etablissement', 'responsables_legaux', 'regions']
bbox = (-10.900634765625, 36.857250976562, 15.400634765625, 55.742749023437)
styles = custom = {'WHERECLAUSE':'WHERE secteur_code = 1',
'GROUPBYCLAUSE':'GROUP BY uai_dger',
'IDOURSIN':'uai_dgerinsee_resplegal filiere_codesecteur_pro_codeoption_code'}
img = wms.getmap(layers=layers,
styles=styles, bbox=bbox,
size=(1197, 859),
format='image/jpeg', srs='EPSG:4326', custom = custom )
Alternatively, could use the same implementation as WCS. To decide.
for example,
< Abstract />
Traceback (most recent call last):
File "/home/admin/morges/buildout/eggs/c2cgeoportal-1.2-py2.6.egg/c2cgeoportal/views/entry.py", line 37, in _wms_getcap
wms = WebMapService(url, version='1.1.1')
File "/home/admin/morges/OWSLib/owslib/wms.py", line 86, in init
self._buildMetadata(parse_remote_metadata)
File "/home/admin/morges/OWSLib/owslib/wms.py", line 126, in _buildMetadata
gather_layers(caps, None)
File "/home/admin/morges/OWSLib/owslib/wms.py", line 120, in gather_layers
cm = ContentMetadata(elem, parent=parent_metadata, index=index+1, parse_remote_metadata=parse_remote_metadata)
File "/home/admin/morges/OWSLib/owslib/wms.py", line 489, in init
self.layers.append(ContentMetadata(child, self))
File "/home/admin/morges/OWSLib/owslib/wms.py", line 340, in init
self.abstract = testXMLValue(elem.find('Abstract'))
File "/home/admin/morges/OWSLib/owslib/util.py", line 148, in testXMLValue
return val.text.strip()
[Fri Dec 07 12:18:50 2012] [error] AttributeError: 'NoneType' object has no attribute 'strip'
When I try to open NASA's CWIC CSW endpoint:
http://cwic.csiss.gmu.edu/cwicv1/discovery
listed at on the CEOS CWIC page, I get an error:
endpoint = 'http://cwic.csiss.gmu.edu/cwicv1/discovery' # CWIC
csw = CatalogueServiceWeb(endpoint,timeout=60)
ExceptionReport: 'REQUEST_EXCEPTION: UNRECOGNIZED_REQUEST - Only GetRecords and GetRecordById supported for HTTP POST method.'
I'm guessing this isn't really an OWSlib issue, but more a provider issue, right?
Can you tell what the CWIC folks would need to fix to have OWSlib work with this CSW?
Thanks,
Rich
The getmap method is limited in not allowing extra parameters when asking the wms server.
Currently, XML library loading in owslib is wrapped in [https://sourceforge.net/apps/trac/owslib/browser/trunk/owslib/etree.py owslib/etree.py], which sets the appropriate library according to what the wrapper finds for python XML libs via try/except with imports. Calling modules always see owslib.etree as a result.
The current behaviour of [https://sourceforge.net/apps/trac/owslib/browser/trunk/owslib/etree.py owslib/etree.py] is as follows:
I propose we reverse this order so that lxml.etree is looked for first, then xml.etree.!ElementTree, then elementtree.!ElementTree. This would ensure that lxml.etree would be loaded first to take advantage of features of lxml (which may not be in owslib, but the calling app[s] use/call), and elementtree.!ElementTree would be called as the last resort.
See patch submitted by Servais Nabil
I would like to suggest 2 patchs. The first is for supporting custom parameters of WMS, I don't know if it's normalize by OGC, but it's supported by Mapserver.
For exemple I have this request in openlayers:
url_wms = ' http://wmshost/cgi-bin/xyea' layers = [ 'oursindep', 'etablissement', 'responsables_legaux', 'regions']
bbox = (-10.900634765625, 36.857250976562, 15.400634765625, 55.742749023437)
styles = custom = {'WHERECLAUSE':'WHERE secteur_code = 1',
'GROUPBYCLAUSE':'GROUP BY uai_dger',
'IDOURSIN':'uai_dgerinsee_resplegal filiere_codesecteur_pro_codeoption_code'}
img = wms.getmap(layers=layers,
styles=styles, bbox=bbox,
size=(1197, 859),
format='image/jpeg', srs='EPSG:4326', custom = custom )
Alternatively, could use the same implementation as WCS. To decide.
Currently as described in #5 it seems that SOS get_records requires an XML response, and a request for a non-XML response, such as the "text/csv" response below, fails:
from owslib.sos import SensorObservationService
sos_endpoint = 'http://opendap.co-ops.nos.noaa.gov/ioos-dif-sos/SOS?service=SOS&request=GetCapabilities&version=1.0.0'
coops = SensorObservationService(sos_endpoint)
print coops.get_operation_by_name('getobservation').parameters['responseFormat']['values']
returns
['text/csv',
'text/tab-separated-values',
'text/xml;schema="ioos/0.6.1"',
'application/ioos+xml;version=0.6.1',
'application/vnd.google-earth.kml+xml']
but then
response = coops.get_observation(offerings=['urn:ioos:station:NOAA.NOS.CO-OPS:8447930'],
responseFormat='text/csv',
observedProperties=['water_surface_height_above_reference_datum'],
eventTime='2013-06-13T00:00:00Z/2013-06-14T00:00:00Z')
returns
File "<string>", line unknown
XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1
Before parsing it as a valid GetCapabilities record.
Using owslib 0.5 installed from pypi.
File "/home/tkralidi/geonode/geonode/layers/models.py", line 650, in geoserver_post_save
links = wcs_links(settings.GEOSERVER_BASE_URL + 'wcs?', instance.typename)
File "/home/tkralidi/geonode/geonode/layers/ows.py", line 15, in wcs_links
wcs = WebCoverageService(wcs_url, version=version)
File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/wcs.py", line 39, in WebCoverageService
return wcs100.WebCoverageService_1_0_0.__new__(wcs100.WebCoverageService_1_0_0, url, xml, cookies)
File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/coverage/wcsBase.py", line 34, in __new__
obj.__init__(url, xml, cookies)
File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/coverage/wcs100.py", line 51, in __init__
self.identification=ServiceIdentification(subelem)
File "/home/tkralidi/venv/lib/python2.6/site-packages/owslib/coverage/wcs100.py", line 184, in __init__
self.service = testXMLValue(elem.find(ns('name')))
AttributeError: 'NoneType' object has no attribute 'find'
To execute tests in a CI environment using http://travis-ci.org/ hook.
I can see that OWSLib supports WCS and WFS but the docs are missing: http://geopython.github.io/OWSLib/#wfs.
Are these services not yet ready to use via OWSLib?
(carrying on from #25)
This includes support for namespaces WMS Capabilities XML, as well as coordinate order handling, etc.
solve encoding problem when the return of the wms server is not ascii
patch submitted by Servais Nabil
We are using the library successfully with Geoserver, but get the following annoying warning when calling !WebCoverageService?(): /usr/local/lib/python2.6/dist-packages/OWSLib-0.3.2beta-py2.6.egg
Python 2.6 raises a deprecation warning.
/owslib/coverage/wcsBase.py:33:
!DeprecationWarning?: object.new() takes no parameters obj=object.new(self, url, xml ,cookies) Fixing this was a simple matter of removing those arguments (as suggested in the warning). I have attached the updated version of wcsBase.py for your consideration. We are using OWSLib from the repository with SVN revision number 1672 and Python version 2.6x
Add the capability to perform (or not) !GetCapabilities requests on WPS init.
Use skip_caps parameter to bypass Capabilities on init.
None
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.