My notes on how to install MovingPandas directly from PyPI without using Conda or Anaconda.
/home/myself/usr/local.Download, build, and install Python3.7;
be sure to include --enable-shared
along with the other configure flags
(such as --prefix=/home/myself/usr/local ).
Consider also installng PostgreSQL V11 (not v12), PostGIS, and MobilityDB.
PROJ-6,7 requires SQLite3, but when I installed it, it broke mobilitydb. My temporary solution was to install SQLite3 off to the side just to get PROJ to compile.
The SQLite download page listed an 'amalgamation' package, but I didn't get that to work. I just compiled directly from sources.
cd ~/pkgs
wget https://sqlite.org/2020/sqlite-src-3310100.zip
unzip sqlite-src-3310100.zip
cd sqlite-src-3310100
./configure --prefix=/home/myself/usr/local_sqlite
make
make TCLLIBDIR=/home/myself/usr/share_sqlite/usr/share/tcl8.5/sqlite3 install
(I have no idea why the make install insisted on a hardcoded TCLLIB,
but I had to override that to get the install to work.)
TODO: figure out how to get MobilityDB and SQLite to behave together.
Notes:
datumgrid files, Proj-7 needs data filesI've decided to try 6.3.1:
export PKG_CONFIG_PATH=/home/myself/usr/local/lib/pkgconfig/
export SQLITE3_CFLAGS=-I/home/myself/usr/local_sqlite/include
export SQLITE3_LIBS="-L/home/myself/usr/local_sqlite/lib -lsqlite3"
cd ~/pkgs
wget https://download.osgeo.org/proj/proj-6.3.1.tar.gz
tar zxvf proj-6.3.1.tar.gz
wget https://download.osgeo.org/proj/proj-datumgrid-1.8.zip
unzip proj-datumgrid-1.8.zip -d proj-6.3.1/data/
cd proj-6.3.1
./configure --prefix=/home/myself/usr/local
make
make install
Seemed to go ok.
Install directly using pip:
~/usr/local/bin/pip3.7 install Cython --install-option="--no-cython-compile"
Running setup.py install for Cython ... done
Successfully installed Cython-0.29.15
Seemed to install ok.
Finally, we can now install cartopy.
This depends on PKG_CONFIG_PATH pointing to the place where the proj.pc file is located. (As already set above.)
cd ~/pkgs
wget https://files.pythonhosted.org/packages/e5/92/fe8838fa8158931906dfc4f16c5c1436b3dd2daf83592645b179581403ad/Cartopy-0.17.0.tar.gz
tar zxvf Cartopy-0.17.0.tar.gz
cd Cartopy-0.17.0
~/usr/local/bin/python3.7 setup.py build_ext --inplace -I/home/myself/usr/local/include -L/home/myself/usr/local/lib
~/usr/local/bin/python3.7 setup.py install
Using /home/myself/usr/local/lib/python3.7/site-packages
Finished processing dependencies for Cartopy==0.17.0
It looks like it installed.
Note: sometimes install of cartopy was complaining about numpy being bad, but upon further analysis it seemed that the problem was really an invalid or missing Cython, and not anything to do with numpy.
Install of movingpandas via pip may pull down bokeh 2.0.0 which won't work, force use of the released (1.4.0) version:
/home/myself/usr/local/bin/pip3.7 install bokeh==1.4.0
Collecting bokeh==1.4.0
...
Successfully installed bokeh-1.4.0
from the GeoPandas docs:
The .crs attribute is no longer a dict or string
Starting with GeoPandas 0.7, the .crs attribute of a GeoSeries or GeoDataFrame stores the CRS information as a pyproj.CRS, and no longer as a proj4 string or dict.
default installed version is:
>>> gpd.__version__
'0.7.0'
HOWEVER, the current git repo (2020-03-10) works fine with GeoPandas. 0.7.
Ok, here goes...
~/usr/local/bin/pip3.7 install movingpandas
Successfully built movingpandas PyYAML tornado
Installing collected packages: ... movingpandas
and to see if it really worked:
~/usr/local/bin/python3.7
Python 3.7.3 (default, Mar 3 2020, 21:42:22)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import movingpandas
looks good.
Not so fast... let's see if it is usable
NOT SO FAST ^2
Ok., let's try that with the correct print statement:
~/usr/local/bin/python3.7
import urllib
import os
import pandas as pd
import geopandas as gpd
from geopandas import GeoDataFrame, read_file
from shapely.geometry import Point, LineString, Polygon
from fiona.crs import from_epsg
from datetime import datetime, timedelta
from matplotlib import pyplot as plt
import movingpandas as mpd
import warnings
warnings.simplefilter("ignore")
CRS_METRIC = from_epsg(31256)
df = pd.DataFrame([
{'geometry':Point(0,0), 't':datetime(2018,1,1,12,0,0)},
{'geometry':Point(6,0), 't':datetime(2018,1,1,12,6,0)},
{'geometry':Point(6,6), 't':datetime(2018,1,1,12,10,0)},
{'geometry':Point(9,9), 't':datetime(2018,1,1,12,15,0)}
]).set_index('t')
geo_df = GeoDataFrame(df, crs=CRS_METRIC)
toy_traj = mpd.Trajectory(geo_df, 1)
print(toy_traj)
and the output of that is:
Trajectory 1 (2018-01-01 12:00:00 to 2018-01-01 12:15:00) | Size: 4 | Length: 16.2m
Bounds: (0.0, 0.0, 9.0, 9.0)
LINESTRING (0 0, 6 0, 6 6, 9 9)
__YIPEE!!!_ (for the 3rd time)