Skip to content

Commit f59b041

Browse files
committed
update docs
1 parent e6aeec6 commit f59b041

8 files changed

Lines changed: 63 additions & 20 deletions

File tree

docs/mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ nav:
116116
- titiler.mosaic:
117117
- factory: api/titiler/mosaic/factory.md
118118
- errors: api/titiler/mosaic/errors.md
119+
- extensions: api/titiler/mosaic/extensions.md
119120
- models:
120121
- responses: api/titiler/mosaic/models/responses.md
121122
- titiler.xarray:
122123
- io: api/titiler/xarray/io.md
123124
- dependencies: api/titiler/xarray/dependencies.md
124125
- extensions: api/titiler/xarray/extensions.md
125126
- factory: api/titiler/xarray/factory.md
127+
- main: api/titiler/xarray/main.md
126128

127129
- Deployment:
128130
- Amazon Web Services:

docs/src/advanced/Extensions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ class FactoryExtension(metaclass=abc.ABCMeta):
6363

6464
- Goal: adds `/dataset/`, `/dataset/keys` and `/datasets/dict` endpoints which return metadata about a multidimensional Dataset (not a DataArray)
6565

66+
#### titiler.mosaic.extensions.MosaicJSONExtension
67+
68+
- Goal: adds `/` and `/validate` endpoints to return MosaicJSON content and validate external mosaics.
69+
6670
## How To
6771

6872
### Use extensions

docs/src/advanced/customization.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ COGTilerWithCustomTMS = TilerFactory(supported_tms=tms)
9595
### Add a MosaicJSON creation endpoint
9696
```python
9797

98-
from dataclasses import dataclass
9998
from typing import List, Optional
10099

100+
from attrs import define
101+
102+
from cogeo_mosaic.backends import MosaicBackend as MosaicJSONBackend
101103
from titiler.mosaic.factory import MosaicTilerFactory
102104
from titiler.core.errors import BadRequestError
103105
from cogeo_mosaic.mosaic import MosaicJSON
@@ -128,9 +130,11 @@ class UpdateMosaicJSON(BaseModel):
128130
add_first: bool = True
129131

130132

131-
@dataclass
133+
@define(kw_only=True)
132134
class CustomMosaicFactory(MosaicTilerFactory):
133135

136+
backend: Type[MosaicJSONBackend] = MosaicJSONBackend
137+
134138
def register_routes(self):
135139
"""Update the class method to add create/update"""
136140
super().register_routes()
@@ -162,8 +166,10 @@ class CustomMosaicFactory(MosaicTilerFactory):
162166

163167
# Write the MosaicJSON using a cogeo-mosaic backend
164168
with rasterio.Env(**env):
165-
with self.reader(
166-
body.url, mosaic_def=mosaic, reader=self.dataset_reader
169+
with self.backend(
170+
body.url,
171+
mosaic_def=mosaic,
172+
reader=self.dataset_reader
167173
) as mosaic:
168174
try:
169175
mosaic.write(overwrite=body.overwrite)
@@ -185,7 +191,7 @@ class CustomMosaicFactory(MosaicTilerFactory):
185191
):
186192
"""Update an existing MosaicJSON"""
187193
with rasterio.Env(**env):
188-
with self.reader(body.url, reader=self.dataset_reader) as mosaic:
194+
with self.backend(body.url, reader=self.dataset_reader) as mosaic:
189195
features = get_footprints(body.files, max_threads=body.max_threads)
190196
try:
191197
mosaic.update(features, add_first=body.add_first, quiet=True)

docs/src/advanced/endpoints_factories.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -301,35 +301,39 @@ app.include_router(colormap.router)
301301

302302
class: `titiler.mosaic.factory.MosaicTilerFactory`
303303

304-
Endpoints factory for mosaics, built on top of [MosaicJSON](https://github.com/developmentseed/mosaicjson-spec).
304+
Endpoints factory for mosaics.
305305

306306
#### Attributes
307307

308-
- **backend**: `cogeo_mosaic.backends.BaseBackend` Mosaic backend. Defaults to `cogeo_mosaic.backend.MosaicBackend`.
308+
- **backend**: `rio_tiler.mosaic.backends.BaseBackend` Mosaic backend.
309309
- **backend_dependency**: Dependency to control options passed to the backend instance init. Defaults to `titiler.core.dependencies.DefaultDependency`
310310
- **dataset_reader**: Dataset Reader. Defaults to `rio_tiler.io.Reader`
311311
- **reader_dependency**: Dependency to control options passed to the reader instance init. Defaults to `titiler.core.dependencies.DefaultDependency`
312-
- **path_dependency**: Dependency to use to define the dataset url. Defaults to `titiler.mosaic.factory.DatasetPathParams`.
312+
- **path_dependency**: Dependency to use to define the dataset. Defaults to `titiler.mosaic.factory.DatasetPathParams`.
313313
- **assets_accessor_dependency**: Dependency to define options to be forwarded to the backend `get_assets` method. Defaults to `titiler.core.dependencies.DefaultDependency`.
314314
- **layer_dependency**: Dependency to define band indexes or expression. Defaults to `titiler.core.dependencies.BidxExprParams`.
315315
- **dataset_dependency**: Dependency to overwrite `nodata` value, apply `rescaling` and change the `I/O` or `Warp` resamplings. Defaults to `titiler.core.dependencies.DatasetParams`.
316316
- **tile_dependency**: Dependency to define `buffer` and `padding` to apply at tile creation. Defaults to `titiler.core.dependencies.TileParams`.
317317
- **process_dependency**: Dependency to control which `algorithm` to apply to the data. Defaults to `titiler.core.algorithm.algorithms.dependency`.
318+
- **stats_dependency**: Dependency to define options for *rio-tiler*'s statistics method used in `/statistics` endpoints. Defaults to `titiler.core.dependencies.StatisticsParams`.
319+
- **histogram_dependency**: Dependency to define *numpy*'s histogram options used in `/statistics` endpoints. Defaults to `titiler.core.dependencies.HistogramParams`.
318320
- **colormap_dependency**: Dependency to define the Colormap options. Defaults to `titiler.core.dependencies.ColorMapParams`
319321
- **render_dependency**: Dependency to control output image rendering options. Defaults to `titiler.core.dependencies.ImageRenderingParams`
320322
- **pixel_selection_dependency**: Dependency to select the `pixel_selection` method. Defaults to `titiler.mosaic.factory.PixelSelectionParams`.
321323
- **environment_dependency**: Dependency to define GDAL environment at runtime. Default to `lambda: {}`.
322324
- **supported_tms**: List of available TileMatrixSets. Defaults to `morecantile.tms`.
323-
- **supported_tms**: List of available TileMatrixSets. Defaults to `morecantile.tms`.
324-
- **templates**: *Jinja2* templates to use in endpoints. Defaults to `titiler.core.factory.DEFAULT_TEMPLATES`.
325+
- **render_func**: Image rendering method. Defaults to `titiler.core.utils.render_image`.
325326
- **optional_headers**: List of OptionalHeader which endpoints could add (if implemented). Defaults to `[]`.
327+
- **templates**: *Jinja2* templates to use in endpoints. Defaults to `titiler.core.factory.DEFAULT_TEMPLATES`.
326328
- **add_viewer**: Add `/{TileMatrixSetId}/map.html` endpoints to the router. Defaults to `True`.
329+
- **add_statistics**: Add `POST - /statistics` endpoints to the router. Defaults to `False`.
330+
- **add_part**: Add `/bbox` and `/feature` endpoints to the router. Defaults to `False`.
331+
- **conforms_to**: Set of conformance classes the Factory implement
327332

328333
#### Endpoints
329334

330335
| Method | URL | Output | Description
331336
| ------ | --------------------------------------------------------------- |--------------------------------------------------- |--------------
332-
| `GET` | `/` | JSON [MosaicJSON][mosaic_model] | return a MosaicJSON document
333337
| `GET` | `/info` | JSON ([Info][mosaic_info_model]) | return mosaic's basic info
334338
| `GET` | `/info.geojson` | GeoJSON ([InfoGeoJSON][mosaic_geojson_info_model]) | return mosaic's basic info as a GeoJSON feature
335339
| `GET` | `/tiles` | JSON | List of OGC Tilesets available
@@ -342,6 +346,30 @@ Endpoints factory for mosaics, built on top of [MosaicJSON](https://github.com/d
342346
| `GET` | `/point/{lon},{lat}` | JSON ([Point][mosaic_point]) | return pixel value from a MosaicJSON dataset
343347
| `GET` | `/point/{lon},{lat}/assets` | JSON | return list of assets intersecting a point
344348
| `GET` | `/bbox/{minx},{miny},{maxx},{maxy}/assets` | JSON | return list of assets intersecting a bounding box
349+
| `POST` | `/statistics` | GeoJSON ([Statistics][stats_geojson_model]) | return info and statistics for a dataset **Optional**
350+
| `GET` | `/bbox/{minx},{miny},{maxx},{maxy}[/{width}x{height}].{format}` | image/bin | create an image from part of a dataset **Optional**
351+
| `POST` | `/feature[/{width}x{height}][.{format}]` | image/bin | create an image from a geojson feature **Optional**
352+
353+
354+
```python
355+
from fastapi import FastAPI
356+
357+
from titiler.mosaic.factory import MosaicTilerFactory
358+
from cogeo_mosaic.backends import MosaicBackend as MosaicJSONBackend
359+
360+
# Create FastAPI application
361+
app = FastAPI()
362+
363+
# Create router and register set of endpoints
364+
mosaic = TilerFactory(
365+
backend=MosaicJSONBackend,
366+
add_part=True, # default to False
367+
add_statistics=True, # default to False
368+
)
369+
370+
# add router endpoint to the main application
371+
app.include_router(mosaic.router)
372+
```
345373

346374
## titiler.xarray
347375

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: titiler.mosaic.extensions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: titiler.xarray.main

src/titiler/mosaic/README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
<img style="max-width:400px" src="https://github.com/user-attachments/assets/14b92588-14eb-4b37-b862-cc5d0d8015c9"/>
44

5-
Adds support for [MosaicJSON](https://github.com/developmentseed/mosaicjson-spec) in Titiler.
6-
7-
> MosaicJSON is an open standard for representing metadata about a mosaic of Cloud-Optimized GeoTIFF (COG) files.
8-
9-
Ref: https://github.com/developmentseed/mosaicjson-spec
5+
Adds support for Mosaic in Titiler. `Mosaic's` backend needs to be built on top of rio-tiler's Mosaic Backend https://cogeotiff.github.io/rio-tiler/advanced/mosaic_backend/
106

117
## Installation
128

@@ -19,6 +15,9 @@ python -m pip install titiler.mosaic
1915
# Or from sources
2016
git clone https://github.com/developmentseed/titiler.git
2117
cd titiler && python -m pip install -e src/titiler/core -e src/titiler/mosaic
18+
19+
# install cogeo-mosaic for MosaicJSON support
20+
python -m pip install cogeo-mosaic
2221
```
2322

2423
## How To
@@ -27,13 +26,15 @@ cd titiler && python -m pip install -e src/titiler/core -e src/titiler/mosaic
2726
from fastapi import FastAPI
2827
from titiler.mosaic.factory import MosaicTilerFactory
2928

29+
from cogeo_mosaic.backends import MosaicBackend
30+
3031
# Create a FastAPI application
3132
app = FastAPI(
3233
description="A Mosaic tile server",
3334
)
3435

35-
# Create a set of MosaicJSON endpoints
36-
mosaic = MosaicTilerFactory()
36+
# Create a set of Mosaic endpoints using MosaicJSON backend from cogeo-mosaic project
37+
mosaic = MosaicTilerFactory(backend=MosaicBackend)
3738

3839
# Register the Mosaic endpoints to the application
3940
app.include_router(mosaic.router, tags=["MosaicJSON"])
@@ -48,6 +49,7 @@ titiler/
4849
└── titiler/mosaic/ - `mosaic` namespace package
4950
├── models/
5051
| └── responses.py - mosaic response models
51-
├── errors.py - cogeo-mosaic known errors
52+
├── errors.py - mosaic known errors
53+
├── extensions.py - extensions
5254
└── factory.py - Mosaic endpoints factory
5355
```

src/titiler/xarray/titiler/xarray/io.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def get_variable(
209209
ds (xarray.Dataset): Xarray Dataset.
210210
variable (str): Variable to extract from the Dataset.
211211
sel (list of str, optional): List of Xarray Indexes.
212-
method (str): Xarray indexing method.
213212
214213
Returns:
215214
xarray.DataArray: 2D or 3D DataArray.

0 commit comments

Comments
 (0)