ardigeos/README.md
2026-05-29 10:09:44 +02:00

259 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ardigeos
Cloud-Optimized GeoTIFF (COG) Workflow für Dünnschliff-Scans mit GDAL, OpenLayers und QGIS.
---
# Überblick
Dieses Projekt konvertiert hochauflösende Dünnschliff-Scans in performante **Cloud Optimized GeoTIFFs (COGs)** inklusive Overviews/Pyramidenstufen für Web-Visualisierung und GIS-Anwendungen.
Die erzeugten Dateien:
* sind deutlich kleiner als die Originale
* besitzen echte TIFF-Overviews
* sind webbasiert performant streambar
* funktionieren direkt mit OpenLayers/QGIS
---
# Workflow
## 1. Höchste Auflösung aus Subdataset extrahieren
Die Originaldaten enthalten mehrere interne Auflösungsstufen als `Subdatasets`.
Zuerst wird nur die höchste Auflösung extrahiert:
```bash
gdal_translate \
GTIFF_DIR:1:/scans/thinsect/1/101.tif \
base.tif \
-co TILED=YES \
-co COMPRESS=JPEG \
-co QUALITY=75
```
👉 Ergebnis: das neue Masterbild (`base.tif`)
---
## 2. Overviews erzeugen
Anschließend werden echte TIFF-Overviews erstellt.
```bash
gdaladdo -r average base.tif 2 4 8 16 32
```
Dies entspricht den ursprünglichen Pyramidenschritten:
```text
34576 → 17288 → 8644 → …
```
### Vorteile
* gleiche Struktur wie die Originaldaten
* echte TIFF-Pyramiden
* vollständig COG-kompatibel
* deutlich bessere Web-Performance
---
## 3. Cloud Optimized GeoTIFF erzeugen
```bash
gdal_translate \
base.tif \
cog_final.tif \
-of COG \
-co COMPRESS=JPEG \
-co QUALITY=75 \
-co COPY_SRC_OVERVIEWS=YES
```
### Ergebnis
* ca. **1/3 kleinere Dateien**
* interne Tile-Struktur optimiert
* echte COG-Overviews statt proprietärer Pyramiden
---
# Beispiel: `gdalinfo`
```bash
gdalinfo /scans/thinsect/cog_out/1/1.tif
```
---
# GeoTIFF / COG Metadaten
## Allgemeine Informationen
| Eigenschaft | Wert |
| ----------- | --------------------------------- |
| Driver | GTiff / GeoTIFF |
| Datei | `/scans/thinsect/cog_out/1/1.tif` |
| Größe | `37264 × 21744 px` |
| Layout | `COG (Cloud Optimized GeoTIFF)` |
---
## TIFF Metadaten
| Schlüssel | Wert |
| ------------------------ | --------------------------------------------------------- |
| TIFFTAG_IMAGEDESCRIPTION | `Objective Imaging, AppMag = 4 \| MPP = 1.2320 \| Q = 75` |
| TIFFTAG_XRESOLUTION | `8116` |
| TIFFTAG_YRESOLUTION | `8116` |
| TIFFTAG_RESOLUTIONUNIT | `3 (pixels/cm)` |
---
## Image Structure Metadata
| Eigenschaft | Wert |
| ------------------- | ------------ |
| LAYOUT | `COG` |
| SOURCE_COLOR_SPACE | `YCbCr` |
| COMPRESSION | `YCbCr JPEG` |
| INTERLEAVE | `PIXEL` |
| OVERVIEW_RESAMPLING | `AVERAGE` |
| JPEG_QUALITY | `75` |
| JPEGTABLESMODE | `1` |
---
# Overviews
Alle drei RGB-Bänder besitzen identische Pyramidenstufen:
```text
18632 × 10872
9316 × 5436
4658 × 2718
2329 × 1359
1164 × 679
582 × 339
291 × 169
```
Blockgröße:
```text
512 × 512
```
---
# Batch-Konvertierung aller Dünnschliffe
Konvertierung aller TIFF-Dateien in mehreren Verzeichnissen mit GNU Parallel:
```bash
nohup bash -c '
for dir in 49 50 51 52; do
find /scans/thinsect/$dir -name "*.tif" | parallel \
--bar \
--joblog conversion_${dir}.log \
"
file={}
name=\$(basename \"\$file\" .tif)
gdal_translate \
\"GTIFF_DIR:1:\$file\" \
\"/scans/thinsect/cog_out/13/\${name}.tif\" \
-of COG \
-co COMPRESS=JPEG \
-co QUALITY=75 \
-co RESAMPLING=AVERAGE
"
done
' > conversion.out 2>&1 &
```
---
# Index-Datei erzeugen
Nach der Konvertierung:
```bash
gdalinfo /scans/thinsect/cog_out/1/1.tif
```
Danach die JSON-Indexdatei generieren:
```bash
sudo /usr/local/bin/build-cog-map.sh
```
Erzeugt:
```text
/var/www/html/tif-index.json
```
---
# Webviewer
## NGINX konfigurieren
* statische TIFF-Dateien bereitstellen
* CORS aktivieren
* Byte-Range Requests erlauben
---
## OpenLayers Frontend
Anschließend `index.html` mit OpenLayers + GeoTIFF-Plugin erstellen.
---
# Anwendungen
## QGIS-generierte Anwendung
[ardigeos Anwendung](https://ardigeos.geosphere.at/anwendung/index.html?utm_source=chatgpt.com)
---
## Dünnschliffe
Verfügbare Datensätze:
```text
1 13.xxx
```
Beispiel:
[Dünnschliff Viewer](https://ardigeos.geosphere.at/tsv/1?utm_source=chatgpt.com)
---
## Geosphere Maps
[Geosphere Maps Dünnschliffe](https://maps.geosphere.at/de?scale=18055.9548215&x=1781235.399195954&y=6107435.260784891&heading=0&basemap=default&layers=https%3A%2F%2Fgis.geosphere.at%2Fmaps%2Frest%2Fservices%2Fgrenzen%2Fadmin_grenzen_oesterreich%2FMapServer%2Chttps%3A%2F%2Fgis.geosphere.at%2Fmaps%2Frest%2Fservices%2Fsammlungen%2Fduennschliffe%2FMapServer%2F1&visibilities=true%2Ctrue&opacities=1%2C1&relief=true&utm_source=chatgpt.com)
---
# Technologien
* GDAL
* Cloud Optimized GeoTIFF (COG)
* GNU Parallel
* OpenLayers
* QGIS
* NGINX
---
# Ziel
Performante Bereitstellung hochauflösender Dünnschliff-Scans direkt im Browser — ohne klassische Tile-Server-Infrastruktur.