Closed fclubb closed 6 years ago
This is a conda-forge packaging problem and should be reported there. But also see the following other issue.
Duplicate of #419.
Duplicate of #419.
Which is not a basemap issue, it is a conda
usage question. The answer is here:
Hi all,
I know this is a duplicate thread, but I have been struggling this this issue for a good couple of hours (on windows), so I wanted to share my experiences so others can hopefully solve this a bit quicker.
For the conda version of basemap it needs the PROJ_LIB variable to be set so it can find the epsg data. For me the epsg data was packaged with the proj4 package.
For me the epsg data was located in the following folder:
C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share
Therefore the following 2 lines in the python script that imports basemap solved the issue for me:
import os
os.environ['PROJ_LIB'] = r'C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share'
I hope it helps.
Cheers
Hi all,
I know this is a duplicate thread, but I have been struggling this this issue for a good couple of hours (on windows), so I wanted to share my experiences so others can hopefully solve this a bit quicker.
For the conda version of basemap it needs the PROJ_LIB variable to be set so it can find the epsg data. For me the epsg data was packaged with the proj4 package.
For me the epsg data was located in the following folder:
C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share
Therefore the following 2 lines in the python script that imports basemap solved the issue for me:
import os
os.environ['PROJ_LIB'] = r'C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share'
I hope it helps.
Cheer
Yeah it helped. Thanks
Hi all, I know this is a duplicate thread, but I have been struggling this this issue for a good couple of hours (on windows), so I wanted to share my experiences so others can hopefully solve this a bit quicker. For the conda version of basemap it needs the PROJ_LIB variable to be set so it can find the epsg data. For me the epsg data was packaged with the proj4 package. For me the epsg data was located in the following folder: C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share Therefore the following 2 lines in the python script that imports basemap solved the issue for me: import os os.environ['PROJ_LIB'] = r'C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share' I hope it helps. Cheer
Yeah it helped. Thanks
This is correct, it shouldn't happen, but its happening here and there
Hi all,
I know this is a duplicate thread, but I have been struggling this this issue for a good couple of hours (on windows), so I wanted to share my experiences so others can hopefully solve this a bit quicker.
For the conda version of basemap it needs the PROJ_LIB variable to be set so it can find the epsg data. For me the epsg data was packaged with the proj4 package.
For me the epsg data was located in the following folder:
C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share
Therefore the following 2 lines in the python script that imports basemap solved the issue for me:
import os
os.environ['PROJ_LIB'] = r'C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share'
I hope it helps.
Cheers
Thank you so much, this seems to work for me, i'm new in programming and i'd like to know whether i'd have to put the location ''C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share" in jupyter notebook cell every time when i use the package or there is permanent solution for it ?
Thank you.
@rezapci and @Asheef1447 bare in mind that conda
should take care of that. Maybe you are using the package via spyder or a non-activate jupyter instance and then changing the kernel another. You can always check if the environment variable is properly set with the command: echo %PROJ_LIB%
. BTW, this works as expected:
conda create --name TEST basemao
conda activate TEST
python -c "from mpl_toolkits.basemap import Basemap"
echo %PROJ_LIB%
Thanks @ocefpaf
Maybe you are using the package via spyder... then changing the kernel another.
pip install --upgrade --user matplotlib numpy pyproj pyshp OWSLib Pillow sudo apt-get update sudo apt install libgeos-dev pip install --user https://github.com/matplotlib/basemap/archive/master.zip
Try this it work smoothy System Note- Ananconda navigator , python 3.7 ubuntu 20.04
PLEASE HELP!!!!
Trying to get basemap to work in Jupyter and getting this error:
NameError Traceback (most recent call last)
C:\Users\HEATHE~1\AppData\Local\Temp/ipykernel_14688/2506085524.py in
NameError: name 'Basemap' is not defined
with this code:
import os os.environ['PROJ_LIB'] = r'C:\Users\username\AppData\Local\Continuum\anaconda2\pkgs\proj4-4.9.2-vc10_0\Library\share' import matplotlib.pyplot as plt
from matplotlib.collections import PatchCollection from matplotlib.patches import Polygon import numpy as np
fig = plt.figure() ax = fig.add_subplot(111)
bot_left_lat =36.5 bot_left_lon =-114.5 top_right_lat =42.5 top_right_lon = -108.5
m = Basemap(resolution='i', projection='cyl', \ llcrnrlon=bot_left_lon, llcrnrlat=bot_left_lat, \ urcrnrlon=top_right_lon, urcrnrlat=top_right_lat)
m.drawcoastlines() m.drawstates() m.drawcountries() m.drawrivers(color='blue')
maps = ['ESRI_Imagery_World_2D', # 0 'ESRI_StreetMap_World_2D', # 1 'NatGeo_World_Map', # 2 'NGS_Topo_US_2D', # 3 'Ocean_Basemap', # 4 'USA_Topo_Maps', # 5 'World_Imagery', # 6 'World_Physical_Map', # 7 'World_Shaded_Relief', # 8 'World_Street_Map', # 9 'World_Terrain_Base', # 10 'World_Topo_Map' # 11 ] print ("drawing image from arcGIS server...",) m.arcgisimage(service=maps[8], xpixels=1000, verbose=False) print ("...finished")
lon = -111.85 lat = 40.77 m.scatter(lon,lat,c='r',s=150)
lons = np.arange(-115,-100,.5) lats = np.arange(33,48,.5) u = np.arange(-5,10,.5) v = np.arange(5,20,.5) m.barbs(lons, lats, u, v, color='fuchsia')
x = [-110, -112] y = [40, 42] m.plot(x, y, color='navy', lw=5)
patches = [] homeplate = np.array([[-114,38],[-113,37],[-112,38],[-112,40],[-114,40]]) patches.append(Polygon(homeplate)) triangle = np.array([[-111,38],[-110,37],[-110,42]]) patches.append(Polygon(triangle)) ax.add_collection(PatchCollection(patches, facecolor='lightgreen', edgecolor='k', linewidths=1.5))
plt.title('Map of Utah Basemap Example') plt.xlabel('this is the x label')
plt.show()
When I try to install basemap via conda (Ubuntu 18.04) I get the following error:
I have the following packages installed:
Any help on fixing would be much appreciated!