Metadata-Version: 2.4
Name: geomanager
Version: 0.6.3
Summary: Wagtail based Geospatial Data Manager
Home-page: https://github.com/wmo-raf/geomanager
Author: Erick Otenyo
Author-email: otenyo.erick@gmail.com
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: wagtail>=6.3.2
Requires-Dist: wagtail-modeladmin>=2.1.0
Requires-Dist: adm-boundary-manager>=0.2.5
Requires-Dist: django_extensions>=3.2.1
Requires-Dist: wagtail_color_panel>=1.4.1
Requires-Dist: wagtail-font-awesome-svg>=1.0.1
Requires-Dist: django_json_widget>=1.1.1
Requires-Dist: django_nextjs==2.4.0
Requires-Dist: django-allauth>=0.54.0
Requires-Dist: django-large-image==0.10.2
Requires-Dist: large-image-source-rasterio>=1.34.0
Requires-Dist: large-image-source-pil>=1.34.0
Requires-Dist: django-filter>=22.1
Requires-Dist: cftime>=1.6.2
Requires-Dist: netCDF4>=1.6.3
Requires-Dist: rasterio>=1.3.6
Requires-Dist: rio-cogeo>=3.5.1
Requires-Dist: xarray>=2023.3.0
Requires-Dist: rioxarray>=0.14.0
Requires-Dist: shapely>=2.0.1
Requires-Dist: djangorestframework-simplejwt>=5.2.2
Requires-Dist: wagtail-humanitarian-icons>=2.0.0
Requires-Dist: wagtail-icon-chooser>=0.3.1
Requires-Dist: matplotlib>=3.7.1
Requires-Dist: CairoSVG>=2.7.0
Requires-Dist: wagtail-cache>=2.5.1
Requires-Dist: mercantile>=1.2.1
Dynamic: license-file

# GeoManager

Wagtail based Geospatial Data Manager and backend CMS for [geomapviewer](https://github.com/wmo-raf/geomapviewer)

![Geomanager Admin Screenshot](./screenshots/geomanager_with_frontend.png)

# Background

Most national/regional institutions working in weather/climate/DRM sectors regularly produce and disseminate data and
information that is Geo-referenced. This can range from forecast model outputs, earth observation data, stations
observation, periodic bulletins and advisories and so on. Usually these are shared on their websites and social media
pages in static formats, mostly as PNGs or PDFS.

This is an effort to develop an interactive system for managing and publishing Geo-referenced (GIS)
datasets. As the institutions produce and share their products in static formats, they can also use packages like this,
to make their data interactive.

The package is developed primarily for use by NMHSs at national levels, but can be adapted in other institutions or
places that need to visualize their geospatial data.

# Features

All the raster and vector datasets uploaded must have time associated with each file.

For netCDF files with time dimension, time is automatically extracted from the file. For Geotiff, each uploaded file
must be manually assigned time.

Data management and visualization

- Uploading and visualization of gridded data
    - netCDF
    - Geotiff
- Uploading and visualization of vector data
    - Shapefiles
    - Geojson
- Raster Tile serving of raster data using [django-large-image](https://github.com/girder/django-large-image).
  All `django-large-image`features are available
- Vector tile serving using PostGIS MVT Tiles

MapViewer Management

- Management of layers visualized on the [geomapviewer](https://github.com/wmo-raf/geomapviewer)
    - Control on visibility (public or private) of layers on the MapViewer

# Installation

### Prerequisite

Before installing this package, you should make sure you have GDAL installed in your system.

`TIP:` Installing GDAL can be notoriously difficult. You can use pre-built Python wheels with the GDAL binary bundled,
provided by [KitWare](https://github.com/Kitware), for easy installation in production linux environments.

To install GDAL using KitWare GDAL wheel, use:

```shell
  pip install --find-links https://girder.github.io/large_image_wheels GDAL
```

Other required packages that you will need to install, if not installed already in your Wagtail Project

- psycopg2 - for postgres/postgis database connection

### Installation

You can install the package using pip:

```shell
pip install geomanager
```

Install this version of [wagtail-admin-sortable](https://github.com/wmo-raf/wagtail-admin-sortable) from Github. This
has some updates to the original packages.

```shell
pip install https://github.com/wmo-raf/wagtail-admin-sortable/archive/33bf22f290e7a4210b44667e9ff56e4b35ad309e.zip
````

# Usage

Make sure the following are all added to your `INSTALLED_APPS` in your Wagtail `settings`

````python
INSTALLED_APPS = [
    ...
    
    "geomanager",
    "adminboundarymanager",
    "django_large_image",
    'django_json_widget',
    'django_nextjs',
    "django_filters",
    "wagtail_color_panel",
    "wagtail_adminsortable",
    "wagtailhumanitarianicons",
    "wagtailiconchooser",
    "django_extensions",
    "wagtailfontawesomesvg"
    "allauth",
    "allauth.account",
    "wagtailcache",
    "wagtail_modeladmin"
    
    "wagtail.contrib.settings",
    "rest_framework",
    "django.contrib.gis",
    
    ...
]

````

Run migrations

```shell
python manage.py migrate geomanager
```

Add the following to your project's `urls.py`

```python
urlpatterns = [
    ...
    path("", include("geomanager.urls")),
    ...
]
```


# Wagtail Cache Setup

Geomanager depends on the [wagtail-cache](https://github.com/coderedcorp/wagtail-cache) package for caching requests.
Please have a look at the [wagtail-cache documentation](https://docs.coderedcorp.com/wagtail-cache/) for setup
instructions

# Including the Map Viewer

This package is the backend component to the frontend [geomapviewer](https://github.com/wmo-raf/geomapviewer).

# Testing local changes in ClimWeb

If you are developing geomanager and want to test your changes inside a running [ClimWeb](https://github.com/wmo-raf/climweb) instance, follow the steps below.

## Prerequisites

Both repos should be cloned side by side:

```
wmo/
  climweb/
  geomanager/
```

## Setup

### 1. Start ClimWeb with the geomanager volume mount

From the **climweb** directory, use the dev compose file (it already mounts `../geomanager` into the containers):

In `docker-compose.dev.yml`
```yaml
  cimweb_dev:
    volumes:
      - ../geomanager:/geomanager

```

Then run ClimWeb as usual:
```bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml build
docker compose -f docker-compose.yml -f docker-compose.dev.yml up
```

### 2. Install geomanager in editable mode

Inside the running ClimWeb container, replace the pinned geomanager with your local copy:

```bash
docker exec climweb_dev pip install -e /geomanager
```

> This must be re-run each time the container is recreated (e.g. after `docker compose build`).

If your changes also affect Celery tasks, install it in the worker too:

```bash
docker exec climweb_celery_worker_dev pip install -e /geomanager
```

### 3. Apply database migrations (if needed)

If your geomanager changes include model modifications:

```bash
docker exec climweb_dev cd src/climweb && python manage.py makemigrations geomanager
docker exec climweb_dev cd src/climweb && python manage.py migrate
```

## Development workflow

1. Edit code in the geomanager repo as normal.
2. Python file changes are picked up automatically (Django dev server reloads).
3. If you modify models, run `makemigrations` + `migrate` again.
4. When done, commit your migrations in the geomanager repo.

## Reverting to the released version

Rebuild the container to go back to the pinned version:

```bash
docker compose -f docker-compose.yml -f docker-compose.dev.yml build
```

Or reinstall the pinned version manually:

```bash
docker exec climweb_dev pip install geomanager==<version>
```

# Documentation

TODO
