How to Handle Errors in 'cyl projection cannot cross pole' in basemap

Asked 2 years ago, Updated 2 years ago, 81 views

I installed basemap to plot the acquired data on the map.
In order to make sure that it was installed, I simply ran the code to draw a map of Japan and got the error "cyl projection cannot cross pole".

ValueError Traceback (most recent call last)
<ipython-input-6-d7b0840e2c1b>in<module>()
      6 
      7# Defining Basemap
---->8m=Basemap(llcrnrlat=south, urcrnrlat=north, llcrnrlon=west, urcrnrlon=east, resolution='h')
      9# draw the coastline
     10 m.drawcoastlines()

C:\Users\9047247\AppData\Local\Continuum\Anaconda3\lib\site-packages\mpl_toolkits\basemap\__init__.py in __init__(self, llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, llcrnrx, llcrnry, urcrnrx, urcrnry, width, height, projection, resolution, area_thresh, rsphere, ellps, lat_ts, lat_1, lat_2, lat_0, lon_0, lon_1, lon_2, o_lon_p, o_lat_p, k_0, no_rot, suppress_ticks, satellite_height, boundinglat, fix_aspect, anchor, celestial, round, epsg,ax)
   1107 if self.resolution is not None:
   1108 self.coastsegs, self.coastpolygontypes=\
->1109self._readboundarydata('gshhs', as_polygons=True)
   1110# reformat for use in matplotlib.patches.Polygon.
   1111 self.coastpolygons = [ ]

C:\Users\9047247\AppData\Local\Continuum\Anaconda3\lib\site-packages\mpl_toolkits\basemap\_init__.py in_readboundarydata(self, name, as_polygons)
   1239 if containsPole and \
   1240 self.projection in_cylproj+_pseudocyl+['geos']:
->1241 raise ValueError ('%s projection cannot cross pole'%(self.projection))
   1242 # make sure some projects have has containsPole = True
   1243# we will compute the intersections in interegraphic

ValueError—Cyl projection cannot cross pole
import numpy as np
import pandas aspd
import matplotlib.pyplot asplt
import seaborn as sns
import_geoslib
from mpl_toolkits.basemap importBasemap

# range by latitude and longitude
north = 46.
south = 30.
east = 147.
west = 128.

# Defining Basemap
m=Basemap(llcrnrlat=south, urcrnrlat=north, llcrnrlon=west, urcrnrlon=east, resolution='h')
# draw a coastline
m.drawcoastlines() 

os:windows(32bit)
python —3.6.1
basemap:1.1.0

I downloaded the appropriate whl file from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and piped it.
Also, the installation of pyproj, which is a prerequisite for basemap, was done from Anaconda Navigator.
(version is 1.9.5.1)

python python3

2022-09-30 19:38

1 Answers

It's self-resolved, so I'll write it down below.

Conclusion
Install from conda-forge with the following command:

conda install-conda-forge basemap

From conda, I gave up because there was no basemap applied to win32+python3.6, but when I tried the above, the code worked without any errors.


2022-09-30 19:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.