Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Projection and Reprojection of Metadata CSV Information #539

Open
DGalexander opened this issue Dec 12, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@DGalexander
Copy link
Collaborator

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"


@DGalexander DGalexander added the bug Something isn't working label Dec 12, 2024
@github-project-automation github-project-automation bot moved this to Backlog in MapReader Dec 12, 2024
@rwood-97 rwood-97 self-assigned this Dec 12, 2024
@rwood-97 rwood-97 moved this from Backlog to Upcoming in MapReader Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Upcoming
Development

No branches or pull requests

2 participants