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

CRSError: The WKT could not be parsed. OGR Error code 6 #255

Open
aetriusgx opened this issue Oct 15, 2024 · 1 comment
Open

CRSError: The WKT could not be parsed. OGR Error code 6 #255

aetriusgx opened this issue Oct 15, 2024 · 1 comment

Comments

@aetriusgx
Copy link

aetriusgx commented Oct 15, 2024

Code outputs 'CRSError: The WKT could not be parsed. OGR Error code 6' when trying to use add_basemap

# Snippet
ax = boundary_map.plot(color="lightgrey", ax=ax)
if background:
    cx.add_basemap(ax, crs=boundary_map.crs.to_string())

boundary_map is in reference to this .geojson

Checking the crs outputs the following:

boundary_map.crs()
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

I'm working with a large dataset so warping the basemap tiles would be preferred.

I've been following these guides:

This is also on a recent install of contextily 1.6.2

Here is the traceback in full:

CPLE_BaseError                            Traceback (most recent call last)
File rasterio\\crs.pyx:779, in rasterio.crs.CRS.from_user_input()

File rasterio\\_err.pyx:303, in rasterio._err.exc_wrap_ogrerr()

CPLE_BaseError: OGR Error code 6

During handling of the above exception, another exception occurred:

CRSError                                  Traceback (most recent call last)
Cell In[134], line 1
----> 1 facet_geoscatter(et_seasonal, boundary_map=keco_geo, col='season', hue='skill_score', palette='Spectral', size='markersize',
      2                  as_percent=False, normalize_cmap=True, export_img="et_spatial_skill_score", 
      3                  col_order=['Winter', 'Spring', 'Summer'], title_template={"template":"{col_name}"},
      4                  title="Average ET Skill Score across Kern County by Season", background=True)

Cell In[133], line 10, in facet_geoscatter(data, boundary_map, col, row, hue, palette, size, title, export_img, height, aspect, double_legend, row_order, col_order, title_template, as_percent, normalize_cmap, background)
      8     ax = boundary_map.plot(color="lightgrey", ax=ax)
      9     if background:
---> 10         cx.add_basemap(ax, crs=boundary_map.crs.to_string())
     12 norm = None
     14 if normalize_cmap:

File ~\.conda\envs\python311\Lib\site-packages\contextily\plotting.py:130, in add_basemap(ax, zoom, source, interpolation, attribution, attribution_size, reset_extent, crs, resampling, zoom_adjust, **extra_imshow_args)
    128 # Convert extent from `crs` into WM for tile query
    129 if crs is not None:
--> 130     left, right, bottom, top = _reproj_bb(
    131         left, right, bottom, top, crs, "epsg:3857"
    132     )
    133 # Download image
    134 image, extent = bounds2img(
    135     left,
    136     bottom,
   (...)
    142     zoom_adjust=zoom_adjust,
    143 )

File ~\.conda\envs\python311\Lib\site-packages\contextily\plotting.py:231, in _reproj_bb(left, right, bottom, top, s_crs, t_crs)
    230 def _reproj_bb(left, right, bottom, top, s_crs, t_crs):
--> 231     n_l, n_b, n_r, n_t = transform_bounds(s_crs, t_crs, left, bottom, right, top)
    232     return n_l, n_r, n_b, n_t

File ~\.conda\envs\python311\Lib\site-packages\rasterio\warp.py:147, in transform_bounds(src_crs, dst_crs, left, bottom, right, top, densify_pts)
    113 def transform_bounds(
    114         src_crs,
    115         dst_crs,
   (...)
    119         top,
    120         densify_pts=21):
    121     """Transform bounds from src_crs to dst_crs.
    122 
    123     Optionally densifying the edges (to account for nonlinear transformations
   (...)
    145         Outermost coordinates in target coordinate reference system.
    146     """
--> 147     src_crs = CRS.from_user_input(src_crs)
    148     dst_crs = CRS.from_user_input(dst_crs)
    149     return _transform_bounds(
    150         src_crs,
    151         dst_crs,
   (...)
    156         densify_pts,
    157     )

File rasterio\\crs.pyx:781, in rasterio.crs.CRS.from_user_input()

CRSError: The WKT could not be parsed. OGR Error code 6
@martinfleis
Copy link
Member

This is most likely an installation issue. Try re-installing rasterio in your environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants