SciTools / cartopy

Cartopy - a cartographic python library with matplotlib support
https://scitools.org.uk/cartopy/docs/latest
BSD 3-Clause "New" or "Revised" License
1.43k stars 365 forks source link

stock_img doesn't work with Orthographic projection #1193

Closed rabernat closed 5 years ago

rabernat commented 5 years ago

Description

Calling .stock_img() with Orthographic projection does not show anything.

ax = plt.axes(projection=ccrs.Orthographic())
ax.stock_img()

Shows this image

This occurs with Cartopy 0.16.0 and matplotlib 3.0.1 (latest releases of each).

Instead, if I use Cartopy 0.15.1 and matplotlib 2.1.0 (from an older setup), I see this: image

Full environment definition ### Operating system Linux ### Cartopy version 0.16.0 ### conda list ``` $ conda list # packages in environment at /opt/conda: # # Name Version Build Channel affine 2.2.1 py_0 conda-forge alembic 0.9.9 py_0 conda-forge appdirs 1.4.3 py_1 conda-forge asciitree 0.3.3 py_2 conda-forge asn1crypto 0.24.0 py36_0 conda-forge atomicwrites 1.2.1 py_0 conda-forge attrs 18.2.0 py_0 conda-forge backcall 0.1.0 py_0 conda-forge blas 1.1 openblas conda-forge bleach 2.1.3 py_0 conda-forge blinker 1.4 py_1 conda-forge blosc 1.14.4 hfc679d8_0 conda-forge bokeh 0.12.16 py36_0 conda-forge boost-cpp 1.67.0 h3a22d5f_0 conda-forge boto3 1.9.45 py_0 conda-forge botocore 1.12.45 py_0 conda-forge bottleneck 1.2.1 py36h7eb728f_1 conda-forge bqplot 0.11.2 py36_0 conda-forge bzip2 1.0.6 h470a237_2 conda-forge ca-certificates 2018.10.15 ha4d7672_0 conda-forge cachetools 2.1.0 py_0 conda-forge cairo 1.14.12 he6fea26_5 conda-forge cartopy 0.16.0 py36h81b52dc_2 conda-forge certifi 2018.10.15 py36_1000 conda-forge cffi 1.11.5 py36_0 conda-forge cftime 1.0.2.1 py36h7eb728f_0 conda-forge chardet 3.0.4 py36_0 conda-forge click 7.0 py_0 conda-forge click-plugins 1.0.4 py_0 conda-forge cligj 0.5.0 py_0 conda-forge cloudpickle 0.6.1 py_0 conda-forge colorcet 1.0.0 py_0 conda-forge conda 4.5.4 py36_0 conda-forge conda-env 2.6.0 0 conda-forge configurable-http-proxy 3.1.0 node8_1 conda-forge cryptography 2.2.1 py36_0 conda-forge curl 7.62.0 h74213dd_0 conda-forge cycler 0.10.0 py_1 conda-forge cython 0.29 py36hfc679d8_0 conda-forge cytoolz 0.9.0.1 py36h470a237_1 conda-forge dask 0.18.2 py_0 conda-forge dask-core 0.18.2 py_0 conda-forge dask-glm 0.1.0 0 conda-forge dask-kubernetes 0.4.0 dask-ml 0.11.0 py_0 conda-forge datashader 0.6.8 py_0 conda-forge datashape 0.5.4 py36_0 conda-forge dbus 1.13.0 h3a4f0e9_0 conda-forge decorator 4.3.0 py_0 conda-forge distributed 1.22.1 py36_0 conda-forge docrep 0.2.4 docutils 0.14 py36_1001 conda-forge entrypoints 0.2.3 py36_1 conda-forge esmf 7.1.0r h35eb876_3 conda-forge esmpy 7.1.0r py36_1 conda-forge expat 2.2.5 hfc679d8_2 conda-forge fasteners 0.14.1 py_3 conda-forge fastparquet 0.1.6 py36h7eb728f_0 conda-forge fontconfig 2.13.1 h65d0f4c_0 conda-forge freetype 2.9.1 h6debe1e_4 conda-forge freexl 1.0.5 h470a237_2 conda-forge fusepy 3.0.1 future 0.17.1 gcsfs 0.1.2 py_0 conda-forge geos 3.6.2 hfc679d8_3 conda-forge geotiff 1.4.2 h700e5ad_5 conda-forge gettext 0.19.8.1 h5e8e0c9_1 conda-forge giflib 5.1.4 h470a237_1 conda-forge glib 2.55.0 h464dc38_2 conda-forge gmp 6.1.2 0 conda-forge google-auth 1.6.1 py_0 conda-forge google-auth-oauthlib 0.1.0 py36_0 conda-forge graphite2 1.3.12 hfc679d8_1 conda-forge graphviz 2.38.0 h08bfae6_9 conda-forge gst-plugins-base 1.12.5 hde13a9d_0 conda-forge gstreamer 1.12.5 h61a6719_0 conda-forge gsw 3.2.1 py36h470a237_3 conda-forge h5netcdf 0.6.2 py_0 conda-forge h5py 2.8.0 py36h097b052_4 conda-forge harfbuzz 1.9.0 h08d66d9_0 conda-forge hdf4 4.2.13 h951d187_2 conda-forge hdf5 1.10.3 hc401514_2 conda-forge heapdict 1.0.0 py36_1000 conda-forge holoviews 1.10.9 py_1 conda-forge html5lib 1.0.1 py_0 conda-forge icu 58.2 hfc679d8_0 conda-forge idna 2.6 py36_1 conda-forge imageio 2.4.1 py36_1000 conda-forge intake 0.2.9 py_0 conda-forge intake-xarray 0.2.4 py_0 conda-forge ipaddress 1.0.22 ipykernel 4.8.2 py36_0 conda-forge ipyleaflet 0.9.1 py36_0 conda-forge ipython 6.4.0 py36_0 conda-forge ipython_genutils 0.2.0 py36_0 conda-forge ipywidgets 7.4.2 py_0 conda-forge jedi 0.13.1 jedi 0.12.0 py36_0 conda-forge jinja2 2.10 py36_0 conda-forge jmespath 0.9.3 py_1 conda-forge jpeg 9c h470a237_1 conda-forge json-c 0.12.1 h470a237_1 conda-forge jsonschema 2.6.0 py36_1 conda-forge jupyter 1.0.0 py_1 conda-forge jupyter_client 5.2.3 py_1 conda-forge jupyter_console 5.2.0 py36_1 conda-forge jupyter_core 4.4.0 py_0 conda-forge jupyterhub 0.8.1 py36_0 conda-forge jupyterlab 0.34.2 py36_0 conda-forge jupyterlab_launcher 0.13.1 py_2 conda-forge kealib 1.4.10 hb88cf67_0 conda-forge kiwisolver 1.0.1 py36h2d50403_2 conda-forge krb5 1.16.2 hbb41f41_0 conda-forge kubernetes 6.0.0 libcurl 7.62.0 hbdb9355_0 conda-forge libdap4 3.19.1 h8fe5423_1 conda-forge libedit 3.1.20170329 0 conda-forge libffi 3.2.1 3 conda-forge libgcc 7.2.0 h69d50b8_2 defaults libgcc-ng 8.2.0 hdf63c60_1 defaults libgdal 2.3.2 hc73897a_0 conda-forge libgfortran 3.0.0 1 conda-forge libiconv 1.15 h470a237_3 conda-forge libkml 1.3.0 hccc92b1_8 conda-forge libnetcdf 4.6.1 h9cd6fdc_11 conda-forge libpng 1.6.35 ha92aebf_2 conda-forge libpq 10.5 he29860b_0 conda-forge libsodium 1.0.16 h470a237_1 conda-forge libspatialite 4.3.0a hdfcc80b_23 conda-forge libssh2 1.8.0 h5b517e9_2 conda-forge libstdcxx-ng 7.2.0 hdf63c60_3 defaults libtiff 4.0.9 he6b73bb_2 conda-forge libtool 2.4.6 h470a237_2 conda-forge libuuid 2.32.1 h470a237_2 conda-forge libxcb 1.13 h470a237_2 conda-forge libxml2 2.9.8 h422b904_5 conda-forge libxslt 1.1.32 h88dbc4e_2 conda-forge llvmlite 0.25.0 py36hd28b015_1 conda-forge locket 0.2.0 py_2 conda-forge lxml 4.2.5 py36hc9114bc_0 conda-forge lz4 1.1.0 py36h3b97293_1 conda-forge lz4-c 1.8.1.2 0 conda-forge mako 1.0.7 py36_0 conda-forge markupsafe 1.0 py36_0 conda-forge matplotlib 2.2.3 py36h8e2386c_0 conda-forge mistune 0.8.3 py36_1 conda-forge monotonic 1.5 py_0 conda-forge more-itertools 4.3.0 py36_1000 conda-forge mpi 1.0 mpich conda-forge mpich 3.2.1 h26a2512_5 conda-forge msgpack-numpy 0.4.4.1 py_0 conda-forge msgpack-python 0.5.6 py36h2d50403_3 conda-forge multipledispatch 0.6.0 py_0 conda-forge nb_conda_kernels 2.2.0 py36_1000 conda-forge nbconvert 5.3.1 py_1 conda-forge nbformat 4.4.0 py36_0 conda-forge nbserverproxy 0.8.1 ncurses 5.9 10 conda-forge netcdf-fortran 4.4.4 h71ea97b_10 conda-forge netcdf4 1.4.2 py36hac939d9_0 conda-forge networkx 2.2 py_1 conda-forge nodejs 8.10.0 0 conda-forge nomkl 3.0 0 defaults notebook 5.5.0 py36_0 conda-forge numba 0.40.0 py36hf8a1672_0 conda-forge numcodecs 0.5.5 py36hfc679d8_1 conda-forge numpy 1.15.1 py36_blas_openblashd3ea46f_1 [blas_openblas] conda-forge oauthlib 2.1.0 py_0 conda-forge olefile 0.46 py_0 conda-forge openblas 0.2.20 8 conda-forge openjpeg 2.3.0 h0e734dc_3 conda-forge openssl 1.0.2p h470a237_1 conda-forge owslib 0.17.0 py_0 conda-forge packaging 18.0 py_0 conda-forge pamela 0.3.0 py36_0 conda-forge pandas 0.23.2 py36_0 conda-forge pandoc 2.2.1 0 conda-forge pandocfilters 1.4.2 py36_0 conda-forge pango 1.40.14 he752989_2 conda-forge param 1.8.1 py_0 conda-forge parso 0.3.1 parso 0.2.1 py_0 conda-forge partd 0.3.9 py_0 conda-forge pcre 8.41 hfc679d8_3 conda-forge pexpect 4.6.0 py36_0 conda-forge pickleshare 0.7.4 py36_0 conda-forge pillow 5.3.0 py36hc736899_0 conda-forge pip 18.1 pip 9.0.3 py36_0 conda-forge pixman 0.34.0 h470a237_3 conda-forge pluggy 0.8.0 py_0 conda-forge poppler 0.67.0 h4d7e492_3 conda-forge poppler-data 0.4.9 0 conda-forge postgresql 10.5 h66035e0_0 conda-forge proj4 4.9.3 h470a237_8 conda-forge prompt_toolkit 1.0.15 py36_0 conda-forge psutil 5.4.8 py36h470a237_0 conda-forge pthread-stubs 0.4 h470a237_1 conda-forge ptyprocess 0.5.2 py36_0 conda-forge py 1.7.0 py_0 conda-forge pyasn1 0.4.4 py_1 conda-forge pyasn1-modules 0.2.1 py_0 conda-forge pycosat 0.6.3 py36_0 conda-forge pycparser 2.18 py36_0 conda-forge pyct 0.4.5 py_0 conda-forge pyct-core 0.4.5 py_0 conda-forge pyepsg 0.3.2 py_1 conda-forge pygments 2.2.0 py36_0 conda-forge pyjwt 1.6.4 py_0 conda-forge pyopenssl 18.0.0 py36_0 conda-forge pyparsing 2.3.0 py_0 conda-forge pyproj 1.9.5.1 py36h508ed2a_6 conda-forge pyqt 5.6.0 py36h8210e8a_7 conda-forge pyshp 2.0.0 py_0 conda-forge pysocks 1.6.8 py36_1 conda-forge pytest 3.9.1 py36_1000 conda-forge python 3.6.6 h5001a0f_3 conda-forge python-blosc 1.4.4 py36_0 conda-forge python-dateutil 2.7.3 py_0 conda-forge python-editor 1.0.3 py36_0 conda-forge python-graphviz 0.8.4 py36_1002 conda-forge python-oauth2 1.0.1 py36_0 conda-forge python-snappy 0.5.3 py36h00d4201_0 conda-forge pytz 2018.7 py_0 conda-forge pyviz_comms 0.6.0 py_0 conda-forge pywavelets 1.0.1 py36h7eb728f_0 conda-forge pyyaml 3.13 py36h470a237_1 conda-forge pyzmq 17.1.2 py36hae99301_1 conda-forge qt 5.6.2 hf70d934_9 conda-forge qtconsole 4.4.3 py_0 conda-forge rasterio 1.0.9 py36h54a03ab_1 conda-forge readline 7.0 0 conda-forge requests 2.18.4 py36_1 conda-forge requests-oauthlib 0.8.0 py36_1 conda-forge rsa 3.4.2 py_1 conda-forge ruamel.yaml 0.15.77 py36h470a237_0 conda-forge ruamel_yaml 0.15.37 py36h470a237_0 conda-forge s3fs 0.1.6 py_0 conda-forge s3transfer 0.1.13 py36_1001 conda-forge scikit-image 0.14.1 py36hfc679d8_1 conda-forge scikit-learn 0.20.0 py36_blas_openblasha84fab4_201 [blas_openblas] conda-forge scipy 1.1.0 py36_blas_openblash7943236_201 [blas_openblas] conda-forge send2trash 1.5.0 py_0 conda-forge setuptools 39.2.0 py36_0 conda-forge shapely 1.6.4 py36h164cb2d_1 conda-forge simplegeneric 0.8.1 py36_0 conda-forge sip 4.18.1 py36hfc679d8_0 conda-forge six 1.11.0 py36_1 conda-forge snappy 1.1.7 hfc679d8_2 conda-forge snuggs 1.4.1 py_1 conda-forge sortedcontainers 2.0.5 py_0 conda-forge sqlalchemy 1.2.8 py36_0 conda-forge sqlite 3.25.3 h7b6447c_0 defaults tblib 1.3.2 py_1 conda-forge terminado 0.8.1 py36_0 conda-forge testpath 0.3.1 py36_0 conda-forge thrift 0.11.0 py36hfc679d8_1 conda-forge tk 8.6.8 ha92aebf_0 conda-forge toolz 0.9.0 py_1 conda-forge tornado 5.0.2 py36_0 conda-forge traitlets 4.3.2 py36_0 conda-forge traittypes 0.2.1 py_1 conda-forge urllib3 1.22 py36_0 conda-forge wcwidth 0.1.7 py36_0 conda-forge webencodings 0.5 py36_0 conda-forge websocket-client 0.54.0 wheel 0.31.0 py36_0 conda-forge widgetsnbextension 3.4.2 py36_1000 conda-forge xarray 0.10.8 py36_1 conda-forge xerces-c 3.2.0 h5d6a6da_2 conda-forge xesmf 0.1.1 xgcm 0.1.0 xorg-kbproto 1.0.7 h470a237_2 conda-forge xorg-libice 1.0.9 h470a237_4 conda-forge xorg-libsm 1.2.3 h8c8a85c_0 conda-forge xorg-libx11 1.6.6 h470a237_0 conda-forge xorg-libxau 1.0.8 h470a237_6 conda-forge xorg-libxdmcp 1.1.2 h470a237_7 conda-forge xorg-libxext 1.3.3 h470a237_4 conda-forge xorg-libxpm 3.5.12 h470a237_2 conda-forge xorg-libxrender 0.9.10 h470a237_2 conda-forge xorg-libxt 1.1.5 h470a237_2 conda-forge xorg-renderproto 0.11.1 h470a237_2 conda-forge xorg-xextproto 7.3.0 h470a237_2 conda-forge xorg-xproto 7.0.31 h470a237_7 conda-forge xz 5.2.4 h470a237_1 conda-forge yaml 0.1.7 0 conda-forge zarr 2.2.0 py_1 conda-forge zeromq 4.2.5 1 conda-forge zict 0.1.3 py_0 conda-forge zlib 1.2.11 h470a237_3 conda-forge ``` ### pip list ``` Package Version -------------------- ----------- affine 2.2.1 alembic 0.9.9 appdirs 1.4.3 asciitree 0.3.3 asn1crypto 0.24.0 atomicwrites 1.2.1 attrs 18.2.0 backcall 0.1.0 beautifulsoup4 4.6.3 bleach 2.1.3 blinker 1.4 blosc 1.4.4 bokeh 0.12.16 boto3 1.9.45 botocore 1.12.45 Bottleneck 1.2.1 bqplot 0.11.2 cachetools 2.1.0 Cartopy 0.16.0 certifi 2018.10.15 cffi 1.11.5 cftime 1.0.2.1 chardet 3.0.4 Click 7.0 click-plugins 1.0.4 cligj 0.5.0 cloudpickle 0.6.1 colorcet 1.0.0 conda 4.5.4 cryptography 2.2.1 cycler 0.10.0 Cython 0.29 cytoolz 0.9.0.1 dask 0.18.2 dask-glm 0.1.0 dask-kubernetes 0.4.0 dask-ml 0.11.0 datashader 0.6.8 datashape 0.5.4 decorator 4.3.0 distributed 1.22.1 docrep 0.2.4 docutils 0.14 entrypoints 0.2.3 ESMPy 7.1.0.dev0 fasteners 0.14.1 fastparquet 0.1.6 fusepy 3.0.1 future 0.17.1 gcsfs 0.1.2 google-auth 1.6.1 google-auth-oauthlib 0.1.0 graphviz 0.8.4 gsw 3.2.1 h5netcdf 0.6.2 h5py 2.8.0 heapdict 1.0.0 holoviews 1.10.9 html5lib 1.0.1 idna 2.6 imageio 2.4.1 intake 0.2.9 intake-xarray 0.2.4 ipaddress 1.0.22 ipykernel 4.8.2 ipyleaflet 0.9.1 ipython 6.4.0 ipython-genutils 0.2.0 ipywidgets 7.4.2 jedi 0.13.1 Jinja2 2.10 jmespath 0.9.3 jsonschema 2.6.0 jupyter 1.0.0 jupyter-client 5.2.3 jupyter-console 5.2.0 jupyter-core 4.4.0 jupyterhub 0.8.1 jupyterlab 0.34.2 jupyterlab-launcher 0.13.1 kiwisolver 1.0.1 kubernetes 6.0.0 llvmlite 0.25.0 locket 0.2.0 lxml 4.2.5 lz4 1.1.0 Mako 1.0.7 MarkupSafe 1.0 matplotlib 2.2.3 mistune 0.8.3 monotonic 1.5 more-itertools 4.3.0 msgpack 0.5.6 msgpack-numpy 0.4.4.1 multipledispatch 0.6.0 nb-conda-kernels 2.2.0 nbconvert 5.3.1 nbformat 4.4.0 nbserverproxy 0.8.1 netCDF4 1.4.2 networkx 2.2 notebook 5.5.0 numba 0.40.0 numcodecs 0.5.5 numpy 1.15.1 oauthlib 2.1.0 olefile 0.46 OWSLib 0.17.0 packaging 18.0 pamela 0.3.0 pandas 0.23.2 pandocfilters 1.4.2 param 1.8.1 parso 0.3.1 partd 0.3.9 pexpect 4.6.0 pickleshare 0.7.4 Pillow 5.3.0 pip 18.1 pluggy 0.8.0 prompt-toolkit 1.0.15 protobuf 3.6.1 psutil 5.4.8 ptyprocess 0.5.2 py 1.7.0 pyasn1 0.4.4 pyasn1-modules 0.2.1 pycosat 0.6.3 pycparser 2.18 pyct 0.4.5 pyepsg 0.3.2 Pygments 2.2.0 PyJWT 1.6.4 pyOpenSSL 18.0.0 pyparsing 2.3.0 pyproj 1.9.5.1 pyshp 2.0.0 PySocks 1.6.8 pytest 3.9.1 python-dateutil 2.7.3 python-editor 1.0.3 python-oauth2 1.0.1 python-snappy 0.5.3 pytz 2018.7 pyviz-comms 0.6.0 PyWavelets 1.0.1 PyYAML 3.13 pyzmq 17.1.2 qtconsole 4.4.3 rasterio 1.0.9 requests 2.18.4 requests-oauthlib 0.8.0 rsa 3.4.2 ruamel-yaml 0.15.37 ruamel.yaml 0.15.77 s3fs 0.1.6 s3transfer 0.1.13 scikit-image 0.14.1 scikit-learn 0.20.0 scipy 1.1.0 Send2Trash 1.5.0 setuptools 39.2.0 Shapely 1.6.4.post1 simplegeneric 0.8.1 siphon 0.8.0 six 1.11.0 snuggs 1.4.1 sortedcontainers 2.0.5 SQLAlchemy 1.2.8 tblib 1.3.2 terminado 0.8.1 testpath 0.3.1 thrift 0.11.0 toolz 0.9.0 tornado 5.0.2 traitlets 4.3.2 traittypes 0.2.1 urllib3 1.22 wcwidth 0.1.7 webencodings 0.5 websocket-client 0.54.0 wheel 0.31.0 widgetsnbextension 3.4.2 xarray 0.10.8 xesmf 0.1.1 xgcm 0.1.0 zarr 2.2.0 zict 0.1.3 ```
QuLogic commented 5 years ago
cartopy 0.15.1 py36_5 conda-forge
proj4 4.9.3 4 conda-forge

But what version of Proj were you using with Cartopy 0.16.0?

dopplershift commented 5 years ago

I can't reproduce on Python 3.7 with Cartopy 0.16 and Proj 4.9.3.

rabernat commented 5 years ago
$ conda list proj
# packages in environment at /opt/conda:
#
# Name                    Version                   Build  Channel
proj4                     4.9.3                h470a237_8    conda-forge
pyproj                    1.9.5.1          py36h508ed2a_6    conda-forge
rabernat commented 5 years ago

Update: I realized that I mistakenly copied the conda / pip envs from the working environment (0.15.1) rather than the non-working one (0.16). I have updated my original post with the correct environment listing.

Looks like this could be a proj4 version issue?

QuLogic commented 5 years ago

Are you absolutely certain those versions don't work with Cartopy 0.16.0?

dopplershift commented 5 years ago

I take it back, I'm running pro 4.9.3. I've corrected above.

BartSchipperijn commented 5 years ago

I have a similar problem. When I plot a collection of filled polygons (as a PolyCollection) + the stock image on a map with PlateCarree projection, the polygons and the stock image are perfectly visible. When I plot the same PolyCollection + stock image on a map with the Orthographic projection, the polygons and the stock image are not visible. However, the coastlines, borders etc. are perfectly visible on both projections.

I am running Cartopy 0.17, Matplotlib 2.2.3 and Proj4 4.9.3.

QuLogic commented 5 years ago

Difficult to say with that little information.

rabernat commented 5 years ago

Are you absolutely certain those versions don't work with Cartopy 0.16.0?

I have no way to explain it, but the problem has gone away. I can't replicate any longer.

QuLogic commented 5 years ago

I'm fairly certain this was a bug in Proj 5.0.x that you may have not noticed get downgraded at some point. Current Cartopy raises a warning about it.

BartSchipperijn commented 5 years ago

The problem disappeared in my environment when I added "transform=ccrs.PlateCarree()" to the PolyCollection parameters.

QuLogic commented 5 years ago

Please see the understanding transforms section of the documentation.