Installation and Configuration¶
Prerequisites¶
- Django 2.x, 3.x or 4.x
- python3
- Geodjango
- PostGis 2.x
- (for kmeans clustering, recommended) kmeans PostgreSQL extension: https://github.com/umitanuki/kmeans-postgresql
kmeans postgis exension¶
Installing the kmeans PostgreSQL extension (optional, needed for kmeans clustering)
Download and unzip https://github.com/umitanuki/kmeans-postgresql on your server.
make sure you have the development packages for you postgresql server package installed (e.g. sudo apt-get install libpq-dev postgresql-server-dev-10)
In your unzipped kmeans folder run the following (e.g. on ubuntu)
make sudo make install psql -f /usr/share/postgresql/14/extension/kmeans.sql -d YOURGEODJANGODATABASE
The latter needs to be processed as a postgresql superuser, e.g. the user postgres. You now have access to the kmeans functions which are necessary for the pin-based clustering.
on opensuse, the psql command would be
psql -f /usr/share/postgresql15/extension/kmeans.sql -d YOURGEODJANGODATABASE
The number 14 or 15 depends on the postgresql versoin you are using.
django configuration¶
Install anycluster with your Django installation
use
pip install anycluster
OR unzip the folder anycluster into your project directoryadd ‘anycluster’ to your INSTALLED_APPS
required SETTINGS (settings.py)
ANYCLUSTER_GEODJANGO_MODEL = "yourapp.models.your_geodjango_model" ANYCLUSTER_COORDINATES_COLUMN = "your_geometric_column"
urls.py
path('anycluster/', include('anycluster.urls')),