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

PERF: Combine similar raster requests #65

Open
caspervdw opened this issue Aug 26, 2020 · 0 comments
Open

PERF: Combine similar raster requests #65

caspervdw opened this issue Aug 26, 2020 · 0 comments

Comments

@caspervdw
Copy link
Collaborator

This is an optimization that will lead to less raster IO in some cases, especially when raster.Smooth is used.

In some complex graphs, we have the situation that the result of raster.Smooth is compared with the original. A contrived example:

from dask_geomodeling.raster import RasterFileSource, Smooth

source = RasterFileSource("/path/to/file")
result = Smooth(source) - source

Requesting data from this result will give 2 different raster requests:

>>> result.get_compute_graph(mode="vals", width=10, height=10, bbox=(0, 0, 10, 10), projection="EPSG:28992")[0]
{'rasterfilesource_36ee9e455dda8d91541eec2dd5dbd6b0': (<function dask_geomodeling.raster.sources.RasterFileSource.process(process_kwargs)>,
  {'mode': 'vals',
   'url': 'file:///home/casper/code/lizard-nxt/var/m_37hn1_int.tif',
   'bbox': (-1.0, -1.0, 11.0, 11.0),
   'width': 12,
   'height': 12,
   'first_band': 0,
   'last_band': 0,
   'dtype': numpy.float32,
   'fillvalue': 3.4028235e+38}),
 'smooth_0655a67553d8dc3aa40d4acf491f2681': (<function dask_geomodeling.raster.spatial.Smooth.process(data, process_kwargs=None)>,
  'rasterfilesource_36ee9e455dda8d91541eec2dd5dbd6b0',
  {'smooth_mode': 'exact', 'fill': 0, 'size': [1.0, 1.0]}),
 'rasterfilesource_8de8049cd52f1027d33a5500981fd9d3': (<function dask_geomodeling.raster.sources.RasterFileSource.process(process_kwargs)>,
  {'mode': 'vals',
   'url': 'file:///home/casper/code/lizard-nxt/var/m_37hn1_int.tif',
   'bbox': (0, 0, 10, 10),
   'width': 10,
   'height': 10,
   'first_band': 0,
   'last_band': 0,
   'dtype': numpy.float32,
   'fillvalue': 3.4028235e+38}),
 'subtract_23cc6703fd2c2bf19b6563daccad808d': (<function dask_geomodeling.raster.elemwise.wrap_math_process_func.<locals>.math_process_func>,
  {'dtype': 'float32', 'fillvalue': 3.4028234663852886e+38},
  'smooth_0655a67553d8dc3aa40d4acf491f2681',
  'rasterfilesource_8de8049cd52f1027d33a5500981fd9d3')}

The two rastersource requests obviously can be derived from one single request. Can we write a generic optimization function (see https://docs.dask.org/en/latest/optimize.html) to merge similar rastersource requests?

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