Installing geopandas and geoplot on a Raspberry Pi turned out not to be straight forward. Hence, I tried to resolve and install this manually. The details of the environment is:
Raspberry Pi 3 Model B Rev 1.2, Linux version 4.19.118-v7+, Raspbian GNU/Linux 10 (buster)
Just installing geopandas and geoplot using pip fails due to the dependencies these packages have.
- geopandas requires fiona, shapely, pandas, pyproj (use
pip show geopandas
) - geoplot requires: geopandas, descartes, contextily, seaborn, pandas, mapclassify, matplotlib, cartopy
Specifically, there is some underlying dependencies of libraries gdal, proj that needs to be resolved before installing.
The following recipe worked for me:
First install gdal and check version
$ sudo apt-get install gdal-bin, libgdal-dev
$ gdal-config --version
2.4.0
Install proj
version 6.3.2 using a tmp-directory, first install sqlite3 that proj
is using
$ sudo apt-get install sqlite3
$ mkdir tmp
$ cd tmp
$ wget https://download.osgeo.org/proj/proj-6.3.2.tar.gz
$ tar xvf proj-6.3.2.tar.gz
$ cd proj-6.3.2
$ ./configure
$ make
$ sudo make install
$ sudo ldconfig
Now install fiona
and
pyproj
version 1.9.6
$ pip install fiona
$ pip install pyproj==1.9.6
Before we can install geoplot, the library libatlas
needs to be installed. Then try to install geopandas
and
geoplot
geopandas also depends on shapely
and
rtree
.
To install rtree
I had to build the underlying library libspatialindex from source.
Here is how (if cmake is not installed, use apt-get install cmake
)
$ mkdir libspatialindex
$ cd libspatialindex/
$ wget https://github.com/libspatialindex/libspatialindex/releases/download/1.9.3/spatialindex-src-1.9.3.tar.gz
$ tar -xvf spatialindex-src-1.9.3.tar.gz
$ cd spatialindex-src-1.9.3/
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local .
$ make
$ sudo make install
$ sudo ldconfig
$ pip install rtree
To ensure that the correct version of shapely
is used, don't install the binary.
I encountered errors like below due to wrong version of shapely
, see stackoverflow
python: geos_ts_c.cpp:3991: int GEOSCoordSeq_getSize_r(GEOSContextHandle_t, const geos::geom::CoordinateSequence*, unsigned int*): Assertion `0 != cs' failed.
Below shapely
is first uninstalled (as I used thw wrong version), then re-installed not using binary default option
$ pip uninstall shapely
$ pip install shapely --no-binary shapely
Now finally install libatlas
, geopandas
and geoplot
.
$ sudo apt-get install libatlas-base-dev
$ pip install geopandas
$ pip install geoplot
During my installation, I got error messages but the installation and setup still worked