Open Clarmy opened 5 months ago
Thanks for the report @Clarmy. This looks like it could be the same problem as #2260. Please could you try again with the newly released Cartopy 0.23?
@rcomer Thank you for your reply. I just tried upgrading cartopy to version 0.23, and then reran the previous code, but it still produced the same error as before. It seems that my issue is not the same as issue #2260.
@rcomer Hello, I have found the root cause of the issue. When using the contourf
function to create contour line path data, the polygon object may encounter topological errors. This error might be caused by the presence of overlapping points in the polygon, which could be introduced by matplotlib during the plotting process. Cartopy does not perform the corresponding checks in this case. After debugging, I have found a solution and have submitted a PR: #2373. Please take some time to review and approve it.
Description
I encountered a strange
shapely.errors.GEOSException
error when using cartopy to draw maps withcontourf
. The plotting works fine if I just use matplotlib without the cartopy projection transformation.sample data: https://drive.google.com/file/d/1n1PkwgZez3Ukz-0klkll2YAJX46vOH-6/view?usp=sharing
Code to reproduce
The code runs normally if I execute the following.
However, if I execute the following code, it results in an error.
Traceback
Full environment definition
### Operating system MacOS ### Cartopy version 0.22.0 ### conda list ``` # packages in environment at /Users/clarmylee/miniconda3: # # Name Version Build Channel affine 2.4.0 pypi_0 pypi aiohttp 3.9.3 pypi_0 pypi aiosignal 1.3.1 pypi_0 pypi aliyun-python-sdk-core 2.14.0 pypi_0 pypi aliyun-python-sdk-kms 2.16.2 pypi_0 pypi annotated-types 0.6.0 pypi_0 pypi antlr4-python3-runtime 4.9.3 pypi_0 pypi anyio 3.7.1 pypi_0 pypi appnope 0.1.3 pyhd8ed1ab_0 conda-forge apscheduler 3.10.4 pypi_0 pypi archspec 0.2.1 pyhd8ed1ab_1 conda-forge argon2-cffi 23.1.0 pypi_0 pypi argon2-cffi-bindings 21.2.0 pypi_0 pypi arrow 1.3.0 pypi_0 pypi asttokens 2.4.0 pypi_0 pypi async-lru 2.0.4 pypi_0 pypi async-timeout 4.0.3 pypi_0 pypi attrs 23.1.0 pyh71513ae_1 conda-forge babel 2.13.0 pypi_0 pypi backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 pyhd8ed1ab_3 conda-forge backports.functools_lru_cache 1.6.5 pyhd8ed1ab_0 conda-forge beautifulsoup4 4.12.2 pyha770c72_0 conda-forge black 23.10.1 pypi_0 pypi blas 1.0 openblas bleach 6.1.0 pyhd8ed1ab_0 conda-forge blosc 1.21.3 h313beb8_0 boltons 23.0.0 pyhd8ed1ab_0 conda-forge boost-cpp 1.78.0 hf1d6563_2 conda-forge branca 0.7.0 pypi_0 pypi brotlipy 0.7.0 py39h1a28f6b_1002 bzip2 1.0.8 h620ffc9_4 c-ares 1.19.1 h80987f9_0 c-blosc2 2.8.0 h313beb8_0 ca-certificates 2024.2.2 hf0a4a13_0 conda-forge cairo 1.16.0 h73a0509_1014 conda-forge cartopy 0.22.0 pypi_0 pypi cattrs 23.2.3 pypi_0 pypi cdsapi 0.6.1 pypi_0 pypi certifi 2024.2.2 pyhd8ed1ab_0 conda-forge cf-units 3.2.0 py39h373d45f_4 conda-forge cfchecker 4.1.0 pyhd8ed1ab_0 conda-forge cffi 1.15.0 py39h22df2f2_1 cfitsio 4.2.0 h2f961c4_0 conda-forge cftime 1.6.3 py39h373d45f_0 conda-forge cfunits 3.3.6 pyhd8ed1ab_0 conda-forge charset-normalizer 2.0.4 pyhd3eb1b0_0 click 8.1.7 pypi_0 pypi click-plugins 1.1.1 pypi_0 pypi cligj 0.7.2 pypi_0 pypi cnmaps 1.1.7 pypi_0 pypi colorama 0.4.4 pyhd3eb1b0_0 comm 0.1.4 pypi_0 pypi compliance-checker 5.1.0 pyhd8ed1ab_0 conda-forge conda 23.7.4 py39h2804cbe_0 conda-forge conda-content-trust 0.1.1 pyhd3eb1b0_0 conda-package-handling 2.2.0 pyh38be061_0 conda-forge conda-package-streaming 0.9.0 pyhd8ed1ab_0 conda-forge confluent-kafka 2.3.0 pypi_0 pypi contourpy 1.1.1 pypi_0 pypi crcmod 1.7 pypi_0 pypi cryptography 40.0.2 py39he2a39a8_0 conda-forge curl 8.4.0 h02f6b3c_0 cycler 0.12.1 pypi_0 pypi cyeva 0.1.0b11 pypi_0 pypi dashscope 1.14.1 pypi_0 pypi dataclasses 0.8 pyhc8e2a94_3 conda-forge debugpy 1.8.0 pypi_0 pypi decorator 5.1.1 pyhd8ed1ab_0 conda-forge defusedxml 0.7.1 pyhd8ed1ab_0 conda-forge eccodes 2.29.0 h4f94b83_1 conda-forge entrypoints 0.4 pyhd8ed1ab_0 conda-forge exceptiongroup 1.1.3 pyhd8ed1ab_0 conda-forge executing 2.0.0 pypi_0 pypi expat 2.5.0 hb7217d7_1 conda-forge fastapi 0.104.1 pypi_0 pypi fiona 1.9.5 pypi_0 pypi fire 0.5.0 pypi_0 pypi flatbuffers 23.5.26 pypi_0 pypi fmt 10.1.1 h1995070_0 conda-forge folium 0.15.0 pypi_0 pypi font-ttf-dejavu-sans-mono 2.37 hab24e00_0 conda-forge font-ttf-inconsolata 3.000 h77eed37_0 conda-forge font-ttf-source-code-pro 2.038 h77eed37_0 conda-forge font-ttf-ubuntu 0.83 hab24e00_0 conda-forge fontconfig 2.14.2 h82840c6_0 conda-forge fonts-conda-ecosystem 1 0 conda-forge fonts-conda-forge 1 0 conda-forge fonttools 4.43.1 pypi_0 pypi fqdn 1.5.1 pypi_0 pypi freetype 2.12.1 hadb7bae_2 conda-forge freexl 1.0.6 h1a8c8d9_1 conda-forge frozenlist 1.4.1 pypi_0 pypi future 0.18.3 pyhd8ed1ab_0 conda-forge gdal 3.6.2 py39h766d3fc_9 conda-forge geojson 3.1.0 pypi_0 pypi geopandas 0.14.0 pypi_0 pypi geos 3.11.1 hb7217d7_0 conda-forge geotiff 1.7.1 hdcdc974_6 conda-forge gettext 0.21.1 h0186832_0 conda-forge giflib 5.2.1 h1a8c8d9_3 conda-forge h11 0.14.0 pypi_0 pypi hdf4 4.2.15 h1a38d6a_5 conda-forge hdf5 1.12.2 nompi_ha7af310_101 conda-forge howhigh 0.0.1 dev_0