DHI / terracotta

A light-weight, versatile XYZ tile server, built with Flask and Rasterio :earth_africa:
https://terracotta-python.readthedocs.org
MIT License
655 stars 69 forks source link

use postgresql conn string not working #340

Open beckietech opened 5 days ago

beckietech commented 5 days ago

terracotta, version 0.8.3

config.toml: DRIVER_PATH = "postgresql+psycopg2://postgres:[password]@localhost:5432/terracotta" DRIVER_PROVIDER = postgresql

terracotta -c /home/bill/config.toml ingest /home/bill/optimized/{date}_forecast.tif -o /home/bill/test.sqlite Uncaught exception! Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 511, in loads ret = decoder.load_line(line, currentlevel, multikey, File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 778, in load_line value, vtype = self.load_value(pair[1], strictly_valid) File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 910, in load_value raise ValueError("This float doesn't have a leading " ValueError: This float doesn't have a leading digit

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.9/dist-packages/terracotta/scripts/cli.py", line 63, in entrypoint cli(obj={}) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1157, in call return self.main(*args, kwargs) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1077, in main with self.make_context(prog_name, args, extra) as ctx: File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 943, in make_context self.parse_args(ctx, args) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1644, in parse_args rest = super().parse_args(ctx, args) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 1408, in parse_args value, args = param.handle_parse_result(ctx, opts, args) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2400, in handle_parse_result value = self.process_value(ctx, value) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2356, in process_value value = self.type_cast_value(ctx, value) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2344, in type_cast_value return convert(value) File "/usr/local/lib/python3.9/dist-packages/click/core.py", line 2316, in convert return self.type(value, param=self, ctx=ctx) File "/usr/local/lib/python3.9/dist-packages/click/types.py", line 83, in call return self.convert(value, param, ctx) File "/usr/local/lib/python3.9/dist-packages/terracotta/scripts/click_types.py", line 129, in convert return dict(toml.load(value)) File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 134, in load return loads(ffile.read(), _dict, decoder) File "/usr/local/lib/python3.9/dist-packages/toml/decoder.py", line 514, in loads raise TomlDecodeError(str(err), original, pos) toml.decoder.TomlDecodeError: This float doesn't have a leading digit (line 2 column 1 char 82)

am I doing it wrong? please advise! Thank you!

dionhaefner commented 5 days ago

What's in your config.toml file? Looks like Terracotta can't parse it.

beckietech commented 5 days ago

As I put it in config.toml file. No more and no less, and it’s the only example I found.Best regards, Bill ShihDion Häfner @.***> 於 2024年7月3日 15:57 寫道: What's in your config.toml file? Looks like Terracotta can't parse it.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

dionhaefner commented 5 days ago

You forgot to quote DRIVER_PROVIDER:

DRIVER_PROVIDER = "postgresql"
beckietech commented 4 days ago

@dionhaefner, thnak you! After added quotes, it started ingesting!

However, I didn't see changes added in target database. Can you show me some example what to expect after this action?

Best regards,

beckietech commented 4 days ago

and also when i brwose the map, on upper right corner, it says: Search for datasets ... and spinning. I don't know if this is correct.

dionhaefner commented 4 days ago

terracotta ingest can only ingest into SQLite databases. For advanced use cases like postgres, please use the Python API.

beckietech commented 3 days ago

@dionhaefner, thank you. Since I am newbee to GIS, when I look at python code, I wonder how can I get keys from raster, for example: KEYS = ["type", "rp", "rcp", "epoch", "gcm"] ; KEYS = ('sensor', 'tile', 'date', 'band'), is there tools / methods to describe a raster file?

dionhaefner commented 3 days ago

Keys are arbitrary values that identify a dataset - you are free to choose whatever you want. In your example ingest command, the only key would be date.