Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project_extents function in geoviews/util.py #564

Open
valenal opened this issue Mar 7, 2022 · 0 comments
Open

project_extents function in geoviews/util.py #564

valenal opened this issue Mar 7, 2022 · 0 comments

Comments

@valenal
Copy link

valenal commented Mar 7, 2022

Python 3.9.7
IPython 7.30.1
cartopy 0.20.1
geoviews 1.9.2

hvplot is trying to convert extents from one projection to another using project_extents function but when i use a projection with a spherical globe I get the following error:

from cartopy import crs as ccrs
from geoviews.util import project_extents

extents =(-20037508.342789244, -20037508.342789248, 20037508.342789244, 20037508.342789248)

sphere = ccrs.Globe(ellipse='sphere', semimajor_axis=6370000, semiminor_axis=6370000)
crsLCC = ccrs.LambertConformal(globe=sphere,central_longitude=-97.0, central_latitude=40.0,standard_parallels=(33,45))

project_extents(extents, crsLCC, ccrs.GOOGLE_MERCATOR)
/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/cartopy/crs.py:825: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  if len(multi_line_string) > 1:
/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/cartopy/crs.py:877: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  for line in multi_line_string:
/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/cartopy/crs.py:944: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  if len(p_mline) > 0:
/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/cartopy/crs.py:982: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use the `geoms` property to access the constituent parts of a multi-part geometry.
  line_strings.extend(multi_line_string)
/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/cartopy/crs.py:982: ShapelyDeprecationWarning: __len__ for multi-part geometries is deprecated and will be removed in Shapely 2.0. Check the length of the `geoms` property instead to get the  number of parts of a multi-part geometry.
  line_strings.extend(multi_line_string)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/geoviews/util.py in project_extents(extents, src_proj, dest_proj, tol)
     96         try:
---> 97             geom_in_crs = dest_proj.project_geometry(geom_in_src_proj, src_proj)
     98         except ValueError:

/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/cartopy/crs.py in project_geometry(self, geometry, src_crs)
    796         if not method_name:
--> 797             raise ValueError(f'Unsupported geometry type {geom_type!r}')
    798         return getattr(self, method_name)(geometry, src_crs)

ValueError: Unsupported geometry type 'GeometryCollection'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-7-92202881847f> in <module>
----> 1 project_extents(extents, crsLCC, ccrs.GOOGLE_MERCATOR)

/usr/apps/anaconda3/envs/gviews/lib/python3.9/site-packages/geoviews/util.py in project_extents(extents, src_proj, dest_proj, tol)
     99             src_name =type(src_proj).__name__
    100             dest_name =type(dest_proj).__name__
--> 101             raise ValueError('Could not project data from %s projection '
    102                              'to %s projection. Ensure the coordinate '
    103                              'reference system (crs) matches your data '

ValueError: Could not project data from LambertConformal projection to Mercator projection. Ensure the coordinate reference system (crs) matches your data and the kdims.

If I use a projection without the spherical parameter, it works. However, this is not my reference coordinate system.

crsLCC = ccrs.LambertConformal(central_longitude=-97.0, central_latitude=40.0,standard_parallels=(33,45))
project_extents(extents, crsLCC, ccrs.GOOGLE_MERCATOR)
@maximlt maximlt added this to the Version 1.9.6 milestone Mar 18, 2022
@hoxbro hoxbro modified the milestones: Version 1.9.6, Version 1.9.x Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants