Deadwood-ai / deadwood-api

Main FastAPI application for the deadwood backend
GNU General Public License v3.0
0 stars 0 forks source link

Error while querying OSM for admin level names #43

Closed JesJehle closed 1 month ago

JesJehle commented 2 months ago

A lot of these:

[
  {
    "id": 7551,
    "created_at": "2024-09-06T11:44:12.368045+00:00",
    "name": "processor",
    "level": "ERROR",
    "message": "An error occurred while querying OSM for admin level names of dataset_id: 1238: Error: line 2: static error: For the attribute "lat" of the element "coord-query" the only allowed values are floats between -90.0 and 90.0. \nError: line 2: static error: For the attribute "lon" of the element "coord-query" the only allowed values are floats between -180.0 and 180.0. ",
    "origin": "upload.py",

from id: 1143 upwards.

cmosig commented 2 months ago

Looks like the query coords are off. Hmmm

cmosig commented 2 months ago

The issue is that there is no reprojection being done. Some orthophotos are in a CRS that is not EPSG:4326. The coordinates are then out of range for EPSG:4326.

cmosig commented 2 months ago

As far as I remember, the consensus was that we store the incoming orthophotos in the CRS that we get it in for maximum accuracy and then reproject it to 4326 for the visualization.

cmosig commented 2 months ago

For the bounds, which is where the OSM query gets its data from, we need to change this line...

https://github.com/Deadwood-ai/deadwood-api/blob/e8a41af960c798abb0afe4c0ea0cf362a7cacbfc/src/routers/upload.py#L107C1-L107C28

...to bounds = rasterio.warp.transform_bounds(src_crs=src.crs, dst_crs="EPSG:4326", *src.bounds)

https://rasterio.readthedocs.io/en/latest/api/rasterio.warp.html#rasterio.warp.transform_bounds

cmosig commented 2 months ago

For the COGs, there does not seem to be a reprojection hapenning here:

https://github.com/Deadwood-ai/deadwood-api/blob/439d7cce8f5e2dcf0c4918429b798ea3c19ac0f3/src/deadwood/cog.py#L45

I think the correct flag is -t_crs=EPSG:4326

JesJehle commented 2 months ago

Perfect! We can rerun the process after the tiffs are imported.