GeoServer Management
Guide for managing GeoServer integration in EO-Toolkit.
GeoServer Setup
Installation
- Download GeoServer from geoserver.org
- Install and configure
- Start GeoServer service
- Access admin at
http://localhost:8080/geoserver
Workspace Configuration
- Log into GeoServer admin
- Navigate to Workspaces
- Create workspace:
etoolkit - Set as default if needed
User Configuration
Set GeoServer credentials in your .env file (never commit real credentials):
Data Upload Process
Single Upload
- Use Django Admin panel
- Go to Geo Data Uploads
- Add new upload
- System automatically:
- Creates store
- Publishes layer
- Configures WMS
Bulk Upload
-
Organize files:
-
Create metadata JSON
- Place at
/staticData/geoserver_data.json - Trigger bulk upload from admin
Layer Management
Viewing Layers
- List in Django Admin
- View in GeoServer admin
- Check WMS availability
- Verify layer properties
Updating Layers
- Edit metadata in Django Admin
- Replace data file (re-upload)
- Update styles (upload new SLD)
- Modify layer properties in GeoServer
Deleting Layers
- Delete from Django Admin
- Automatic cleanup:
- GeoServer layer removed
- Store deleted
- Files removed
Style Management
SLD Files
- Upload with data
- Applied automatically
- Can be updated
- Supports various styles
Default Styles
- Applied if no SLD provided
- GeoServer default styles
- Can be customized
Troubleshooting
Connection Issues
- Verify GeoServer is running
- Check URL and credentials
- Test connection manually
- Review network settings
Upload Failures
- Check file format
- Verify permissions
- Check workspace exists
- Review GeoServer logs
Helper script: TIFF to COG
For efficient web visualization and GeoServer uploads, GeoTIFFs can be converted to Cloud Optimized GeoTIFF (COG) format. Use the script below to compress GeoTIFFs into COG format (tiled, DEFLATE-compressed) using GDAL.
Prerequisites
- GDAL installed and available on your
PATH(e.g.gdal_translate). - On Ubuntu:
sudo apt-get install gdal-bin
How to use
- Prepare your folder structure (same as for bulk upload):
geoserver_data/
├── DatasetName1/
│ └── DatasetName1.tif
├── DatasetName2/
│ └── DatasetName2.tif
...
Each subfolder name must match the .tif filename (e.g. folder Niger_LULC with Niger_LULC.tif).
-
Copy the script from the collapsible block below. Save as
gdal_tiff_to_cog.py. Setbase_dirinside the script to your data path (e.g."/path/to/etoolkit/media/geoserver_data"or keep"geoserver_data"if running from the directory that contains it). -
Run the script:
- The script will:
- Find each
{folder_name}.tifunderbase_dir - Compress it to COG (tiled, DEFLATE) as
{folder_name}_compressed.tif - Replace the original file with the compressed one
View script: gdal_tiff_to_cog.py
Copy the script below, save as gdal_tiff_to_cog.py, set base_dir to your geoserver_data path, and run with python gdal_tiff_to_cog.py.
# This script compresses all GeoTIFF files within subfolders
# into Cloud Optimized GeoTIFF (COG) format using GDAL. The optimized files are suitable
# for efficient web visualization and upload to GeoServer.
import os
import subprocess
# Path to the main directory containing subfolders
base_dir = "geoserver_data"
# Loop through each subdirectory
for folder in os.listdir(base_dir):
folder_path = os.path.join(base_dir, folder)
if os.path.isdir(folder_path):
tif_filename = f"{folder}.tif"
tif_path = os.path.join(folder_path, tif_filename)
if os.path.isfile(tif_path):
compressed_path = os.path.join(folder_path, f"{folder}_compressed.tif")
print(f"Compressing: {tif_path}")
cmd = [
"gdal_translate",
"-co", "COMPRESS=DEFLATE",
"-co", "TILED=YES",
"-of", "GTiff",
tif_path,
compressed_path
]
try:
subprocess.check_call(cmd)
os.replace(compressed_path, tif_path)
print(f"Replaced with compressed: {tif_path}")
except subprocess.CalledProcessError as e:
print(f"Compression failed for {tif_path}: {e}")
else:
print(f"No .tif found: {tif_path}")
Bulk geoserver data upload
1. first All data files must be organized under:
/media/geoserver_data/<folder_name>/
Each dataset should have:
- GeoTIFF or Shapefile ZIP
- .sld file for styling
- Thumbnail image
media/geoserver_data/Niger_LULC/
├── Niger_LULC.tif
├── Niger_LULC.sld
├── Niger_LULC.png
2. Place the bulk metadata JSON at:
/staticData/geoserver_data.json
3. What the Script Does
- Loads and parses geoserver_data.json
- For each entry:
- Checks if a dataset with the same name already exists
- Validates file paths
- Saves a new GeoDataUpload model instance
- Uploads the data and style to GeoServer
4. Triggering Upload
- Go to Geo Data Upload in Django Admin
- Click the top-right button: “Trigger Bulk Upload”