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

Update geojson and geotiff saving #318

Merged
merged 12 commits into from
Jan 5, 2024
Merged

Update geojson and geotiff saving #318

merged 12 commits into from
Jan 5, 2024

Conversation

rwood-97
Copy link
Collaborator

@rwood-97 rwood-97 commented Dec 7, 2023

Summary

At the moment, the code can output patches as geojson and geotiffs. These methods rely on coordinates being saved in the patch/parent metadata.

Problems with this come from:

  • Coordinates are saved as a list in the patch/parent dataframes ([minx, miny, maxx, maxy]) so when reading from a csv, these coords are read as a string and not a python list object. This is a problem when indexing the coord list later on.
  • In an earlier version of mapreader, the parent coordinates we calculated incorrectly. If these coords are in your parent dataframe it is not possible to recalculate using other info saved for hte parent image (i.e. the grid bounding box used for downloading)
  • The save to geojson method uses a shapely polygon (generated from coordinates) for saving geometry instead of the coordinates. When reading from a csv, the polygon is read as a string not a polygon object.

Describe your changes

This PR:

  • Adds method to apply literal_eval to all columns in dataframe using try/except. This fixes problems with tuples/coordinates/etc being read as strings. i.e. fixes problem with coords list.
  • Adds method of regenerating coordinates from grid bounding boxes. i.e. to fix previously incorrect coords from bug in earlier version of MapReader.
  • Recreates shapely polygon from string if needed
  • Adds method for saving parent images as geotiffs. This is helpful because both parent/patch images can then be loaded into QGIS or other geospatial software and compared to a basemap to check that coords are as expected.

Checklist before assigning a reviewer (update as needed)

  • Self-review code
  • Ensure submission passes current tests
  • Add tests
  • Update relevant docs

To do:

  • Add method to ensure single band images are saved correctly for save_parents_as_geotiffs()

Reviewer checklist

Please add anything you want reviewers to specifically focus/comment on.

  • Everything looks ok?

@codecov-commenter
Copy link

codecov-commenter commented Jan 2, 2024

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (2236f3e) 56.45% compared to head (af7df2d) 58.69%.
Report is 3 commits behind head on main.

Files Patch % Lines
mapreader/load/images.py 87.14% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #318      +/-   ##
==========================================
+ Coverage   56.45%   58.69%   +2.24%     
==========================================
  Files          35       35              
  Lines        5875     6092     +217     
==========================================
+ Hits         3317     3576     +259     
+ Misses       2558     2516      -42     
Flag Coverage Δ
unittests 58.69% <97.77%> (+2.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rwood-97 rwood-97 changed the base branch from main to dev January 5, 2024 15:23
@rwood-97 rwood-97 merged commit 7eb659e into dev Jan 5, 2024
3 checks passed
@rwood-97 rwood-97 mentioned this pull request Jan 5, 2024
5 tasks
@rwood-97 rwood-97 deleted the fix_save_to_geojson branch April 5, 2024 13:44
@rwood-97 rwood-97 added bug Something isn't working new feature labels May 13, 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 new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants