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

Add ability to crop raster source extent #1030

Merged
merged 15 commits into from
Oct 20, 2020
Merged

Conversation

AdeelH
Copy link
Collaborator

@AdeelH AdeelH commented Oct 14, 2020

Overview

Allows different portions of the same scene image to be used in different dataset splits.

  • Adds an extent_crop field to RasterSourceConfig that is passed on to the RasterSources.
    extent_crop: CropOffsets = Field(
    None,
    description='Relative offsets '
    '(skip_top, skip_left, skip_bottom, skip_right) for cropping '
    'the extent of the raster source. Useful for splitting a scene into '
    'different dataset splits. E.g. if you want to use the top 80% of the '
    'image for training and the bottom 20% for validation you can pass '
    'extent_crop=CropOffsets(skip_bottom=0.20) to the raster source in '
    'the training scene and extent_crop=CropOffsets(skip_top=0.80) to the '
    'raster source in the validation scene. Defaults to None i.e. no '
    'cropping.')
  • Updates RaterioSource and MultiRasterSource to make use of extent_crop.
  • Some minor improvements to Box().
  • Adds unit tests.

Checklist

  • Updated docs/changelog.rst
  • Added needs-backport label if PR is bug fix that applies to previous minor release
  • Ran scripts/format_code and committed any changes
  • Documentation updated if needed
  • PR has a name that won't get you publicly shamed for vagueness

Testing Instructions

  • How to test this PR
    • See new unit tests

Copy link
Contributor

@lewfish lewfish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tests! It's a little confusing that the coordinate system is flipped for top vs. bottom and left vs. right. Eg. top=0.2 and bottom=0.8 refer to the same point. Being a little more explicit in the docs would be helpful.

@AdeelH
Copy link
Collaborator Author

AdeelH commented Oct 19, 2020

Thanks for the tests! It's a little confusing that the coordinate system is flipped for top vs. bottom and left vs. right. Eg. top=0.2 and bottom=0.8 refer to the same point. Being a little more explicit in the docs would be helpful.

(top=0.2, left=0.0, bottom=0.0, right=0.0) means skip the top 20% of the image and use the bottom 80%.

Untitled drawing

(top=0.0, left=0.0, bottom=0.8, right=0.0) means use the top 20% and skip the bottom 80% of the image.
Copy of Untitled drawing

@AdeelH
Copy link
Collaborator Author

AdeelH commented Oct 19, 2020

I have updated it to use a NamedTuple and elaborated the usage a bit more in the description.

@AdeelH
Copy link
Collaborator Author

AdeelH commented Oct 19, 2020

blank comment

@AdeelH AdeelH requested a review from lewfish October 19, 2020 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants