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

Polygon tool library #13

Open
10 tasks
mpaget opened this issue Feb 13, 2023 · 1 comment
Open
10 tasks

Polygon tool library #13

mpaget opened this issue Feb 13, 2023 · 1 comment

Comments

@mpaget
Copy link

mpaget commented Feb 13, 2023

Polygon tool library

  • Checks and balances
  • Accepted input/output types
  • Simple polygons
  • Geopolygons
  • Statistic types
    • median cover
    • benchmark analyses. See Figs 7-10 (Ground cover milestone 3 report, 2022-12-21, p.12-14) - Not covered by the project (future work)
      • Request a code/tech review when appropriate
    • NRM/LGA reports
  • Donuts
@mpaget
Copy link
Author

mpaget commented Feb 14, 2023

datacube-wps

  • input_data()
    1. dc "bag" for polygon > find_datasets
    2. box (from bag) for output resolution > xarray
    3. get mask rasterio.features.geometry_mask()
      • all_touched = False
      • invert = True
    4. apply to xarray (where)
    5. return xarray

rasterio.features.geometry_mask()

  • [geom.to_crs(geobox.crs)], # what if geom is a list already?
  • geometries = iterable geoms
  • out_shape = target nd.array shape
  • all_touched = False (centre within geom), True (any part of pixel in geom)
  • invert = False (mask True is outside geo), True (mask True is inside geom) # check apply mask

To do

  • Check geom input
  • Check mask
    • set all_touched > PolygonDrill class variable
      • default in class constructor PolygonDrill().mask_all_touched = True|**False**
      • set in product/tool-specific PolygonDrill subclass if writable, else add an @x.setter or make it a param
    • invert and apply settings
      • True (mask True is inside geom): rasterio.features.geometry_mask()
      • xarray.where (mask True is preserve. Use nodata or NaN for False): PolygonDrill().input_data()

Out of scope for now (to be revisited if/when needed)

  • rasterize performance
    • will check valid geom > return value/exception?
    • The shapes iterator will be materialized to a Python list and another C copy of that list will be made
    • For maximum speed, ensure that GDAL_CACHEMAX is larger than the size of out or out_shape.
  • other rasterio functions we could consider

@mpaget mpaget mentioned this issue Feb 20, 2023
28 tasks
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

No branches or pull requests

1 participant