TUB-DVG / vDistrict

vDistrict - Django Project to collect and demonstrate functionalities of virtual District Django-apps.
Other
1 stars 0 forks source link

Update GDAL installation #2

Open c0nb4 opened 1 week ago

c0nb4 commented 1 week ago

Fix the GDAL installation.

Adapt the installation and readme, so the wheels by Gohlke are used.

https://github.com/cgohlke/geospatial-wheels/

c0nb4 commented 1 week ago

@nlongn22 can you update the GDAL installation, test and verify the installation. Additionally check for the option to install usesgraphs / 3Dcitydb ( https://github.com/TUB-DVG/djangoCityDB ) and djangoteaser. ( https://github.com/TUB-DVG/djangoTEASER )

c0nb4 commented 1 week ago

Based on your findings, take a look at this issue: https://github.com/TUB-DVG/vDistrict/issues/3

nlongn22 commented 1 week ago

Following the guide in README i encountered some issues. Below are the exact steps I followed with comments and an issue (or not).

DB setup (Docker, 3DCityDB, InfluxDB, ADE)

1. run Docker (OK): docker run -dit --name citydb-container -p 5555:5432 -e "SRID=25832" -e "SRSNAME=urn:adv:crs:ETRS89_UTM32*DE_DHHN92_NH" -e "CITYDBNAME=citydb" -e "POSTGRES_USER=admin" -e "POSTGRES_PASSWORD=admin" tumgis/3dcitydb-postgis

2. pull InfluxDB (OK): docker pull influxdb

3. run Docker with the http api port 8086 exposed for InfluxDB (OK): docker run --name=influxdb -d -p 8086:8086 -v /media/influxdb_backup/:/backup influxdb

4. jump into the InfluxDB console for db and user creation (problem!):

  $ docker exec -it influxdb bash
  $ influx

  # CREATE DATABASE vdistrict
  # CREATE USER vdistrict WITH PASSWORD 'vdistrict' WITH ALL PRIVILEGES

This assumes InfluxDB version v1.x but the version Docker pulls is 2.x which doesn't support these command line commands. Instead I needed to use the GUI version accessible by going to http://localhost:8086. This was also the easiest way IMO. There we are presented a user creation screen which you need to fill out. After that a personal token is showed which needs to be saved. After user creation the README guide says we need to create a database called vdistrict (btw InfluxDB often refers to a 'database' as 'bucket'). The database can either be created using the GUI or we can use this command in the command line instead (we are still inside our Docker container btw).

4.1. authenticate the CLI with our personal token (showed after user creation): export INFLUX_TOKEN=<<your-token>>

4.2. create the bucket (database) via CLI: influx bucket create -n vdistrict --org <<your-org-name>>

5. migrate EnergyADE and UtilityNetworksADE (OK) Following this step in the guide was okay and I didn't encountered any issues. Make sure to fill the correct DB info in the 3DCityDB Importer/Exporter.

=== This completes the DB setup process. ===

Dependencies installation

1. download and install Anaconda (OK):

$ wget https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
$ bash Anaconda3-2019.03-Linux-x86_64.sh

2. setup a vDistrict virtual environment (OK): conda create -n vDistrict python=3.7

3. activate venv (OK): source activate vDistrict

4. installing dependencies (problem!):

$ conda install psycopg2 numpy pandas=0.23 pyproj scipy plotly
$ conda install -c conda-forge shapely libgdal gdal
$ pip install django influxdb

Here, the first and third command work fine but I've come across an issue at the second command with conda-forge shapely libgdal gdal dependencies. I'm stucked with this loop: Screenshot from 2024-10-23 13-53-32 Not sure why...

5. installing internal dependencies - EBC Django-applications (problem!):

All those link above point to 404 not found.

6. Environment variables (OK, but some observations): First we need to locate our conda vDistrict environment direcotry which is located in ~/anaconda3/envs/vDistrict. There navigate to etc/conda and follow these steps below.

6.1. open activate.d/env_vars.sh and add these lines below:

export AIXLIB_LIBRARY_PATH=Path/to/your/AixLibClone
export PYTHONPATH=Path/to/your/vDistrictClone

6.2. open deactivate.d/env_vars.sh and add these lines below:

unset AIXLIB_LIBRARY_PATH=Path/to/your/AixLibClone
unset PYTHONPATH=Path/to/your/vDistrictClone

Note: It needs to be more specified what is Path/to/your/AixLibClone and Path/to/your/vDistrictClone. I'm not sure what these values are supposed to be.

=== This completes the dependencies setup process. ===

Configure your individual settings (Django)

1. settings file copy (OK): In the root directory you will find p_settings_TEMPLATE.py. Create a copy and name it for instance p_settings_vDistrict.py and move it into ./vDistrict.

2. update PostgreSQL database information (OK): Update the DATABASE field with your data from step 1. of the section "DB setup (Docker, 3DCityDB, InfluxDB, ADE)".

3. update InfluxDB information (OK): Update the INFLUX_DF_CLIENT fields, same as previous step.

4. Adding this settings file to our environment variables (OK): Navigate to ~/anaconda3/envs/vDistrict/etc/conda.

4.1. open activate.d/env_vars.sh and add these lines below: export DJANGO_SETTINGS_MODULE=vDistrict.p_settings_<<PROJECTNAME>> (PROJECTNAME is in my case vDistrict (per step 1.) 4.2. open deactivate.d/env_vars.sh and add these lines below: unset DJANGO_SETTINGS_MODULE

5. only for Linux users (problem!):

if platform.system() == "Linux":
    GDAL_LIBRARY_PATH = os.path.join(
        os.getenv("HOME"), "anaconda3", "envs", "{YOUR_ENVIRONMENT}", "lib", "libgdal.so"
    )
    GEOS_LIBRARY_PATH = os.path.join(
        os.getenv("HOME"), "anaconda3", "envs", "{YOUR_ENVIRONMENT}", "lib", "libgeos_c.so"
    )

_Note: I don't know what YOURENVIRONMENT means.

=== This completes the settings setup process. ===

Run application (FINAL)

1. Run migrations (problem!):

$ python manage.py migrate
$ python manage.py migrate --fake-initial

I get an error saying citydb doesn't exist.

2. Run Django server: $ ./vDistrict python manage.py runserver

nlongn22 commented 1 week ago

Fix the GDAL installation.

Adapt the installation and readme, so the wheels by Gohlke are used.

https://github.com/cgohlke/geospatial-wheels/

The provided repo doesn't show any Linux installation steps (only Windows). But per discussion via Webex here is a link to a Debian distribution (currently testing): https://tracker.debian.org/pkg/gdal

c0nb4 commented 1 week ago

Thanks,

so from your text I understand that there are a few dependencies errors that we need to update.

  1. influxdb
  2. Most likely conda and python to newer versions (?)

I'll update the paths of the installation. Have you tried with the versions hosted on github? e.g. https://github.com/TUB-DVG/djangoCityDB