0

This question is an addition to this similar question. I'm trying to get a SoilGrid GeoTIFF image using OWSLib in python. Here is the script I am running:

from owslib.wcs import WebCoverageService

wcs = WebCoverageService('https://maps.isric.org/mapserv?map=/map/clay.map', version = '2.0.1')

# comes from my shapefile
bbox = (10.017215784693967, 35.63600166380057, 10.024866939934073, 35.64423653393575)

response = wcs.getCoverage(
    identifier = ['clay_0-5cm_mean'], 
    crs = 'EPSG::4326',
    bbox = bbox, 
    resx = 0.1, resy = 0.1, 
    format = 'image/tiff')

And here is the output I get:

Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
ServiceException                          Traceback (most recent call last)
/tmp/ipykernel_1537/4024548350.py in <module>
----> 1 response = wcs.getCoverage(
      2     identifier = [coverage_id],
      3     crs = crs,
      4     bbox = bbox,
      5     resx = 0.01, resy = 0.01,

~/anaconda3/envs/work_env/lib/python3.8/site-packages/owslib/coverage/wcs201.py in getCoverage(self, identifier, bbox, time, format, subsets, resolutions, sizes, crs, width, height, resx, resy, resz, parameter, method, timeout, **kwargs)
    217         log.debug("WCS 2.0.1 DEBUG: Second part of URL: %s" % data)
    218 
--> 219         u = openURL(base_url, data, method, self.cookies, auth=self.auth, timeout=timeout, headers=self.headers)
    220         return u
    221 

~/anaconda3/envs/work_env/lib/python3.8/site-packages/owslib/util.py in openURL(url_base, data, method, cookies, username, password, timeout, headers, verify, cert, auth)
    209 
    210     if req.status_code in [400, 401]:
--> 211         raise ServiceException(req.text)
    212 
    213     if req.status_code in [404, 500, 502, 503, 504]:    # add more if needed

ServiceException: <?xml version="1.0" encoding="UTF-8"?>
<ows:ExceptionReport xmlns:ows="http://www.opengis.net/ows/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.1" xml:lang="en-US" xsi:schemaLocation="http://www.opengis.net/ows/2.0 http://schemas.opengis.net/ows/2.0/owsExceptionReport.xsd">
...
  <ows:Exception exceptionCode="InvalidParameterValue" locator="size">
    <ows:ExceptionText>msWCSGetCoverage20(): WCS server error. Raster size out of range, width and height of resulting coverage must be no more than MAXSIZE=16384.</ows:ExceptionText>
  </ows:Exception>

I've tried changing the resolution, I've tried using height = 100, width = 100 in the parameters, precising a time = '2013' argument, but I can't get it to work.

My conda env:

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
_openmp_mutex             5.1                       1_gnu
affine                    2.3.1                    pypi_0    pypi
alabaster                 0.7.12             pyhd3eb1b0_0
arrow                     1.2.3            py38h06a4308_0
astroid                   2.11.7           py38h06a4308_0
asttokens                 2.0.8                    pypi_0    pypi
atomicwrites              1.4.0                      py_0
attrs                     22.1.0           py38h06a4308_0
autopep8                  1.6.0              pyhd3eb1b0_1
babel                     2.9.1              pyhd3eb1b0_0
backcall                  0.2.0              pyhd3eb1b0_0
beautifulsoup4            4.11.1           py38h06a4308_0
binaryornot               0.4.4              pyhd3eb1b0_1
black                     22.6.0           py38h06a4308_0
blas                      1.0                         mkl
bleach                    4.1.0              pyhd3eb1b0_0
boto3                     1.24.91                  pypi_0    pypi
botocore                  1.27.91                  pypi_0    pypi
brotlipy                  0.7.0           py38h27cfd23_1003
bzip2                     1.0.8                h7b6447c_0
c-ares                    1.18.1               h7f8727e_0
ca-certificates           2022.10.11           h06a4308_0
cairo                     1.16.0               h19f5f5c_2
cdsapi                    0.5.1                    pypi_0    pypi
certifi                   2022.9.24        py38h06a4308_0
cffi                      1.15.1           py38h74dc2b5_0
cfitsio                   3.470                h5893167_7
cftime                    1.6.2                    pypi_0    pypi
chardet                   4.0.0           py38h06a4308_1003
charset-normalizer        2.1.1                    pypi_0    pypi
click                     8.1.3                    pypi_0    pypi
click-plugins             1.1.1                    pypi_0    pypi
cligj                     0.7.2                    pypi_0    pypi
cloudpickle               2.0.0              pyhd3eb1b0_0
colorama                  0.4.5            py38h06a4308_0
contourpy                 1.0.5                    pypi_0    pypi
cookiecutter              1.7.3              pyhd3eb1b0_0
cryptography              38.0.1           py38h9ce1e76_0
curl                      7.84.0               h5eee18b_0
cycler                    0.11.0                   pypi_0    pypi
dbus                      1.13.18              hb2f20db_0
debugpy                   1.6.3                    pypi_0    pypi
decorator                 5.1.1              pyhd3eb1b0_0
defusedxml                0.7.1              pyhd3eb1b0_0
diff-match-patch          20200713           pyhd3eb1b0_0
dill                      0.3.6            py38h06a4308_0
docutils                  0.18.1           py38h06a4308_3
ecmwf-api-client          1.6.3                    pypi_0    pypi
entrypoints               0.4              py38h06a4308_0
eodag                     2.6.0                    pypi_0    pypi
eodag-sentinelsat         0.4.1                    pypi_0    pypi
eto                       1.1.0                    pypi_0    pypi
executing                 1.1.1                    pypi_0    pypi
expat                     2.4.9                h6a678d5_0
fiona                     1.8.21                   pypi_0    pypi
flake8                    4.0.1              pyhd3eb1b0_1
flasgger                  0.9.5                    pypi_0    pypi
flask                     2.2.2                    pypi_0    pypi
fontconfig                2.13.1               h6c09931_0
fonttools                 4.37.4                   pypi_0    pypi
freetype                  2.11.0               h70c0345_0
freexl                    1.0.6                h27cfd23_0
gdal                      3.4.1            py38h2c27f0e_0
geojson                   2.5.0                    pypi_0    pypi
geomet                    0.3.0                    pypi_0    pypi
geopandas                 0.11.1                   pypi_0    pypi
geos                      3.8.0                he6710b0_0
geotiff                   1.7.0                hd69d5b1_0
giflib                    5.2.1                h7b6447c_0
glib                      2.69.1               h4ff587b_1
gst-plugins-base          1.14.0               h8213a91_2
gstreamer                 1.14.0               h28cd5cc_2
h5netcdf                  1.1.0                    pypi_0    pypi
h5py                      3.7.0                    pypi_0    pypi
hdf4                      4.2.13               h3ca952b_2
hdf5                      1.10.6               h3ffc7dd_1
html2text                 2020.1.16                pypi_0    pypi
icu                       58.2                 he6710b0_3
idna                      3.4              py38h06a4308_0
imagesize                 1.4.1            py38h06a4308_0
importlib-metadata        5.0.0                    pypi_0    pypi
importlib-resources       5.10.0                   pypi_0    pypi
importlib_metadata        4.11.3               hd3eb1b0_0
inflection                0.5.1            py38h06a4308_0
intel-openmp              2021.4.0          h06a4308_3561
intervaltree              3.1.0              pyhd3eb1b0_0
ipykernel                 6.16.0                   pypi_0    pypi
ipython                   8.5.0                    pypi_0    pypi
ipython_genutils          0.2.0              pyhd3eb1b0_1
isort                     5.9.3              pyhd3eb1b0_0
itsdangerous              2.1.2                    pypi_0    pypi
jedi                      0.18.1           py38h06a4308_1
jeepney                   0.7.1              pyhd3eb1b0_0
jellyfish                 0.9.0            py38h7f8727e_0
jinja2                    3.1.2            py38h06a4308_0
jinja2-time               0.2.0              pyhd3eb1b0_3
jmespath                  1.0.1                    pypi_0    pypi
jpeg                      9e                   h7f8727e_0
json-c                    0.13.1               h1bed415_0
jsonpath-ng               1.5.3                    pypi_0    pypi
jsonschema                4.16.0           py38h06a4308_0
jupyter-client            7.4.2                    pypi_0    pypi
jupyter-core              4.11.1                   pypi_0    pypi
jupyterlab_pygments       0.1.2                      py_0
kealib                    1.4.14               hb50703a_1
keyring                   23.4.0           py38h06a4308_0
kiwisolver                1.4.4                    pypi_0    pypi
krb5                      1.19.2               hac12032_0
landsatxplore             0.13.0                   pypi_0    pypi
lazy-object-proxy         1.6.0            py38h27cfd23_0
ld_impl_linux-64          2.38                 h1181459_1
lerc                      3.0                  h295c915_0
libboost                  1.73.0              h28710b8_12
libclang                  10.0.1          default_hb85057a_2
libcurl                   7.84.0               h91b91d3_0
libdap4                   3.19.1               h6ec2957_0
libdeflate                1.8                  h7f8727e_5
libedit                   3.1.20210910         h7f8727e_0
libev                     4.33                 h7f8727e_1
libevent                  2.1.12               h8f2d780_0
libffi                    3.3                  he6710b0_2
libgcc-ng                 11.2.0               h1234567_1
libgdal                   3.4.1                h05199a0_1
libgfortran-ng            11.2.0               h00389a5_1
libgfortran5              11.2.0               h1234567_1
libgomp                   11.2.0               h1234567_1
libkml                    1.3.0                h7ecb851_5
libllvm10                 10.0.1               hbcb73fb_5
libnetcdf                 4.8.1                h42ceab0_1
libnghttp2                1.46.0               hce63b2e_0
libpng                    1.6.37               hbc83047_0
libpq                     12.9                 h16c4e8d_3
libsodium                 1.0.18               h7b6447c_0
libspatialindex           1.9.3                h2531618_0
libspatialite             4.3.0a              hbedb2dc_20
libssh2                   1.10.0               h8f2d780_0
libstdcxx-ng              11.2.0               h1234567_1
libtiff                   4.4.0                hecacb30_0
libuuid                   1.0.3                h7f8727e_2
libwebp                   1.2.4                h11a3e52_0
libwebp-base              1.2.4                h5eee18b_0
libxcb                    1.15                 h7f8727e_0
libxkbcommon              1.0.1                hfa300c1_0
libxml2                   2.9.14               h74e7548_0
libxslt                   1.1.35               h4e12654_0
libzip                    1.8.0                h5cef20c_0
lxml                      4.9.1            py38h1edc446_0
lz4-c                     1.9.3                h295c915_1
markdown                  3.4.1                    pypi_0    pypi
markupsafe                2.1.1            py38h7f8727e_0
matplotlib                3.6.1                    pypi_0    pypi
matplotlib-inline         0.1.6            py38h06a4308_0
mccabe                    0.7.0              pyhd3eb1b0_0
memory-profiler           0.61.0                   pypi_0    pypi
mistune                   2.0.4                    pypi_0    pypi
mkl                       2021.4.0           h06a4308_640
mkl-service               2.4.0            py38h7f8727e_0
mkl_fft                   1.3.1            py38hd3c417c_0
mkl_random                1.2.2            py38h51133e4_0
multiprocess              0.70.14                  pypi_0    pypi
munch                     2.5.0                    pypi_0    pypi
mypy_extensions           0.4.3            py38h06a4308_1
nbclient                  0.5.13           py38h06a4308_0
nbconvert                 6.5.4            py38h06a4308_0
nbformat                  5.5.0            py38h06a4308_0
ncurses                   6.3                  h5eee18b_3
nest-asyncio              1.5.6                    pypi_0    pypi
netcdf4                   1.6.2                    pypi_0    pypi
nspr                      4.33                 h295c915_0
nss                       3.74                 h0370c37_0
numpy                     1.23.4                   pypi_0    pypi
numpydoc                  1.5.0            py38h06a4308_0
opencv-python             4.6.0.66                 pypi_0    pypi
openjpeg                  2.4.0                h3ad879b_0
openssl                   1.1.1s               h7f8727e_0
owslib                    0.27.2                   pypi_0    pypi
p-tqdm                    1.4.0                    pypi_0    pypi
packaging                 21.3               pyhd3eb1b0_0
pandas                    1.5.0                    pypi_0    pypi
pandocfilters             1.5.0              pyhd3eb1b0_0
parso                     0.8.3              pyhd3eb1b0_0
pathos                    0.3.0                    pypi_0    pypi
pathspec                  0.9.0            py38h06a4308_0
pcre                      8.45                 h295c915_0
pexpect                   4.8.0              pyhd3eb1b0_3
pickleshare               0.7.5           pyhd3eb1b0_1003
pillow                    9.2.0                    pypi_0    pypi
pip                       22.3.1                   pypi_0    pypi
pixman                    0.40.0               h7f8727e_1
pkgutil-resolve-name      1.3.10           py38h06a4308_0
platformdirs              2.5.2            py38h06a4308_0
pluggy                    1.0.0            py38h06a4308_1
ply                       3.11                     py38_0
poppler                   0.81.0               h01f5e8b_2
poppler-data              0.4.11               h06a4308_0
pox                       0.3.2                    pypi_0    pypi
poyo                      0.5.0              pyhd3eb1b0_0
ppft                      1.7.6.6                  pypi_0    pypi
proj                      6.2.1                h05a3930_0
prompt-toolkit            3.0.31                   pypi_0    pypi
psutil                    5.9.2                    pypi_0    pypi
ptyprocess                0.7.0              pyhd3eb1b0_2
pure-eval                 0.2.2                    pypi_0    pypi
pycodestyle               2.8.0              pyhd3eb1b0_0
pycparser                 2.21               pyhd3eb1b0_0
pydocstyle                6.1.1              pyhd3eb1b0_0
pyflakes                  2.4.0              pyhd3eb1b0_0
pygments                  2.13.0                   pypi_0    pypi
pylint                    2.14.5           py38h06a4308_0
pyls-spyder               0.4.0              pyhd3eb1b0_0
pyopenssl                 22.0.0             pyhd3eb1b0_0
pyparsing                 3.0.9            py38h06a4308_0
pyproj                    3.4.0                    pypi_0    pypi
pyqt                      5.15.7           py38h6a678d5_1
pyqt5-sip                 12.11.0          py38h6a678d5_1
pyqtwebengine             5.15.7           py38h6a678d5_1
pyrsistent                0.18.1                   pypi_0    pypi
pyshp                     2.3.1                    pypi_0    pypi
pysocks                   1.7.1            py38h06a4308_0
pystac                    1.6.1                    pypi_0    pypi
python                    3.8.13               h12debd9_0
python-dateutil           2.8.2              pyhd3eb1b0_0
python-fastjsonschema     2.16.2           py38h06a4308_0
python-lsp-black          1.2.1            py38h06a4308_0
python-lsp-jsonrpc        1.0.0              pyhd3eb1b0_0
python-lsp-server         1.5.0            py38h06a4308_0
python-slugify            5.0.2              pyhd3eb1b0_0
pytz                      2022.4                   pypi_0    pypi
pyxdg                     0.27               pyhd3eb1b0_0
pyyaml                    6.0              py38h7f8727e_1
pyzmq                     24.0.1                   pypi_0    pypi
qdarkstyle                3.0.2              pyhd3eb1b0_0
qstylizer                 0.1.10             pyhd3eb1b0_0
qt-main                   5.15.2               h327a75a_7
qt-webengine              5.15.9               hd2b0992_4
qtawesome                 1.0.3              pyhd3eb1b0_0
qtconsole                 5.3.2            py38h06a4308_0
qtpy                      2.2.0            py38h06a4308_0
qtwebkit                  5.212                h4eab89a_4
rasterio                  1.3.2                    pypi_0    pypi
readline                  8.1.2                h7f8727e_1
requests                  2.28.1           py38h06a4308_0
requests-futures          1.0.0                    pypi_0    pypi
rope                      0.22.0             pyhd3eb1b0_0
rtree                     0.9.7            py38h06a4308_1
s3transfer                0.6.0                    pypi_0    pypi
scipy                     1.9.2                    pypi_0    pypi
secretstorage             3.3.1            py38h06a4308_0
sentinelsat               1.1.1                    pypi_0    pypi
setuptools                65.5.0           py38h06a4308_0
shapely                   1.8.5.post1              pypi_0    pypi
sip                       6.6.2            py38h6a678d5_0
six                       1.16.0             pyhd3eb1b0_1
snowballstemmer           2.2.0              pyhd3eb1b0_0
snuggs                    1.4.7                    pypi_0    pypi
sortedcontainers          2.4.0              pyhd3eb1b0_0
soupsieve                 2.3.2.post1      py38h06a4308_0
sphinx                    5.0.2            py38h06a4308_0
sphinxcontrib-applehelp   1.0.2              pyhd3eb1b0_0
sphinxcontrib-devhelp     1.0.2              pyhd3eb1b0_0
sphinxcontrib-htmlhelp    2.0.0              pyhd3eb1b0_0
sphinxcontrib-jsmath      1.0.1              pyhd3eb1b0_0
sphinxcontrib-qthelp      1.0.3              pyhd3eb1b0_0
sphinxcontrib-serializinghtml 1.1.5              pyhd3eb1b0_0
spyder-kernels            2.3.3            py38h06a4308_0
sqlite                    3.39.3               h5082296_0
stack-data                0.5.1                    pypi_0    pypi
text-unidecode            1.3                pyhd3eb1b0_0
textdistance              4.2.1              pyhd3eb1b0_0
three-merge               0.1.1              pyhd3eb1b0_0
tiledb                    2.3.3                h1132f93_2
tinycss                   0.4             pyhd3eb1b0_1002
tinycss2                  1.2.1            py38h06a4308_0
tk                        8.6.12               h1ccaba5_0
toml                      0.10.2             pyhd3eb1b0_0
tomli                     2.0.1            py38h06a4308_0
tomlkit                   0.11.1           py38h06a4308_0
tornado                   6.2              py38h5eee18b_0
tqdm                      4.64.1                   pypi_0    pypi
traitlets                 5.4.0                    pypi_0    pypi
typing-extensions         4.3.0            py38h06a4308_0
typing_extensions         4.3.0            py38h06a4308_0
ujson                     5.4.0            py38h6a678d5_0
unidecode                 1.2.0              pyhd3eb1b0_0
urllib3                   1.26.12          py38h06a4308_0
usgs                      0.3.4                    pypi_0    pypi
watchdog                  2.1.6            py38h06a4308_0
wcwidth                   0.2.5              pyhd3eb1b0_0
webencodings              0.5.1                    py38_1
werkzeug                  2.2.2                    pypi_0    pypi
whatthepatch              1.0.2            py38h06a4308_0
wheel                     0.37.1             pyhd3eb1b0_0
whoosh                    2.7.4                    pypi_0    pypi
wrapt                     1.14.1           py38h5eee18b_0
wurlitzer                 3.0.2            py38h06a4308_0
xarray                    2022.11.0                pypi_0    pypi
xerces-c                  3.2.3                h780794e_0
xlrd                      2.0.1                    pypi_0    pypi
xz                        5.2.6                h5eee18b_0
yaml                      0.2.5                h7b6447c_0
yapf                      0.31.0             pyhd3eb1b0_0
zeromq                    4.3.4                h2531618_0
zipp                      3.9.0                    pypi_0    pypi
zlib                      1.2.12               h5eee18b_3
zstd                      1.5.2                ha4553b6_0


After reading a little more documentation from the ISRIC web coverage service page, I ran the script again by changing the version to '1.0.0' (on the second line) as shown in the documentation.

wcs = WebCoverageService('https://maps.isric.org/mapserv?map=/map/clay.map', version = '1.0.0')

That doesn't return any errors, but it downloads a 587 octet .tif file (in less than 0.1 seconds) that obviously doesn't contain any data and can't be opened without returning a None element in python (opening it with a basic image viewer doesn't work either).

1 Answer 1

1

Try using a URN to identify the CRS, e.g.:

response = wcs.getCoverage(
    identifier = ['clay_0-5cm_mean'], 
    crs = 'urn:ogc:def:crs:EPSG::4326',
    bbox = bbox, 
    resx = 0.1, resy = 0.1, 
    format = 'image/tiff')

Besides that, it would be recommendable to consider whether a datum ensemble is appropriate for your use case. The GDAL manual advises against its use:

The generic EPSG:4326 WGS 84 CRS is also considered dynamic, although it is not recommended to use it due to being based on a datum ensemble whose positional accuracy is 2 meters, but prefer one of its realizations, such as WGS 84 (G1762)

1
  • Thank you for the answer. I tried but it still downloads an empty image (587 o). I don't think the data I am trying to download changes much over time, and for my specific application the varying accuracy won't be an issue. Feb 10, 2023 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.