-
-
Notifications
You must be signed in to change notification settings - Fork 366
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
MapboxTilesRenderer #1024
base: main
Are you sure you want to change the base?
MapboxTilesRenderer #1024
Conversation
Create MapboxTilesRenderer for outputting TMS tile sets as a mbtiles file (a SQLite database following the MBTiles 1.3 specification).
Compute min/max of span in-place instead of building a list of all values, then computing using dask. Use dimensions of data array for label based indexing, instead of hard-coded x, y labels (which forced input coordinate columns to be named x, y).
Include capability to provide a local_cache_path. If provided, the aggregation for the super tiles will be stored locally as a NetCDF file (instead of keeping all these in memory, which eventually overflows memory at high zoom levels). This allows most of the processing to now be done completely out of core.
Included an additional capability for out-of-core processing. An optional parameter, local_cache_path, can be provided. If provided, the aggregates generated by Datashader for the super tiles will be persisted to that local cache as a NetCDF file, instead of keeping all these intermediate results in memory. These aggregates will then be individually loaded by Dask workers to generate the individual tiles. This allows tile generation for larger datasets at much higher zoom levels, being only dependent on your disk space. |
Use the netCDF4 library for writing/loading XArray DataArrays from cache, since it properly handles unsigned data types. Optional dependency that will raise an error if not installed when the caching feature is used.
Very cool! We're working on fixing the tests, at which point we should be able to review this. Let me know if you're still planning to add more amazing features! |
Allow updates to an existing mbtiles file, inserting or replacing rows in the SQLite database and make SQL statements consistent.
That's all the features I currently have planned. I'd considered supporting output to pmtiles, either directly, or as a conversion step from the mbtiles format, but that can wait until that format is more widely adopted. |
calculate_zoom_level_stats moved to a parallel implementation with dask bags, that does not cache the super tiles in memory. If a local_cache_path is provided, the super tiles will be cached to disk as NetCDF files. Super tiles will then be either recomputed during the render_super_tiles function, or loaded from the local cache. Note: If using the Datashader render_tiles, the scheduler for Dask should be configured to 'threads' (when running on local) to avoid Dask bag computations from copying the input DataFrame to multiple processes, which will increase memory overhead. If outputting tiles to the MBTiles format, the num_workers should be tuned to prevent the SQLite database from locking during transactions. Both of these can be configured using dask.config.set(scheduler='threads', num_workers=4).
Handle setup of output paths.
Codecov Report
@@ Coverage Diff @@
## main #1024 +/- ##
==========================================
- Coverage 84.52% 84.24% -0.29%
==========================================
Files 35 35
Lines 8369 8643 +274
==========================================
+ Hits 7074 7281 +207
- Misses 1295 1362 +67
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Implement MapboxTilesRenderer, which adds support for outputting TMS tilesets as a mbtiles file (a SQLite database following the MBTiles 1.3 schema. This file can then be easily used in GIS clients, such as QGIS, though the primary motivation was creating an output format that could easily be used by GeoServer (using the MBTiles community extension).
Example using data from ACLED (Armed Conflict Location & Event Data):
ACLED.mbtiles loaded into QGIS:
The render_tiles function now has two big changes to it's behavior.