Skip to content

Issue with Projection and Reprojection of Metadata CSV Information #539

@DGalexander

Description

@DGalexander

The current implementation does not correctly project or reproject the metadata CSV information for bounding boxes. When working with metadata that specifies bounding boxes in EPSG:4326 (WGS 84), the CRS transformation to EPSG:27700 (British National Grid) was not applied correctly. As a result, the bounding box coordinates in the maps.parents object are misaligned with the expected CRS.

To Reproduce:

  1. Load a metadata CSV file with bounding box coordinates in EPSG:4326.
  2. Add the metadata to the maps.parents object using maps.add_metadata.
  3. Attempt to reproject the bounding box coordinates to EPSG:27700.
  4. Observe that the coordinates are not correctly transformed, and subsequent operations using these coordinates fail or are misaligned.

Expected behavior
The bounding box coordinates from the metadata CSV should be transformed correctly from EPSG:4326 to EPSG:27700 using a robust CRS transformation method. Once transformed, the coordinates should match the CRS of the parent images (EPSG:27700).

Desktop:

  • OS: [Ubuntu 20.04]
  • PythonVersion [3.12]

Additional context
To resolve this issue, the following code snippet was added to ensure the bounding box coordinates are correctly transformed:

from pyproj import Transformer

transformer = Transformer.from_crs("EPSG:4326", "EPSG:27700", always_xy=True)

for parent_id in maps.list_parents():
    coords = maps.parents[parent_id]["coordinates"]
    xmin, ymin, xmax, ymax = coords
    new_coords = transformer.transform_bounds(xmin, ymin, xmax, ymax)
    maps.parents[parent_id]["coordinates"] = new_coords
    maps.parents[parent_id]["crs"] = "EPSG:27700"


Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions