Reputation: 363
I am working on a school project doing some spatial analysis on of counties in California; using Jyupter Notebook to run Python(2.7) scripts and create visualizations.
I was successful in importing Basemap into my notebook after I downloaded it using conda. I am very new to Python and can't really remember how I pulled that off. I believe I used the instructions from this website.
But now, when trying to impose my shapefile over the basemap I run into this error:
ValueError: shapefile must have lat/lon vertices - it looks like this one has vertices in map projection coordinates. You can convert the shapefile to geographic
coordinates using the shpproj utility from the shapelib tools
(http://shapelib.maptools.org/shapelib-tools.html)
For the past hour I have been searching for ways to convert the coordinates and learned about GDAL and some command ogr2ogr
. I have tried following the instructions posted on gdal.org that tell me to run this command: conda install -c conda-forge gdal
. Is there a difference between conda and conda-forge? I have tried many variations of this command like: conda install -c anaconda2 gdal
and install conda gdal
. Nothing has worked because when I go back to my notebook and try import gdal
or import ogr
I get an error like so:
ImportError: dlopen(/anaconda2/lib/python2.7/site-packages/osgeo/_gdal.so, 2): Library not loaded: @rpath/libgif.7.dylib
Referenced from: /anaconda2/lib/libgdal.20.dylib
Reason: image not found
I'm really confused as to how conda works, the difference between conda and conda-forge, and where all this stuff I have been downloading has been going. What I am doing wrong?
Upvotes: 0
Views: 1054
Reputation: 27718
First, when you ask a question, please specify your environment: OS, conda version (conda info
), Python version, etc.
conda
is a Python environment manager and a package manager. To install packages, conda
has to download the packages from somewhere. The place where conda
get the list of packages is called a channel.
By defaults, two channels named main
and r
are enable, both of which are maintained by Anaconda, the company itself. conda-force
is a channel by a third-party community.
Quote from conda-force documentation
What is conda-forge?
conda-forge is a community effort that provides conda packages for a wide range of software.
Specify a channel in command line with -c channelname
, shortcut for --channel
.
Your problem was caused by a mixed channel usage for one package. gdal
was specified to be installed from conda-forge
, but not its dependencies. Since channel of its dependencies are not specified, the default channel main
and r
will be used.
To fix the mixed dependency use, enable "strict" channel priority.
conda config --set channel_priority strict
which makes channel specified by --channel
prioritize over other channels.
channel_priority
(ChannelPriority)With
strict
channel priority, packages in lower priority channels are not considered if a package with the same name appears in a higher priority channel.
Then recreate an environment and install gdal
.
conda create --name test4gdal python=2.7
conda activate test4gdal
conda install -c conda-forge gdal
This time, all gdal
related packages are installed from conda-forge
.
Upvotes: 3