cartopy icon indicating copy to clipboard operation
cartopy copied to clipboard

Use geometries.geoms to fix deprecation warning

Open chowington opened this issue 3 years ago • 4 comments

Rationale

Fix deprecation warning from Shapely, in the vein of https://github.com/SciTools/cartopy/pull/1930.

Implications

None.

Fixes https://github.com/SciTools/cartopy/issues/1984.

chowington avatar Jan 14 '22 23:01 chowington

Thank you, sorry I missed one :(

akrherz avatar Jan 14 '22 23:01 akrherz

No prob!

Unfortunately it looks like some tests are failing. Maybe the fix isn't as simple as I'd thought. I'm not actually that familiar with this package (I'm not using it myself), so someone else (@akrherz?) may need to look into it

chowington avatar Jan 15 '22 00:01 chowington

According to the docstring, the class expects a collection of geometries, so the tests are passing tuples and lists. It seems reasonable to me that a user might want to pass a single geometry e.g. via GeoAxes.add_geometries. One option might be to check whether geometries is a shapely geometry object and turn it into a single element tuple before the line that is throwing the warning.

Disclaimer: I am not a Cartopy developer so have no authority here. Just making a suggestion!

rcomer avatar Jan 16 '22 11:01 rcomer

I think @rcomer is on the right track. I think that suggestion would also help some other cases too with the pluralization confusion. See here for a possible starting implementation: https://github.com/SciTools/cartopy/issues/1303#issuecomment-619641832

greglucas avatar Jan 21 '22 04:01 greglucas

I believe this was superseded by https://github.com/SciTools/cartopy/pull/1999 which should allow single geometries to be passed through now. Feel free to re-open if that is not the case.

greglucas avatar Aug 21 '22 00:08 greglucas