RASTER_PATTERN in terracotta ingest
zufryy opened this issue · 2 comments
zufryy commented
Hi All,
So I have two files with these filename
- WBF0_Demo_1x1_Int3_Sm0_Mean.tiff
- WBF0_Demo_1x1_Int3_Sm0_Mean_grad.tiff
When using this command, "terracotta ingest {name}.tif -o test.sqlite"
it gave me these error message :
Error: Invalid value for 'RASTER_PATTERN': Given pattern matches no files
Is it possible to use the full filename as the raster pattern variable when running the ingest ?
dionhaefner commented
Nope, not possible from the command line. It's pretty simple from the Python API, though. This should do it:
import os
import glob
from terracotta import get_driver
DB_NAME = "test.sqlite"
KEYS = ["name"]
RASTERFILES = glob.glob("*.tif")
driver = get_driver(DB_NAME)
if not os.path.isfile(DB_NAME):
driver.create(KEYS)
for raster_path in RASTERFILES:
raster_filename = os.path.basename(raster_path)
driver.insert(raster_filename, raster_path)
zufryy commented
Perfect, thanks for the script