diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 00000000..f2754497 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,9 @@ +[bumpversion] +current_version = 3.1.2 +commit = True +tag = True +tag_name = {new_version} + +[bumpversion:file:rio_tiler/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..b851f0e2 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +ignore = E501,W503,E203 +exclude = .git,__pycache__,docs/source/conf.py,old,build,dist +max-complexity = 14 +max-line-length = 90 diff --git a/codecov.yml b/.github/codecov.yml similarity index 100% rename from codecov.yml rename to .github/codecov.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ac64c37..b3aa0924 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,13 +8,15 @@ on: tags: - '*' pull_request: +env: + LATEST_PY_VERSION: '3.9' jobs: tests: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: ['3.7', '3.8', '3.9'] steps: - uses: actions/checkout@v2 @@ -29,16 +31,17 @@ jobs: python -m pip install pre-commit codecov - name: Install module - run: python -m pip install -e .["test"] + run: python -m pip install .["test"] - name: Run pre-commit + if: ${{ matrix.python-version == env.LATEST_PY_VERSION }} run: pre-commit run --all-files - name: Run tests run: python -m pytest --cov rio_tiler --cov-report xml --cov-report term-missing --benchmark-skip - name: Upload Results - if: success() + if: ${{ matrix.python-version == env.LATEST_PY_VERSION }} uses: codecov/codecov-action@v1 with: file: ./coverage.xml @@ -54,12 +57,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: "3.8" + python-version: ${{ env.LATEST_PY_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox + python -m pip install -e .["test"] - name: Cache benchmark data uses: actions/cache@v2 @@ -68,9 +71,7 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('./tests/benchmarks/__init__.py') }} - name: Run Benchmark - env: - TOXENV: benchmark - run: tox + run: python -m pytest --benchmark-only --benchmark-autosave --benchmark-columns 'min, max, mean, median' --benchmark-sort 'min' publish: needs: [tests] @@ -81,12 +82,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: "3.x" + python-version: ${{ env.LATEST_PY_VERSION }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox + python -m pip install flit + python -m pip install . - name: Set tag version id: tag @@ -95,13 +97,11 @@ jobs: - name: Set module version id: module - # https://stackoverflow.com/questions/58177786/get-the-current-pushed-tag-in-github-actions - run: echo ::set-output name=version::$(python setup.py --version) + run: echo ::set-output name=version::$(python -c 'from importlib.metadata import version; print(version("rio_tiler"))') - name: Build and publish if: steps.tag.outputs.tag == steps.module.outputs.version env: - TOXENV: release - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: tox + FLIT_USERNAME: ${{ secrets.PYPI_USERNAME }} + FLIT_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: flit publish diff --git a/.github/workflows/deploy_mkdocs.yml b/.github/workflows/deploy_mkdocs.yml index d386de9d..ef111622 100644 --- a/.github/workflows/deploy_mkdocs.yml +++ b/.github/workflows/deploy_mkdocs.yml @@ -36,7 +36,7 @@ jobs: - name: update API docs run: | pdocs as_markdown \ - --output_dir docs/api/ \ + --output_dir docs/src/api/ \ --exclude_source \ --overwrite \ rio_tiler.colormap \ @@ -56,4 +56,4 @@ jobs: rio_tiler.utils - name: Deploy docs - run: mkdocs gh-deploy --force + run: mkdocs gh-deploy -f docs/mkdocs.yml --force diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f81da5a9..40639d48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/psf/black - rev: 21.10b0 + rev: 22.3.0 hooks: - id: black language_version: python @@ -18,10 +18,12 @@ repos: language_version: python - repo: https://github.com/PyCQA/pydocstyle - rev: 5.1.1 + rev: 6.1.1 hooks: - id: pydocstyle language_version: python + additional_dependencies: + - toml - repo: https://github.com/pre-commit/mirrors-mypy rev: v0.812 diff --git a/CHANGES.md b/CHANGES.md index 2b79e1c6..947488bf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +# Unreleased + +* Switch to `pyproject.toml` and `flit` for packaging + # 3.1.2 (2022-03-25) * avoid calculating statistics for non-finite values (https://github.com/cogeotiff/rio-tiler/pull/489) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 844d1f26..0c410c6d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,12 +36,12 @@ To manually deploy docs (note you should never need to do this because Github Actions deploys automatically for new commits.): ```bash -$ mkdocs gh-deploy +$ mkdocs gh-deploy -f docs/mkdocs.yml ``` ```bash pdocs as_markdown \ - --output_dir docs/api/ \ + --output_dir docs/src/api/ \ --exclude_source \ --overwrite \ rio_tiler.colormap \ diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index d8bde515..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include rio_tiler/cmap_data/*.npy -include rio_tiler/py.typed diff --git a/docs/contributing.md b/docs/contributing.md deleted file mode 120000 index 44fcc634..00000000 --- a/docs/contributing.md +++ /dev/null @@ -1 +0,0 @@ -../CONTRIBUTING.md \ No newline at end of file diff --git a/docs/index.md b/docs/index.md deleted file mode 120000 index 32d46ee8..00000000 --- a/docs/index.md +++ /dev/null @@ -1 +0,0 @@ -../README.md \ No newline at end of file diff --git a/mkdocs.yml b/docs/mkdocs.yml similarity index 98% rename from mkdocs.yml rename to docs/mkdocs.yml index a4ba16df..0289ac90 100644 --- a/mkdocs.yml +++ b/docs/mkdocs.yml @@ -2,7 +2,7 @@ site_name: 'rio-tiler' site_description: 'User friendly Rasterio plugin to read raster datasets.' -docs_dir: 'docs' +docs_dir: 'src' site_dir: 'build' # Repository @@ -85,7 +85,7 @@ theme: font: text: 'Nunito Sans' code: 'Fira Code' - custom_dir: 'docs/overrides' + custom_dir: 'src/overrides' # These extensions are chosen to be a superset of Pandoc's Markdown. # This way, I can write in Pandoc's Markdown and have it be supported here. diff --git a/docs/release-notes.md b/docs/release-notes.md deleted file mode 120000 index cf547089..00000000 --- a/docs/release-notes.md +++ /dev/null @@ -1 +0,0 @@ -../CHANGES.md \ No newline at end of file diff --git a/docs/advanced/custom_readers.md b/docs/src/advanced/custom_readers.md similarity index 100% rename from docs/advanced/custom_readers.md rename to docs/src/advanced/custom_readers.md diff --git a/docs/advanced/dynamic_tiler.md b/docs/src/advanced/dynamic_tiler.md similarity index 100% rename from docs/advanced/dynamic_tiler.md rename to docs/src/advanced/dynamic_tiler.md diff --git a/docs/advanced/feature.md b/docs/src/advanced/feature.md similarity index 100% rename from docs/advanced/feature.md rename to docs/src/advanced/feature.md diff --git a/docs/advanced/tms.md b/docs/src/advanced/tms.md similarity index 100% rename from docs/advanced/tms.md rename to docs/src/advanced/tms.md diff --git a/docs/advanced/zonal_stats.md b/docs/src/advanced/zonal_stats.md similarity index 100% rename from docs/advanced/zonal_stats.md rename to docs/src/advanced/zonal_stats.md diff --git a/docs/src/api/rio_tiler/colormap.md b/docs/src/api/rio_tiler/colormap.md new file mode 100644 index 00000000..f3bc15fb --- /dev/null +++ b/docs/src/api/rio_tiler/colormap.md @@ -0,0 +1,232 @@ +# Module rio_tiler.colormap + +rio-tiler colormap functions and classes. + +None + +## Variables + +```python3 +DEFAULT_CMAPS_FILES +``` + +```python3 +EMPTY_COLORMAP +``` + +```python3 +USER_CMAPS_DIR +``` + +```python3 +cmap +``` + +## Functions + + +### apply_cmap + +```python3 +def apply_cmap( + data: numpy.ndarray, + colormap: Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]] +) -> Tuple[numpy.ndarray, numpy.ndarray] +``` + + +Apply colormap on data. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| data | numpy.ndarray | 1D image array to translate to RGB. | None | +| colormap | dict or sequence | GDAL RGBA Color Table dictionary or sequence (for intervals). | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | Data (numpy.ndarray) and Mask (numpy.ndarray) values. | + +**Raises:** + +| Type | Description | +|---|---| +| InvalidFormat | If data is not a 1 band dataset (1, col, row). | + + +### apply_discrete_cmap + +```python3 +def apply_discrete_cmap( + data: numpy.ndarray, + colormap: Dict[int, Tuple[int, int, int, int]] +) -> Tuple[numpy.ndarray, numpy.ndarray] +``` + + +Apply discrete colormap. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| data | numpy.ndarray | 1D image array to translate to RGB. | None | +| color_map | dict | Discrete ColorMap dictionary. | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | Data (numpy.ndarray) and Alpha band (numpy.ndarray). | + + +### apply_intervals_cmap + +```python3 +def apply_intervals_cmap( + data: numpy.ndarray, + colormap: Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]] +) -> Tuple[numpy.ndarray, numpy.ndarray] +``` + + +Apply intervals colormap. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| data | numpy.ndarray | 1D image array to translate to RGB. | None | +| color_map | Sequence | Sequence of intervals and color in form of [([min, max], [r, g, b, a]), ...]. | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | Data (numpy.ndarray) and Alpha band (numpy.ndarray). | + + +### make_lut + +```python3 +def make_lut( + colormap: Dict[int, Tuple[int, int, int, int]] +) -> numpy.ndarray +``` + + +Create a lookup table numpy.ndarray from a GDAL RGBA Color Table dictionary. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| colormap | dict | GDAL RGBA Color Table dictionary. | None | + +**Returns:** + +| Type | Description | +|---|---| +| numpy.ndarray | colormap lookup table. | + + +### parse_color + +```python3 +def parse_color( + rgba: Union[Sequence[int], str] +) -> Tuple[int, int, int, int] +``` + + +Parse RGB/RGBA color and return valid rio-tiler compatible RGBA colormap entry. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| rgba | str or list of int | HEX encoded or list RGB or RGBA colors. | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | RGBA values. | + +## Classes + +### ColorMaps + +```python3 +class ColorMaps( + data: Dict[str, Union[str, Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]]] = NOTHING +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| data | dict | colormaps. Defaults to `rio_tiler.colormap.DEFAULTS_CMAPS`. | `rio_tiler.colormap.DEFAULTS_CMAPS` | + +#### Methods + + +#### get + +```python3 +def get( + self, + name: str +) -> Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]] +``` + + +Fetch a colormap. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| name | str | colormap name. +Returns | None | +| dict | None | colormap dictionary. | None | + + +#### list + +```python3 +def list( + self +) -> List[str] +``` + + +List registered Colormaps. + +Returns + list: list of colormap names. + + +#### register + +```python3 +def register( + self, + custom_cmap: Dict[str, Union[str, Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]]]], + overwrite: bool = False +) -> 'ColorMaps' +``` + + +Register a custom colormap. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| custom_cmap | dict | custom colormap(s) to register. | None | +| overwrite | bool | Overwrite existing colormap with same key. Defaults to False. | False | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/constants.md b/docs/src/api/rio_tiler/constants.md new file mode 100644 index 00000000..ef2b7541 --- /dev/null +++ b/docs/src/api/rio_tiler/constants.md @@ -0,0 +1,23 @@ +# Module rio_tiler.constants + +rio-tiler constant values. + +None + +## Variables + +```python3 +MAX_THREADS +``` + +```python3 +WEB_MERCATOR_CRS +``` + +```python3 +WEB_MERCATOR_TMS +``` + +```python3 +WGS84_CRS +``` \ No newline at end of file diff --git a/docs/src/api/rio_tiler/errors.md b/docs/src/api/rio_tiler/errors.md new file mode 100644 index 00000000..10fd572e --- /dev/null +++ b/docs/src/api/rio_tiler/errors.md @@ -0,0 +1,710 @@ +# Module rio_tiler.errors + +Errors and warnings. + +None + +## Classes + +### AlphaBandWarning + +```python3 +class AlphaBandWarning( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* builtins.UserWarning +* builtins.Warning +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### ColorMapAlreadyRegistered + +```python3 +class ColorMapAlreadyRegistered( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### EmptyMosaicError + +```python3 +class EmptyMosaicError( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### ExpressionMixingWarning + +```python3 +class ExpressionMixingWarning( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* builtins.UserWarning +* builtins.Warning +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### IncorrectTileBuffer + +```python3 +class IncorrectTileBuffer( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### InvalidAssetName + +```python3 +class InvalidAssetName( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### InvalidBandName + +```python3 +class InvalidBandName( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### InvalidColorFormat + +```python3 +class InvalidColorFormat( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### InvalidColorMapName + +```python3 +class InvalidColorMapName( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### InvalidDatatypeWarning + +```python3 +class InvalidDatatypeWarning( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* builtins.UserWarning +* builtins.Warning +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### InvalidFormat + +```python3 +class InvalidFormat( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### InvalidMosaicMethod + +```python3 +class InvalidMosaicMethod( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### MissingAssets + +```python3 +class MissingAssets( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### MissingBands + +```python3 +class MissingBands( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### NoOverviewWarning + +```python3 +class NoOverviewWarning( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* builtins.UserWarning +* builtins.Warning +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### PointOutsideBounds + +```python3 +class PointOutsideBounds( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### RioTilerError + +```python3 +class RioTilerError( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* builtins.Exception +* builtins.BaseException + +#### Descendants + +* rio_tiler.errors.InvalidFormat +* rio_tiler.errors.TileOutsideBounds +* rio_tiler.errors.IncorrectTileBuffer +* rio_tiler.errors.PointOutsideBounds +* rio_tiler.errors.InvalidBandName +* rio_tiler.errors.InvalidColorMapName +* rio_tiler.errors.InvalidAssetName +* rio_tiler.errors.MissingAssets +* rio_tiler.errors.MissingBands +* rio_tiler.errors.InvalidMosaicMethod +* rio_tiler.errors.ColorMapAlreadyRegistered +* rio_tiler.errors.EmptyMosaicError +* rio_tiler.errors.InvalidColorFormat + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. + +### TileOutsideBounds + +```python3 +class TileOutsideBounds( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.errors.RioTilerError +* builtins.Exception +* builtins.BaseException + +#### Class variables + +```python3 +args +``` + +#### Methods + + +#### with_traceback + +```python3 +def with_traceback( + ... +) +``` + + +Exception.with_traceback(tb) -- + +set self.__traceback__ to tb and return self. \ No newline at end of file diff --git a/docs/src/api/rio_tiler/expression.md b/docs/src/api/rio_tiler/expression.md new file mode 100644 index 00000000..e0acb7af --- /dev/null +++ b/docs/src/api/rio_tiler/expression.md @@ -0,0 +1,85 @@ +# Module rio_tiler.expression + +rio-tiler.expression: Parse and Apply expression. + +None + +## Functions + + +### apply_expression + +```python3 +def apply_expression( + blocks: Sequence[str], + bands: Sequence[Union[str, int]], + data: numpy.ndarray +) -> numpy.ndarray +``` + + +Apply rio-tiler expression. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| blocks | sequence | expression for a specific layer. | None | +| bands | sequence | bands names. | None | +| data | numpy.array | array of bands. | None | + +**Returns:** + +| Type | Description | +|---|---| +| numpy.array | output data. | + + +### get_expression_blocks + +```python3 +def get_expression_blocks( + expression: str +) -> List[str] +``` + + +Split expression in blocks. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| expression | str | band math/combination expression. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | expression blocks (str). | + + +### parse_expression + +```python3 +def parse_expression( + expression: str, + cast: bool = True +) -> Tuple +``` + + +Parse rio-tiler band math expression. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| expression | str | band math/combination expression. | None | +| cast | bool | cast band names to integers (convert to index values). Defaults to True. | True | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | band names/indexes. | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/io/base.md b/docs/src/api/rio_tiler/io/base.md new file mode 100644 index 00000000..990bf3d9 --- /dev/null +++ b/docs/src/api/rio_tiler/io/base.md @@ -0,0 +1,1172 @@ +# Module rio_tiler.io.base + +rio_tiler.io.base: ABC class for rio-tiler readers. + +None + +## Classes + +### AsyncBaseReader + +```python3 +class AsyncBaseReader( + input: Any, + tms: morecantile.models.TileMatrixSet = +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.io.base.SpatialMixin + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### feature + +```python3 +def feature( + self, + shape: Dict, + **kwargs: Any +) -> Coroutine[Any, Any, rio_tiler.models.ImageData] +``` + + +Read a Dataset for a GeoJSON feature. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| shape | dict | Valid GeoJSON feature. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### info + +```python3 +def info( + self +) -> Coroutine[Any, Any, rio_tiler.models.Info] +``` + + +Return Dataset's info. + +**Returns:** + +| Type | Description | +|---|---| +| rio_tile.models.Info | Dataset info. | + + +#### part + +```python3 +def part( + self, + bbox: Tuple[float, float, float, float], + **kwargs: Any +) -> Coroutine[Any, Any, rio_tiler.models.ImageData] +``` + + +Read a Part of a Dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bbox | tuple | Output bounds (left, bottom, right, top) in target crs. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### point + +```python3 +def point( + self, + lon: float, + lat: float, + **kwargs: Any +) -> Coroutine[Any, Any, List] +``` + + +Read a value from a Dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| lon | float | Longitude. | None | +| lat | float | Latitude. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel value per bands/assets. | + + +#### preview + +```python3 +def preview( + self, + **kwargs: Any +) -> Coroutine[Any, Any, rio_tiler.models.ImageData] +``` + + +Read a preview of a Dataset. + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### statistics + +```python3 +def statistics( + self, + **kwargs: Any +) -> Coroutine[Any, Any, Dict[str, rio_tiler.models.BandStatistics]] +``` + + +Return bands statistics from a dataset. + +**Returns:** + +| Type | Description | +|---|---| +| Dict[str, rio_tiler.models.BandStatistics] | bands statistics. | + + +#### tile + +```python3 +def tile( + self, + tile_x: int, + tile_y: int, + tile_z: int, + **kwargs: Any +) -> Coroutine[Any, Any, rio_tiler.models.ImageData] +``` + + +Read a Map tile from the Dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | + +### BaseReader + +```python3 +class BaseReader( + input: Any, + tms: morecantile.models.TileMatrixSet = +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.io.base.SpatialMixin + +#### Descendants + +* rio_tiler.io.cogeo.COGReader + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### feature + +```python3 +def feature( + self, + shape: Dict, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read a Dataset for a GeoJSON feature. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| shape | dict | Valid GeoJSON feature. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### info + +```python3 +def info( + self +) -> rio_tiler.models.Info +``` + + +Return Dataset's info. + +**Returns:** + +| Type | Description | +|---|---| +| rio_tile.models.Info | Dataset info. | + + +#### part + +```python3 +def part( + self, + bbox: Tuple[float, float, float, float], + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read a Part of a Dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bbox | tuple | Output bounds (left, bottom, right, top) in target crs. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### point + +```python3 +def point( + self, + lon: float, + lat: float, + **kwargs: Any +) -> List +``` + + +Read a value from a Dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| lon | float | Longitude. | None | +| lat | float | Latitude. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel value per bands/assets. | + + +#### preview + +```python3 +def preview( + self, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read a preview of a Dataset. + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### statistics + +```python3 +def statistics( + self, + **kwargs: Any +) -> Dict[str, rio_tiler.models.BandStatistics] +``` + + +Return bands statistics from a dataset. + +**Returns:** + +| Type | Description | +|---|---| +| Dict[str, rio_tiler.models.BandStatistics] | bands statistics. | + + +#### tile + +```python3 +def tile( + self, + tile_x: int, + tile_y: int, + tile_z: int, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read a Map tile from the Dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | + +### MultiBandReader + +```python3 +class MultiBandReader( + input: Any, + tms: morecantile.models.TileMatrixSet = , + reader_options: Dict = NOTHING +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| input | any | input data. | None | +| tms | morecantile.TileMatrixSet | TileMatrixSet grid definition. Defaults to `WebMercatorQuad`. | `WebMercatorQuad` | +| reader_options | dict, option | options to forward to the reader. Defaults to `{}`. | `{}` | +| reader | rio_tiler.io.BaseReader | reader. **Not in __init__**. | None | +| bands | sequence | Band list. **Not in __init__**. | None | + +#### Ancestors (in MRO) + +* rio_tiler.io.base.SpatialMixin + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### feature + +```python3 +def feature( + self, + shape: Dict, + bands: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge parts defined by geojson feature from multiple bands. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| shape | dict | Valid GeoJSON feature. | None | +| bands | sequence of str or str | bands to fetch info from. | None | +| expression | str | rio-tiler expression for the band list (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `self.reader.feature` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### info + +```python3 +def info( + self, + bands: Union[Sequence[str], str] = None, + *args, + **kwargs: Any +) -> rio_tiler.models.Info +``` + + +Return metadata from multiple bands. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bands | sequence of str or str | band names to fetch info from. Required keyword argument. | None | + +**Returns:** + +| Type | Description | +|---|---| +| dict | Multiple bands info in form of {"band1": rio_tile.models.Info}. | + + +#### parse_expression + +```python3 +def parse_expression( + self, + expression: str +) -> Tuple +``` + + +Parse rio-tiler band math expression. + + +#### part + +```python3 +def part( + self, + bbox: Tuple[float, float, float, float], + bands: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge parts from multiple bands. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bbox | tuple | Output bounds (left, bottom, right, top) in target crs. | None | +| bands | sequence of str or str | bands to fetch info from. | None | +| expression | str | rio-tiler expression for the band list (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the 'self.reader.part' method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### point + +```python3 +def point( + self, + lon: float, + lat: float, + bands: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> List +``` + + +Read a pixel values from multiple bands. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| lon | float | Longitude. | None | +| lat | float | Latitude. | None | +| bands | sequence of str or str | bands to fetch info from. | None | +| expression | str | rio-tiler expression for the band list (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `self.reader.point` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel value per bands. | + + +#### preview + +```python3 +def preview( + self, + bands: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge previews from multiple bands. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bands | sequence of str or str | bands to fetch info from. | None | +| expression | str | rio-tiler expression for the band list (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `self.reader.preview` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### statistics + +```python3 +def statistics( + self, + bands: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + categorical: bool = False, + categories: Union[List[float], NoneType] = None, + percentiles: List[int] = [2, 98], + hist_options: Union[Dict, NoneType] = None, + max_size: int = 1024, + **kwargs: Any +) -> Dict[str, rio_tiler.models.BandStatistics] +``` + + +Return array statistics for multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bands | sequence of str or str | bands to fetch info from. Required keyword argument. | None | +| expression | str | rio-tiler expression for the band list (e.g. b1/b2+b3). | None | +| categorical | bool | treat input data as categorical data. Defaults to False. | False | +| categories | list of numbers | list of categories to return value for. | None | +| percentiles | list of numbers | list of percentile values to calculate. Defaults to `[2, 98]`. | `[2, 98]` | +| hist_options | dict | Options to forward to numpy.histogram function. | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024. | 1024 | +| kwargs | optional | Options to forward to the `self.preview` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| dict | Multiple assets statistics in form of {"{band}/{expression}": rio_tiler.models.BandStatistics, ...}. | + + +#### tile + +```python3 +def tile( + self, + tile_x: int, + tile_y: int, + tile_z: int, + bands: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge Web Map tiles multiple bands. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | +| bands | sequence of str or str | bands to fetch info from. | None | +| expression | str | rio-tiler expression for the band list (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `self.reader.tile` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | + +### MultiBaseReader + +```python3 +class MultiBaseReader( + input: Any, + tms: morecantile.models.TileMatrixSet = , + reader_options: Dict = NOTHING +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| input | any | input data. | None | +| tms | morecantile.TileMatrixSet | TileMatrixSet grid definition. Defaults to `WebMercatorQuad`. | `WebMercatorQuad` | +| reader_options | dict, option | options to forward to the reader. Defaults to `{}`. | `{}` | +| reader | rio_tiler.io.BaseReader | reader. **Not in __init__**. | None | +| assets | sequence | Asset list. **Not in __init__**. | None | + +#### Ancestors (in MRO) + +* rio_tiler.io.base.SpatialMixin + +#### Descendants + +* rio_tiler.io.stac.STACReader + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### feature + +```python3 +def feature( + self, + shape: Dict, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge parts defined by geojson feature from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| shape | dict | Valid GeoJSON feature. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.feature` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### info + +```python3 +def info( + self, + assets: Union[Sequence[str], str] = None, + **kwargs: Any +) -> Dict[str, rio_tiler.models.Info] +``` + + +Return metadata from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. Required keyword argument. | None | + +**Returns:** + +| Type | Description | +|---|---| +| dict | Multiple assets info in form of {"asset1": rio_tile.models.Info}. | + + +#### merged_statistics + +```python3 +def merged_statistics( + self, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + categorical: bool = False, + categories: Union[List[float], NoneType] = None, + percentiles: List[int] = [2, 98], + hist_options: Union[Dict, NoneType] = None, + max_size: int = 1024, + **kwargs: Any +) -> Dict[str, rio_tiler.models.BandStatistics] +``` + + +Return array statistics for multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| categorical | bool | treat input data as categorical data. Defaults to False. | False | +| categories | list of numbers | list of categories to return value for. | None | +| percentiles | list of numbers | list of percentile values to calculate. Defaults to `[2, 98]`. | `[2, 98]` | +| hist_options | dict | Options to forward to numpy.histogram function. | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024. | 1024 | +| kwargs | optional | Options to forward to the `self.preview` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| Dict[str, rio_tiler.models.BandStatistics] | bands statistics. | + + +#### parse_expression + +```python3 +def parse_expression( + self, + expression: str +) -> Tuple +``` + + +Parse rio-tiler band math expression. + + +#### part + +```python3 +def part( + self, + bbox: Tuple[float, float, float, float], + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge parts from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bbox | tuple | Output bounds (left, bottom, right, top) in target crs. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.part` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### point + +```python3 +def point( + self, + lon: float, + lat: float, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> List +``` + + +Read pixel value from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| lon | float | Longitude. | None | +| lat | float | Latitude. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.point` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel values per assets. | + + +#### preview + +```python3 +def preview( + self, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge previews from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.preview` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### statistics + +```python3 +def statistics( + self, + assets: Union[Sequence[str], str] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> Dict[str, Dict[str, rio_tiler.models.BandStatistics]] +``` + + +Return array statistics for multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.statistics` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| dict | Multiple assets statistics in form of {"asset1": {"1": rio_tiler.models.BandStatistics, ...}}. | + + +#### tile + +```python3 +def tile( + self, + tile_x: int, + tile_y: int, + tile_z: int, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge Wep Map tiles from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.tile` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | + +### SpatialMixin + +```python3 +class SpatialMixin( + tms: morecantile.models.TileMatrixSet = +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| tms | morecantile.TileMatrixSet | TileMatrixSet grid definition. Defaults to `WebMercatorQuad`. | `WebMercatorQuad` | +| minzoom | int | Dataset Min Zoom level. **Not in __init__**. | None | +| maxzoom | int | Dataset Max Zoom level. **Not in __init__**. | None | +| bounds | tuple | Dataset bounds (left, bottom, right, top). **Not in __init__**. | None | +| crs | rasterio.crs.CRS | Dataset crs. **Not in __init__**. | None | +| geographic_crs | rasterio.crs.CRS | CRS to use as geographic coordinate system. Defaults to WGS84. **Not in __init__**. | WGS84. **Not in __init__** | + +#### Descendants + +* rio_tiler.io.base.BaseReader +* rio_tiler.io.base.AsyncBaseReader +* rio_tiler.io.base.MultiBaseReader +* rio_tiler.io.base.MultiBandReader + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/io/cogeo.md b/docs/src/api/rio_tiler/io/cogeo.md new file mode 100644 index 00000000..7fdb56f3 --- /dev/null +++ b/docs/src/api/rio_tiler/io/cogeo.md @@ -0,0 +1,758 @@ +# Module rio_tiler.io.cogeo + +rio_tiler.io.cogeo: raster processing. + +None + +## Classes + +### COGReader + +```python3 +class COGReader( + input: str, + dataset: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.io.MemoryFile, rasterio.vrt.WarpedVRT] = None, + tms: morecantile.models.TileMatrixSet = , + minzoom: int = None, + maxzoom: int = None, + geographic_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + colormap: Dict = None, + nodata: Union[float, int, str, NoneType] = None, + unscale: Union[bool, NoneType] = None, + resampling_method: Union[rasterio.enums.Resampling, NoneType] = None, + vrt_options: Union[Dict, NoneType] = None, + post_process: Union[Callable[[numpy.ndarray, numpy.ndarray], Tuple[numpy.ndarray, numpy.ndarray]], NoneType] = None +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| input | str | Cloud Optimized GeoTIFF path. | None | +| dataset | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| bounds | tuple | Dataset bounds (left, bottom, right, top). | None | +| crs | rasterio.crs.CRS | Dataset CRS. | None | +| tms | morecantile.TileMatrixSet | TileMatrixSet grid definition. Defaults to `WebMercatorQuad`. | `WebMercatorQuad` | +| minzoom | int | Set minzoom for the tiles. | None | +| maxzoom | int | Set maxzoom for the tiles. | None | +| geographic_crs | rasterio.crs.CRS | CRS to use as geographic coordinate system. Defaults to WGS84. | WGS84 | +| colormap | dict | Overwrite internal colormap. | None | +| nodata | int or float or str | Global options, overwrite internal nodata value. | None | +| unscale | bool | Global options, apply internal scale and offset on all read operations. | None | +| resampling_method | rasterio.enums.Resampling | Global options, resampling method to use for read operations. | None | +| vrt_options | dict | Global options, WarpedVRT options to use for read operations. | None | +| post_process | callable | Global options, Function to apply after all read operations. | None | + +#### Ancestors (in MRO) + +* rio_tiler.io.base.BaseReader +* rio_tiler.io.base.SpatialMixin + +#### Descendants + +* rio_tiler.io.cogeo.GCPCOGReader + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### close + +```python3 +def close( + self +) +``` + + +Close rasterio dataset. + + +#### feature + +```python3 +def feature( + self, + shape: Dict, + dst_crs: Union[rasterio.crs.CRS, NoneType] = None, + shape_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + max_size: Union[int, NoneType] = None, + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read part of a COG defined by a geojson feature. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| shape | dict | Valid GeoJSON feature. | None | +| dst_crs | rasterio.crs.CRS | Overwrite target coordinate reference system. | None | +| shape_crs | rasterio.crs.CRS | Input geojson coordinate reference system. Defaults to `epsg:4326`. | `epsg:4326` | +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. | None | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| kwargs | optional | Options to forward to the `COGReader.part` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### get_zooms + +```python3 +def get_zooms( + self, + tilesize: int = 256 +) -> Tuple[int, int] +``` + + +Calculate raster min/max zoom level for input TMS. + + +#### info + +```python3 +def info( + self +) -> rio_tiler.models.Info +``` + + +Return COG info. + + +#### part + +```python3 +def part( + self, + bbox: Tuple[float, float, float, float], + dst_crs: Union[rasterio.crs.CRS, NoneType] = None, + bounds_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + indexes: Union[int, Sequence, NoneType] = None, + expression: Union[str, NoneType] = None, + max_size: Union[int, NoneType] = None, + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read part of a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bbox | tuple | Output bounds (left, bottom, right, top) in target crs ("dst_crs"). | None | +| dst_crs | rasterio.crs.CRS | Overwrite target coordinate reference system. | None | +| bounds_crs | rasterio.crs.CRS | Bounds Coordinate Reference System. Defaults to `epsg:4326`. | `epsg:4326` | +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. | None | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.part` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### point + +```python3 +def point( + self, + lon: float, + lat: float, + coord_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> List +``` + + +Read a pixel value from a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| lon | float | Longitude. | None | +| lat | float | Latitude. | None | +| coord_crs | rasterio.crs.CRS | Coordinate Reference System of the input coords. Defaults to `epsg:4326`. | `epsg:4326` | +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.point` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel value per band indexes. | + + +#### preview + +```python3 +def preview( + self, + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + max_size: int = 1024, + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Return a preview of a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024. | 1024 | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.preview` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### read + +```python3 +def read( + self, + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read the COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.read` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### statistics + +```python3 +def statistics( + self, + categorical: bool = False, + categories: Union[List[float], NoneType] = None, + percentiles: List[int] = [2, 98], + hist_options: Union[Dict, NoneType] = None, + max_size: int = 1024, + **kwargs: Any +) -> Dict[str, rio_tiler.models.BandStatistics] +``` + + +Return bands statistics from a dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| categorical | bool | treat input data as categorical data. Defaults to False. | False | +| categories | list of numbers | list of categories to return value for. | None | +| percentiles | list of numbers | list of percentile values to calculate. Defaults to `[2, 98]`. | `[2, 98]` | +| hist_options | dict | Options to forward to numpy.histogram function. | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024. | 1024 | +| kwargs | optional | Options to forward to `self.preview`. | None | + +**Returns:** + +| Type | Description | +|---|---| +| Dict[str, rio_tiler.models.BandStatistics] | bands statistics. | + + +#### tile + +```python3 +def tile( + self, + tile_x: int, + tile_y: int, + tile_z: int, + tilesize: int = 256, + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + tile_buffer: Union[float, int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read a Web Map tile from a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | +| tilesize | int | Output image size. Defaults to `256`. | `256` | +| indexes | int or sequence of int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| tile_buffer | int or float | Buffer on each side of the given tile. It must be a multiple of `0.5`. Output **tilesize** will be expanded to `tilesize + 2 * tile_buffer` (e.g 0.5 = 257x257, 1.0 = 258x258). | None | +| kwargs | optional | Options to forward to the `COGReader.part` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | + +### GCPCOGReader + +```python3 +class GCPCOGReader( + input: str, + src_dataset: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.io.MemoryFile, rasterio.vrt.WarpedVRT] = None, + tms: morecantile.models.TileMatrixSet = , + minzoom: int = None, + maxzoom: int = None, + geographic_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + colormap: Dict = None, + nodata: Union[float, int, str, NoneType] = None, + unscale: Union[bool, NoneType] = None, + resampling_method: Union[rasterio.enums.Resampling, NoneType] = None, + vrt_options: Union[Dict, NoneType] = None, + post_process: Union[Callable[[numpy.ndarray, numpy.ndarray], Tuple[numpy.ndarray, numpy.ndarray]], NoneType] = None +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| input | str | Cloud Optimized GeoTIFF path. | None | +| src_dataset | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| tms | morecantile.TileMatrixSet | TileMatrixSet grid definition. Defaults to `WebMercatorQuad`. | `WebMercatorQuad` | +| minzoom | int | Overwrite Min Zoom level. | None | +| maxzoom | int | Overwrite Max Zoom level. | None | +| colormap | dict | Overwrite internal colormap. | None | +| nodata | int or float or str | Global options, overwrite internal nodata value. | None | +| unscale | bool | Global options, apply internal scale and offset on all read operations. | None | +| resampling_method | rasterio.enums.Resampling | Global options, resampling method to use for read operations. | None | +| vrt_options | dict | Global options, WarpedVRT options to use for read operations. | None | +| post_process | callable | Global options, Function to apply after all read operations. | None | +| dataset | rasterio.vrtWarpedVRT | Warped VRT constructed with dataset GCPS info. **READ ONLY attribute**. | None | + +#### Ancestors (in MRO) + +* rio_tiler.io.cogeo.COGReader +* rio_tiler.io.base.BaseReader +* rio_tiler.io.base.SpatialMixin + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### close + +```python3 +def close( + self +) +``` + + +Close rasterio dataset. + + +#### feature + +```python3 +def feature( + self, + shape: Dict, + dst_crs: Union[rasterio.crs.CRS, NoneType] = None, + shape_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + max_size: Union[int, NoneType] = None, + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read part of a COG defined by a geojson feature. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| shape | dict | Valid GeoJSON feature. | None | +| dst_crs | rasterio.crs.CRS | Overwrite target coordinate reference system. | None | +| shape_crs | rasterio.crs.CRS | Input geojson coordinate reference system. Defaults to `epsg:4326`. | `epsg:4326` | +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. | None | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| kwargs | optional | Options to forward to the `COGReader.part` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### get_zooms + +```python3 +def get_zooms( + self, + tilesize: int = 256 +) -> Tuple[int, int] +``` + + +Calculate raster min/max zoom level for input TMS. + + +#### info + +```python3 +def info( + self +) -> rio_tiler.models.Info +``` + + +Return COG info. + + +#### part + +```python3 +def part( + self, + bbox: Tuple[float, float, float, float], + dst_crs: Union[rasterio.crs.CRS, NoneType] = None, + bounds_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + indexes: Union[int, Sequence, NoneType] = None, + expression: Union[str, NoneType] = None, + max_size: Union[int, NoneType] = None, + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read part of a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bbox | tuple | Output bounds (left, bottom, right, top) in target crs ("dst_crs"). | None | +| dst_crs | rasterio.crs.CRS | Overwrite target coordinate reference system. | None | +| bounds_crs | rasterio.crs.CRS | Bounds Coordinate Reference System. Defaults to `epsg:4326`. | `epsg:4326` | +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. | None | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.part` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### point + +```python3 +def point( + self, + lon: float, + lat: float, + coord_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> List +``` + + +Read a pixel value from a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| lon | float | Longitude. | None | +| lat | float | Latitude. | None | +| coord_crs | rasterio.crs.CRS | Coordinate Reference System of the input coords. Defaults to `epsg:4326`. | `epsg:4326` | +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.point` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel value per band indexes. | + + +#### preview + +```python3 +def preview( + self, + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + max_size: int = 1024, + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Return a preview of a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024. | 1024 | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.preview` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### read + +```python3 +def read( + self, + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read the COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| indexes | sequence of int or int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| kwargs | optional | Options to forward to the `rio_tiler.reader.read` function. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and input spatial info. | + + +#### statistics + +```python3 +def statistics( + self, + categorical: bool = False, + categories: Union[List[float], NoneType] = None, + percentiles: List[int] = [2, 98], + hist_options: Union[Dict, NoneType] = None, + max_size: int = 1024, + **kwargs: Any +) -> Dict[str, rio_tiler.models.BandStatistics] +``` + + +Return bands statistics from a dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| categorical | bool | treat input data as categorical data. Defaults to False. | False | +| categories | list of numbers | list of categories to return value for. | None | +| percentiles | list of numbers | list of percentile values to calculate. Defaults to `[2, 98]`. | `[2, 98]` | +| hist_options | dict | Options to forward to numpy.histogram function. | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024. | 1024 | +| kwargs | optional | Options to forward to `self.preview`. | None | + +**Returns:** + +| Type | Description | +|---|---| +| Dict[str, rio_tiler.models.BandStatistics] | bands statistics. | + + +#### tile + +```python3 +def tile( + self, + tile_x: int, + tile_y: int, + tile_z: int, + tilesize: int = 256, + indexes: Union[Sequence[int], int, NoneType] = None, + expression: Union[str, NoneType] = None, + tile_buffer: Union[float, int, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read a Web Map tile from a COG. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | +| tilesize | int | Output image size. Defaults to `256`. | `256` | +| indexes | int or sequence of int | Band indexes. | None | +| expression | str | rio-tiler expression (e.g. b1/b2+b3). | None | +| tile_buffer | int or float | Buffer on each side of the given tile. It must be a multiple of `0.5`. Output **tilesize** will be expanded to `tilesize + 2 * tile_buffer` (e.g 0.5 = 257x257, 1.0 = 258x258). | None | +| kwargs | optional | Options to forward to the `COGReader.part` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/io/stac.md b/docs/src/api/rio_tiler/io/stac.md new file mode 100644 index 00000000..705c173b --- /dev/null +++ b/docs/src/api/rio_tiler/io/stac.md @@ -0,0 +1,416 @@ +# Module rio_tiler.io.stac + +rio_tiler.io.stac: STAC reader. + +None + +## Variables + +```python3 +DEFAULT_VALID_TYPE +``` + +## Functions + + +### fetch + +```python3 +def fetch( + filepath: str, + **kwargs: Any +) -> Dict +``` + + +Fetch STAC items. + +A LRU cache is set on top of this function. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| filepath | str | STAC item URL. | None | +| kwargs | any | additional options to pass to client. | None | + +**Returns:** + +| Type | Description | +|---|---| +| dict | STAC Item content. | + +## Classes + +### STACReader + +```python3 +class STACReader( + input: str, + item: Union[NoneType, Dict, pystac.item.Item] = None, + tms: morecantile.models.TileMatrixSet = , + minzoom: int = None, + maxzoom: int = None, + geographic_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + include_assets: Union[Set[str], NoneType] = None, + exclude_assets: Union[Set[str], NoneType] = None, + include_asset_types: Set[str] = {'image/x.geotiff', 'image/tiff; profile=cloud-optimized; application=geotiff', 'image/jp2', 'application/x-hdf', 'image/tiff', 'image/tiff; application=geotiff; profile=cloud-optimized', 'application/x-hdf5', 'image/vnd.stac.geotiff; cloud-optimized=true', 'image/tiff; application=geotiff'}, + exclude_asset_types: Union[Set[str], NoneType] = None, + reader: Type[rio_tiler.io.base.BaseReader] = , + reader_options: Dict = NOTHING, + fetch_options: Dict = NOTHING +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| input | str | STAC Item path, URL or S3 URL. | None | +| item | dict or pystac.Item, STAC | Stac Item. | None | +| minzoom | int | Set minzoom for the tiles. | None | +| maxzoom | int | Set maxzoom for the tiles. | None | +| geographic_crs | rasterio.crs.CRS | CRS to use as geographic coordinate system. Defaults to WGS84. | WGS84 | +| include | set of string | Only Include specific assets. | None | +| exclude | set of string | Exclude specific assets. | None | +| include_asset_types | set of string | Only include some assets base on their type. | None | +| exclude_asset_types | set of string | Exclude some assets base on their type. | None | +| reader | rio_tiler.io.BaseReader | rio-tiler Reader. Defaults to `rio_tiler.io.COGReader`. | `rio_tiler.io.COGReader` | +| reader_options | dict | Additional option to forward to the Reader. Defaults to `{}`. | `{}` | +| fetch_options | dict | Options to pass to `rio_tiler.io.stac.fetch` function fetching the STAC Items. Defaults to `{}`. | `{}` | + +#### Ancestors (in MRO) + +* rio_tiler.io.base.MultiBaseReader +* rio_tiler.io.base.SpatialMixin + +#### Instance variables + +```python3 +geographic_bounds +``` + +return bounds in WGS84. + +#### Methods + + +#### feature + +```python3 +def feature( + self, + shape: Dict, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge parts defined by geojson feature from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| shape | dict | Valid GeoJSON feature. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.feature` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### info + +```python3 +def info( + self, + assets: Union[Sequence[str], str] = None, + **kwargs: Any +) -> Dict[str, rio_tiler.models.Info] +``` + + +Return metadata from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. Required keyword argument. | None | + +**Returns:** + +| Type | Description | +|---|---| +| dict | Multiple assets info in form of {"asset1": rio_tile.models.Info}. | + + +#### merged_statistics + +```python3 +def merged_statistics( + self, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + categorical: bool = False, + categories: Union[List[float], NoneType] = None, + percentiles: List[int] = [2, 98], + hist_options: Union[Dict, NoneType] = None, + max_size: int = 1024, + **kwargs: Any +) -> Dict[str, rio_tiler.models.BandStatistics] +``` + + +Return array statistics for multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| categorical | bool | treat input data as categorical data. Defaults to False. | False | +| categories | list of numbers | list of categories to return value for. | None | +| percentiles | list of numbers | list of percentile values to calculate. Defaults to `[2, 98]`. | `[2, 98]` | +| hist_options | dict | Options to forward to numpy.histogram function. | None | +| max_size | int | Limit the size of the longest dimension of the dataset read, respecting bounds X/Y aspect ratio. Defaults to 1024. | 1024 | +| kwargs | optional | Options to forward to the `self.preview` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| Dict[str, rio_tiler.models.BandStatistics] | bands statistics. | + + +#### parse_expression + +```python3 +def parse_expression( + self, + expression: str +) -> Tuple +``` + + +Parse rio-tiler band math expression. + + +#### part + +```python3 +def part( + self, + bbox: Tuple[float, float, float, float], + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge parts from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| bbox | tuple | Output bounds (left, bottom, right, top) in target crs. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.part` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### point + +```python3 +def point( + self, + lon: float, + lat: float, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> List +``` + + +Read pixel value from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| lon | float | Longitude. | None | +| lat | float | Latitude. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.point` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel values per assets. | + + +#### preview + +```python3 +def preview( + self, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge previews from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.preview` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### statistics + +```python3 +def statistics( + self, + assets: Union[Sequence[str], str] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> Dict[str, Dict[str, rio_tiler.models.BandStatistics]] +``` + + +Return array statistics for multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| assets | sequence of str or str | assets to fetch info from. | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.statistics` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| dict | Multiple assets statistics in form of {"asset1": {"1": rio_tiler.models.BandStatistics, ...}}. | + + +#### tile + +```python3 +def tile( + self, + tile_x: int, + tile_y: int, + tile_z: int, + assets: Union[Sequence[str], str] = None, + expression: Union[str, NoneType] = None, + asset_indexes: Union[Dict[str, Union[Sequence[int], int]], NoneType] = None, + asset_expression: Union[Dict[str, str], NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Read and merge Wep Map tiles from multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | +| assets | sequence of str or str | assets to fetch info from. | None | +| expression | str | rio-tiler expression for the asset list (e.g. asset1/asset2+asset3). | None | +| asset_indexes | dict | Band indexes for each asset (e.g {"asset1": 1, "asset2": (1, 2,)}). | None | +| asset_expression | dict | rio-tiler expression for each asset (e.g. {"asset1": "b1/b2+b3", "asset2": ...}). | None | +| kwargs | optional | Options to forward to the `self.reader.tile` method. | None | + +**Returns:** + +| Type | Description | +|---|---| +| rio_tiler.models.ImageData | ImageData instance with data, mask and tile spatial info. | + + +#### tile_exists + +```python3 +def tile_exists( + self, + tile_x: int, + tile_y: int, + tile_z: int +) -> bool +``` + + +Check if a tile intersects the dataset bounds. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile_x | int | Tile's horizontal index. | None | +| tile_y | int | Tile's vertical index. | None | +| tile_z | int | Tile's zoom level index. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bool | True if the tile intersects the dataset bounds. | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/models.md b/docs/src/api/rio_tiler/models.md new file mode 100644 index 00000000..f62ef24a --- /dev/null +++ b/docs/src/api/rio_tiler/models.md @@ -0,0 +1,1359 @@ +# Module rio_tiler.models + +rio-tiler models. + +None + +## Variables + +```python3 +dtype_ranges +``` + +## Functions + + +### to_coordsbbox + +```python3 +def to_coordsbbox( + bbox +) -> Union[rasterio.coords.BoundingBox, NoneType] +``` + + +Convert bbox to CoordsBbox nameTuple. + +## Classes + +### BandStatistics + +```python3 +class BandStatistics( + __pydantic_self__, + **data: Any +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.models.RioTilerBaseModel +* pydantic.main.BaseModel +* pydantic.utils.Representation + +#### Class variables + +```python3 +Config +``` + +#### Static methods + + +#### construct + +```python3 +def construct( + _fields_set: Union[ForwardRef('SetStr'), NoneType] = None, + **values: Any +) -> 'Model' +``` + + +Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. + +Default values are respected, but no other validation is performed. +Behaves as if `Config.extra = 'allow'` was set since it adds all passed values + + +#### from_orm + +```python3 +def from_orm( + obj: Any +) -> 'Model' +``` + + + + +#### parse_file + +```python3 +def parse_file( + path: Union[str, pathlib.Path], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### parse_obj + +```python3 +def parse_obj( + obj: Any +) -> 'Model' +``` + + + + +#### parse_raw + +```python3 +def parse_raw( + b: Union[str, bytes], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### schema + +```python3 +def schema( + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}' +) -> 'DictStrAny' +``` + + + + +#### schema_json + +```python3 +def schema_json( + *, + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}', + **dumps_kwargs: Any +) -> 'unicode' +``` + + + + +#### update_forward_refs + +```python3 +def update_forward_refs( + **localns: Any +) -> None +``` + + +Try to update ForwardRefs on fields based on this Model, globalns and localns. + + +#### validate + +```python3 +def validate( + value: Any +) -> 'Model' +``` + + + +#### Methods + + +#### copy + +```python3 +def copy( + self: 'Model', + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + update: 'DictStrAny' = None, + deep: bool = False +) -> 'Model' +``` + + +Duplicate a model, optionally choose which fields to include, exclude and change. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| include | None | fields to include in new model | None | +| exclude | None | fields to exclude from new model, as with values this takes precedence over include | None | +| update | None | values to change/add in the new model. Note: the data is not validated before creating +the new model: you should trust this data | None | +| deep | None | set to `True` to make a deep copy of the model | None | + +**Returns:** + +| Type | Description | +|---|---| +| None | new model instance | + + +#### dict + +```python3 +def dict( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False +) -> 'DictStrAny' +``` + + +Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. + + +#### json + +```python3 +def json( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False, + encoder: Union[Callable[[Any], Any], NoneType] = None, + models_as_dict: bool = True, + **dumps_kwargs: Any +) -> 'unicode' +``` + + +Generate a JSON representation of the model, `include` and `exclude` arguments as per `dict()`. + +`encoder` is an optional function to supply as `default` to json.dumps(), other arguments as per `json.dumps()`. + +### Bounds + +```python3 +class Bounds( + __pydantic_self__, + **data: Any +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.models.RioTilerBaseModel +* pydantic.main.BaseModel +* pydantic.utils.Representation + +#### Descendants + +* rio_tiler.models.SpatialInfo + +#### Class variables + +```python3 +Config +``` + +#### Static methods + + +#### construct + +```python3 +def construct( + _fields_set: Union[ForwardRef('SetStr'), NoneType] = None, + **values: Any +) -> 'Model' +``` + + +Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. + +Default values are respected, but no other validation is performed. +Behaves as if `Config.extra = 'allow'` was set since it adds all passed values + + +#### from_orm + +```python3 +def from_orm( + obj: Any +) -> 'Model' +``` + + + + +#### parse_file + +```python3 +def parse_file( + path: Union[str, pathlib.Path], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### parse_obj + +```python3 +def parse_obj( + obj: Any +) -> 'Model' +``` + + + + +#### parse_raw + +```python3 +def parse_raw( + b: Union[str, bytes], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### schema + +```python3 +def schema( + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}' +) -> 'DictStrAny' +``` + + + + +#### schema_json + +```python3 +def schema_json( + *, + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}', + **dumps_kwargs: Any +) -> 'unicode' +``` + + + + +#### update_forward_refs + +```python3 +def update_forward_refs( + **localns: Any +) -> None +``` + + +Try to update ForwardRefs on fields based on this Model, globalns and localns. + + +#### validate + +```python3 +def validate( + value: Any +) -> 'Model' +``` + + + +#### Methods + + +#### copy + +```python3 +def copy( + self: 'Model', + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + update: 'DictStrAny' = None, + deep: bool = False +) -> 'Model' +``` + + +Duplicate a model, optionally choose which fields to include, exclude and change. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| include | None | fields to include in new model | None | +| exclude | None | fields to exclude from new model, as with values this takes precedence over include | None | +| update | None | values to change/add in the new model. Note: the data is not validated before creating +the new model: you should trust this data | None | +| deep | None | set to `True` to make a deep copy of the model | None | + +**Returns:** + +| Type | Description | +|---|---| +| None | new model instance | + + +#### dict + +```python3 +def dict( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False +) -> 'DictStrAny' +``` + + +Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. + + +#### json + +```python3 +def json( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False, + encoder: Union[Callable[[Any], Any], NoneType] = None, + models_as_dict: bool = True, + **dumps_kwargs: Any +) -> 'unicode' +``` + + +Generate a JSON representation of the model, `include` and `exclude` arguments as per `dict()`. + +`encoder` is an optional function to supply as `default` to json.dumps(), other arguments as per `json.dumps()`. + +### ImageData + +```python3 +class ImageData( + data: numpy.ndarray, + mask: numpy.ndarray = NOTHING, + assets: Union[List, NoneType] = None, + bounds=None, + crs: Union[rasterio.crs.CRS, NoneType] = None, + metadata: Union[Dict, NoneType] = NOTHING, + band_names: Union[List[str], NoneType] = NOTHING +) +``` + +#### Attributes + +| Name | Type | Description | Default | +|---|---|---|---| +| data | numpy.ndarray | pixel values. | None | +| mask | numpy.ndarray | rasterio mask values. | None | +| assets | list | list of assets used to construct the data values. | None | +| bounds | BoundingBox | bounding box of the data. | None | +| crs | rasterio.crs.CRS | Coordinates Reference System of the bounds. | None | +| metadata | dict | Additional metadata. Defaults to `{}`. | `{}` | +| band_names | list | name of each band. Defaults to `["1", "2", "3"]` for 3 bands image. | `["1", "2", "3"]` for 3 bands image | + +#### Static methods + + +#### create_from_list + +```python3 +def create_from_list( + data: Sequence[ForwardRef('ImageData')] +) +``` + + +Create ImageData from a sequence of ImageData objects. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| data | sequence | sequence of ImageData. | None | + +#### Instance variables + +```python3 +count +``` + +Number of band. + +```python3 +height +``` + +Height of the data array. + +```python3 +transform +``` + +Returns the affine transform. + +```python3 +width +``` + +Width of the data array. + +#### Methods + + +#### as_masked + +```python3 +def as_masked( + self +) -> numpy.ma.core.MaskedArray +``` + + +return a numpy masked array. + + +#### data_as_image + +```python3 +def data_as_image( + self +) -> numpy.ndarray +``` + + +Return the data array reshaped into an image processing/visualization software friendly order. + +(bands, rows, columns) -> (rows, columns, bands). + + +#### post_process + +```python3 +def post_process( + self, + in_range: Union[Sequence[Tuple[Union[float, int], Union[float, int]]], NoneType] = None, + out_dtype: Union[str, numpy.number] = 'uint8', + color_formula: Union[str, NoneType] = None, + **kwargs: Any +) -> 'ImageData' +``` + + +Post-process image data. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| in_range | tuple | input min/max bounds value to rescale from. | None | +| out_dtype | str | output datatype after rescaling. Defaults to `uint8`. | `uint8` | +| color_formula | str | rio-color formula (see: https://github.com/mapbox/rio-color). | None | +| kwargs | optional | keyword arguments to forward to `rio_tiler.utils.linear_rescale`. | None | + +**Returns:** + +| Type | Description | +|---|---| +| ImageData | new ImageData object with the updated data. | + + +#### render + +```python3 +def render( + self, + add_mask: bool = True, + img_format: str = 'PNG', + colormap: Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType] = None, + **kwargs +) -> bytes +``` + + +Render data to image blob. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| add_mask | bool | add mask to output image. Defaults to True. | True | +| img_format | str | output image format. Defaults to PNG. | PNG | +| colormap | dict or sequence | RGBA Color Table dictionary or sequence. | None | +| kwargs | optional | keyword arguments to forward to `rio_tiler.utils.render`. | None | + +**Returns:** + +| Type | Description | +|---|---| +| bytes | image. | + +### Info + +```python3 +class Info( + __pydantic_self__, + **data: Any +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.models.SpatialInfo +* rio_tiler.models.Bounds +* rio_tiler.models.RioTilerBaseModel +* pydantic.main.BaseModel +* pydantic.utils.Representation + +#### Class variables + +```python3 +Config +``` + +#### Static methods + + +#### construct + +```python3 +def construct( + _fields_set: Union[ForwardRef('SetStr'), NoneType] = None, + **values: Any +) -> 'Model' +``` + + +Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. + +Default values are respected, but no other validation is performed. +Behaves as if `Config.extra = 'allow'` was set since it adds all passed values + + +#### from_orm + +```python3 +def from_orm( + obj: Any +) -> 'Model' +``` + + + + +#### parse_file + +```python3 +def parse_file( + path: Union[str, pathlib.Path], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### parse_obj + +```python3 +def parse_obj( + obj: Any +) -> 'Model' +``` + + + + +#### parse_raw + +```python3 +def parse_raw( + b: Union[str, bytes], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### schema + +```python3 +def schema( + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}' +) -> 'DictStrAny' +``` + + + + +#### schema_json + +```python3 +def schema_json( + *, + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}', + **dumps_kwargs: Any +) -> 'unicode' +``` + + + + +#### update_forward_refs + +```python3 +def update_forward_refs( + **localns: Any +) -> None +``` + + +Try to update ForwardRefs on fields based on this Model, globalns and localns. + + +#### validate + +```python3 +def validate( + value: Any +) -> 'Model' +``` + + + +#### Methods + + +#### copy + +```python3 +def copy( + self: 'Model', + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + update: 'DictStrAny' = None, + deep: bool = False +) -> 'Model' +``` + + +Duplicate a model, optionally choose which fields to include, exclude and change. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| include | None | fields to include in new model | None | +| exclude | None | fields to exclude from new model, as with values this takes precedence over include | None | +| update | None | values to change/add in the new model. Note: the data is not validated before creating +the new model: you should trust this data | None | +| deep | None | set to `True` to make a deep copy of the model | None | + +**Returns:** + +| Type | Description | +|---|---| +| None | new model instance | + + +#### dict + +```python3 +def dict( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False +) -> 'DictStrAny' +``` + + +Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. + + +#### json + +```python3 +def json( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False, + encoder: Union[Callable[[Any], Any], NoneType] = None, + models_as_dict: bool = True, + **dumps_kwargs: Any +) -> 'unicode' +``` + + +Generate a JSON representation of the model, `include` and `exclude` arguments as per `dict()`. + +`encoder` is an optional function to supply as `default` to json.dumps(), other arguments as per `json.dumps()`. + +### NodataTypes + +```python3 +class NodataTypes( + /, + *args, + **kwargs +) +``` + +#### Ancestors (in MRO) + +* builtins.str +* enum.Enum + +#### Class variables + +```python3 +Alpha +``` + +```python3 +Empty +``` + +```python3 +Internal +``` + +```python3 +Mask +``` + +```python3 +Nodata +``` + +```python3 +name +``` + +```python3 +value +``` + +### RioTilerBaseModel + +```python3 +class RioTilerBaseModel( + __pydantic_self__, + **data: Any +) +``` + +#### Ancestors (in MRO) + +* pydantic.main.BaseModel +* pydantic.utils.Representation + +#### Descendants + +* rio_tiler.models.Bounds +* rio_tiler.models.BandStatistics + +#### Class variables + +```python3 +Config +``` + +#### Static methods + + +#### construct + +```python3 +def construct( + _fields_set: Union[ForwardRef('SetStr'), NoneType] = None, + **values: Any +) -> 'Model' +``` + + +Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. + +Default values are respected, but no other validation is performed. +Behaves as if `Config.extra = 'allow'` was set since it adds all passed values + + +#### from_orm + +```python3 +def from_orm( + obj: Any +) -> 'Model' +``` + + + + +#### parse_file + +```python3 +def parse_file( + path: Union[str, pathlib.Path], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### parse_obj + +```python3 +def parse_obj( + obj: Any +) -> 'Model' +``` + + + + +#### parse_raw + +```python3 +def parse_raw( + b: Union[str, bytes], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### schema + +```python3 +def schema( + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}' +) -> 'DictStrAny' +``` + + + + +#### schema_json + +```python3 +def schema_json( + *, + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}', + **dumps_kwargs: Any +) -> 'unicode' +``` + + + + +#### update_forward_refs + +```python3 +def update_forward_refs( + **localns: Any +) -> None +``` + + +Try to update ForwardRefs on fields based on this Model, globalns and localns. + + +#### validate + +```python3 +def validate( + value: Any +) -> 'Model' +``` + + + +#### Methods + + +#### copy + +```python3 +def copy( + self: 'Model', + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + update: 'DictStrAny' = None, + deep: bool = False +) -> 'Model' +``` + + +Duplicate a model, optionally choose which fields to include, exclude and change. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| include | None | fields to include in new model | None | +| exclude | None | fields to exclude from new model, as with values this takes precedence over include | None | +| update | None | values to change/add in the new model. Note: the data is not validated before creating +the new model: you should trust this data | None | +| deep | None | set to `True` to make a deep copy of the model | None | + +**Returns:** + +| Type | Description | +|---|---| +| None | new model instance | + + +#### dict + +```python3 +def dict( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False +) -> 'DictStrAny' +``` + + +Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. + + +#### json + +```python3 +def json( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False, + encoder: Union[Callable[[Any], Any], NoneType] = None, + models_as_dict: bool = True, + **dumps_kwargs: Any +) -> 'unicode' +``` + + +Generate a JSON representation of the model, `include` and `exclude` arguments as per `dict()`. + +`encoder` is an optional function to supply as `default` to json.dumps(), other arguments as per `json.dumps()`. + +### SpatialInfo + +```python3 +class SpatialInfo( + __pydantic_self__, + **data: Any +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.models.Bounds +* rio_tiler.models.RioTilerBaseModel +* pydantic.main.BaseModel +* pydantic.utils.Representation + +#### Descendants + +* rio_tiler.models.Info + +#### Class variables + +```python3 +Config +``` + +#### Static methods + + +#### construct + +```python3 +def construct( + _fields_set: Union[ForwardRef('SetStr'), NoneType] = None, + **values: Any +) -> 'Model' +``` + + +Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. + +Default values are respected, but no other validation is performed. +Behaves as if `Config.extra = 'allow'` was set since it adds all passed values + + +#### from_orm + +```python3 +def from_orm( + obj: Any +) -> 'Model' +``` + + + + +#### parse_file + +```python3 +def parse_file( + path: Union[str, pathlib.Path], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### parse_obj + +```python3 +def parse_obj( + obj: Any +) -> 'Model' +``` + + + + +#### parse_raw + +```python3 +def parse_raw( + b: Union[str, bytes], + *, + content_type: 'unicode' = None, + encoding: 'unicode' = 'utf8', + proto: pydantic.parse.Protocol = None, + allow_pickle: bool = False +) -> 'Model' +``` + + + + +#### schema + +```python3 +def schema( + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}' +) -> 'DictStrAny' +``` + + + + +#### schema_json + +```python3 +def schema_json( + *, + by_alias: bool = True, + ref_template: 'unicode' = '#/definitions/{model}', + **dumps_kwargs: Any +) -> 'unicode' +``` + + + + +#### update_forward_refs + +```python3 +def update_forward_refs( + **localns: Any +) -> None +``` + + +Try to update ForwardRefs on fields based on this Model, globalns and localns. + + +#### validate + +```python3 +def validate( + value: Any +) -> 'Model' +``` + + + +#### Methods + + +#### copy + +```python3 +def copy( + self: 'Model', + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + update: 'DictStrAny' = None, + deep: bool = False +) -> 'Model' +``` + + +Duplicate a model, optionally choose which fields to include, exclude and change. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| include | None | fields to include in new model | None | +| exclude | None | fields to exclude from new model, as with values this takes precedence over include | None | +| update | None | values to change/add in the new model. Note: the data is not validated before creating +the new model: you should trust this data | None | +| deep | None | set to `True` to make a deep copy of the model | None | + +**Returns:** + +| Type | Description | +|---|---| +| None | new model instance | + + +#### dict + +```python3 +def dict( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False +) -> 'DictStrAny' +``` + + +Generate a dictionary representation of the model, optionally specifying which fields to include or exclude. + + +#### json + +```python3 +def json( + self, + *, + include: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + exclude: Union[ForwardRef('AbstractSetIntStr'), ForwardRef('MappingIntStrAny')] = None, + by_alias: bool = False, + skip_defaults: bool = None, + exclude_unset: bool = False, + exclude_defaults: bool = False, + exclude_none: bool = False, + encoder: Union[Callable[[Any], Any], NoneType] = None, + models_as_dict: bool = True, + **dumps_kwargs: Any +) -> 'unicode' +``` + + +Generate a JSON representation of the model, `include` and `exclude` arguments as per `dict()`. + +`encoder` is an optional function to supply as `default` to json.dumps(), other arguments as per `json.dumps()`. \ No newline at end of file diff --git a/docs/src/api/rio_tiler/mosaic/methods/base.md b/docs/src/api/rio_tiler/mosaic/methods/base.md new file mode 100644 index 00000000..9f0f0f91 --- /dev/null +++ b/docs/src/api/rio_tiler/mosaic/methods/base.md @@ -0,0 +1,65 @@ +# Module rio_tiler.mosaic.methods.base + +rio-tiler.mosaic.methods abc class. + +None + +## Classes + +### MosaicMethodBase + +```python3 +class MosaicMethodBase( + +) +``` + +#### Ancestors (in MRO) + +* abc.ABC + +#### Descendants + +* rio_tiler.mosaic.methods.defaults.FirstMethod +* rio_tiler.mosaic.methods.defaults.HighestMethod +* rio_tiler.mosaic.methods.defaults.LowestMethod +* rio_tiler.mosaic.methods.defaults.MeanMethod +* rio_tiler.mosaic.methods.defaults.MedianMethod +* rio_tiler.mosaic.methods.defaults.StdevMethod +* rio_tiler.mosaic.methods.defaults.LastBandHigh +* rio_tiler.mosaic.methods.defaults.LastBandLow + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile +) +``` + + +Fill mosaic tile. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tile | numpy.ma.ndarray | data | None | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/mosaic/methods/defaults.md b/docs/src/api/rio_tiler/mosaic/methods/defaults.md new file mode 100644 index 00000000..f2468de7 --- /dev/null +++ b/docs/src/api/rio_tiler/mosaic/methods/defaults.md @@ -0,0 +1,343 @@ +# Module rio_tiler.mosaic.methods.defaults + +rio_tiler.mosaic.methods.defaults: default mosaic filling methods. + +None + +## Classes + +### FirstMethod + +```python3 +class FirstMethod( + +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile +) +``` + + +Add data to tile. + +### HighestMethod + +```python3 +class HighestMethod( + +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile +) +``` + + +Add data to tile. + +### LastBandHigh + +```python3 +class LastBandHigh( + +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile: numpy.ma.core.MaskedArray +) +``` + + +Add data to tile. + +### LastBandLow + +```python3 +class LastBandLow( + +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile: numpy.ma.core.MaskedArray +) +``` + + +Add data to tile. + +### LowestMethod + +```python3 +class LowestMethod( + +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile +) +``` + + +Add data to tile. + +### MeanMethod + +```python3 +class MeanMethod( + enforce_data_type=True +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile +) +``` + + +Add data to tile. + +### MedianMethod + +```python3 +class MedianMethod( + enforce_data_type=True +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile +) +``` + + +Create a stack of tile. + +### StdevMethod + +```python3 +class StdevMethod( + enforce_data_type=True +) +``` + +#### Ancestors (in MRO) + +* rio_tiler.mosaic.methods.base.MosaicMethodBase +* abc.ABC + +#### Instance variables + +```python3 +data +``` + +Return data and mask. + +```python3 +is_done +``` + +Check if the tile filling is done. + +#### Methods + + +#### feed + +```python3 +def feed( + self, + tile +) +``` + + +Add data to tile. \ No newline at end of file diff --git a/docs/src/api/rio_tiler/mosaic/reader.md b/docs/src/api/rio_tiler/mosaic/reader.md new file mode 100644 index 00000000..9629c698 --- /dev/null +++ b/docs/src/api/rio_tiler/mosaic/reader.md @@ -0,0 +1,51 @@ +# Module rio_tiler.mosaic.reader + +rio_tiler.mosaic: create tile from multiple assets. + +None + +## Variables + +```python3 +MAX_THREADS +``` + +## Functions + + +### mosaic_reader + +```python3 +def mosaic_reader( + mosaic_assets: Sequence, + reader: Callable[..., rio_tiler.models.ImageData], + *args: Any, + pixel_selection: Union[Type[rio_tiler.mosaic.methods.base.MosaicMethodBase], rio_tiler.mosaic.methods.base.MosaicMethodBase] = , + chunk_size: Union[int, NoneType] = None, + threads: int = 40, + allowed_exceptions: Tuple = (,), + **kwargs +) -> Tuple[rio_tiler.models.ImageData, List] +``` + + +Merge multiple assets. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| mosaic_assets | sequence | List of assets. | None | +| reader | callable | Reader function. The function MUST take `(asset, *args, **kwargs)` as arguments, and MUST return an ImageData. | None | +| args | Any | Argument to forward to the reader function. | None | +| pixel_selection | MosaicMethod | Instance of MosaicMethodBase class. Defaults to `rio_tiler.mosaic.methods.defaults.FirstMethod`. | `rio_tiler.mosaic.methods.defaults.FirstMethod` | +| chunk_size | int | Control the number of asset to process per loop. | None | +| threads | int | Number of threads to use. If <= 1, runs single threaded without an event loop. By default reads from the MAX_THREADS environment variable, and if not found defaults to multiprocessing.cpu_count() * 5. | None | +| allowed_exceptions | tuple | List of exceptions which will be ignored. Note: `TileOutsideBounds` is likely to be raised and should be included in the allowed_exceptions. Defaults to `(TileOutsideBounds, )`. | `(TileOutsideBounds, )` | +| kwargs | optional | Reader callable's keywords options. | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | ImageData and assets (list). | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/profiles.md b/docs/src/api/rio_tiler/profiles.md new file mode 100644 index 00000000..b1d4f410 --- /dev/null +++ b/docs/src/api/rio_tiler/profiles.md @@ -0,0 +1,895 @@ +# Module rio_tiler.profiles + +Image file profiles. + +None + +## Variables + +```python3 +img_profiles +``` + +## Classes + +### ImagesProfiles + +```python3 +class ImagesProfiles( + +) +``` + +#### Ancestors (in MRO) + +* collections.UserDict +* collections.abc.MutableMapping +* collections.abc.Mapping +* collections.abc.Collection +* collections.abc.Sized +* collections.abc.Iterable +* collections.abc.Container + +#### Static methods + + +#### fromkeys + +```python3 +def fromkeys( + iterable, + value=None +) +``` + + + +#### Methods + + +#### clear + +```python3 +def clear( + self +) +``` + + +D.clear() -> None. Remove all items from D. + + +#### copy + +```python3 +def copy( + self +) +``` + + + + +#### get + +```python3 +def get( + self, + key, + default=None +) +``` + + +Like normal item access but return a copy of the key. + + +#### items + +```python3 +def items( + self +) +``` + + +D.items() -> a set-like object providing a view on D's items + + +#### keys + +```python3 +def keys( + self +) +``` + + +D.keys() -> a set-like object providing a view on D's keys + + +#### pop + +```python3 +def pop( + self, + key, + default= +) +``` + + +D.pop(k[,d]) -> v, remove specified key and return the corresponding value. + +If key is not found, d is returned if given, otherwise KeyError is raised. + + +#### popitem + +```python3 +def popitem( + self +) +``` + + +D.popitem() -> (k, v), remove and return some (key, value) pair + +as a 2-tuple; but raise KeyError if D is empty. + + +#### setdefault + +```python3 +def setdefault( + self, + key, + default=None +) +``` + + +D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D + + +#### update + +```python3 +def update( + self, + other=(), + /, + **kwds +) +``` + + +D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. + +If E present and has a .keys() method, does: for k in E: D[k] = E[k] +If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v +In either case, this is followed by: for k, v in F.items(): D[k] = v + + +#### values + +```python3 +def values( + self +) +``` + + +D.values() -> an object providing a view on D's values + +### JPEGProfile + +```python3 +class JPEGProfile( + data={}, + **kwds +) +``` + +#### Ancestors (in MRO) + +* rasterio.profiles.Profile +* collections.UserDict +* collections.abc.MutableMapping +* collections.abc.Mapping +* collections.abc.Collection +* collections.abc.Sized +* collections.abc.Iterable +* collections.abc.Container + +#### Class variables + +```python3 +defaults +``` + +#### Static methods + + +#### fromkeys + +```python3 +def fromkeys( + iterable, + value=None +) +``` + + + +#### Methods + + +#### clear + +```python3 +def clear( + self +) +``` + + +D.clear() -> None. Remove all items from D. + + +#### copy + +```python3 +def copy( + self +) +``` + + + + +#### get + +```python3 +def get( + self, + key, + default=None +) +``` + + +D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. + + +#### items + +```python3 +def items( + self +) +``` + + +D.items() -> a set-like object providing a view on D's items + + +#### keys + +```python3 +def keys( + self +) +``` + + +D.keys() -> a set-like object providing a view on D's keys + + +#### pop + +```python3 +def pop( + self, + key, + default= +) +``` + + +D.pop(k[,d]) -> v, remove specified key and return the corresponding value. + +If key is not found, d is returned if given, otherwise KeyError is raised. + + +#### popitem + +```python3 +def popitem( + self +) +``` + + +D.popitem() -> (k, v), remove and return some (key, value) pair + +as a 2-tuple; but raise KeyError if D is empty. + + +#### setdefault + +```python3 +def setdefault( + self, + key, + default=None +) +``` + + +D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D + + +#### update + +```python3 +def update( + self, + other=(), + /, + **kwds +) +``` + + +D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. + +If E present and has a .keys() method, does: for k in E: D[k] = E[k] +If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v +In either case, this is followed by: for k, v in F.items(): D[k] = v + + +#### values + +```python3 +def values( + self +) +``` + + +D.values() -> an object providing a view on D's values + +### PNGProfile + +```python3 +class PNGProfile( + data={}, + **kwds +) +``` + +#### Ancestors (in MRO) + +* rasterio.profiles.Profile +* collections.UserDict +* collections.abc.MutableMapping +* collections.abc.Mapping +* collections.abc.Collection +* collections.abc.Sized +* collections.abc.Iterable +* collections.abc.Container + +#### Class variables + +```python3 +defaults +``` + +#### Static methods + + +#### fromkeys + +```python3 +def fromkeys( + iterable, + value=None +) +``` + + + +#### Methods + + +#### clear + +```python3 +def clear( + self +) +``` + + +D.clear() -> None. Remove all items from D. + + +#### copy + +```python3 +def copy( + self +) +``` + + + + +#### get + +```python3 +def get( + self, + key, + default=None +) +``` + + +D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. + + +#### items + +```python3 +def items( + self +) +``` + + +D.items() -> a set-like object providing a view on D's items + + +#### keys + +```python3 +def keys( + self +) +``` + + +D.keys() -> a set-like object providing a view on D's keys + + +#### pop + +```python3 +def pop( + self, + key, + default= +) +``` + + +D.pop(k[,d]) -> v, remove specified key and return the corresponding value. + +If key is not found, d is returned if given, otherwise KeyError is raised. + + +#### popitem + +```python3 +def popitem( + self +) +``` + + +D.popitem() -> (k, v), remove and return some (key, value) pair + +as a 2-tuple; but raise KeyError if D is empty. + + +#### setdefault + +```python3 +def setdefault( + self, + key, + default=None +) +``` + + +D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D + + +#### update + +```python3 +def update( + self, + other=(), + /, + **kwds +) +``` + + +D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. + +If E present and has a .keys() method, does: for k in E: D[k] = E[k] +If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v +In either case, this is followed by: for k, v in F.items(): D[k] = v + + +#### values + +```python3 +def values( + self +) +``` + + +D.values() -> an object providing a view on D's values + +### PNGRAWProfile + +```python3 +class PNGRAWProfile( + data={}, + **kwds +) +``` + +#### Ancestors (in MRO) + +* rasterio.profiles.Profile +* collections.UserDict +* collections.abc.MutableMapping +* collections.abc.Mapping +* collections.abc.Collection +* collections.abc.Sized +* collections.abc.Iterable +* collections.abc.Container + +#### Class variables + +```python3 +defaults +``` + +#### Static methods + + +#### fromkeys + +```python3 +def fromkeys( + iterable, + value=None +) +``` + + + +#### Methods + + +#### clear + +```python3 +def clear( + self +) +``` + + +D.clear() -> None. Remove all items from D. + + +#### copy + +```python3 +def copy( + self +) +``` + + + + +#### get + +```python3 +def get( + self, + key, + default=None +) +``` + + +D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. + + +#### items + +```python3 +def items( + self +) +``` + + +D.items() -> a set-like object providing a view on D's items + + +#### keys + +```python3 +def keys( + self +) +``` + + +D.keys() -> a set-like object providing a view on D's keys + + +#### pop + +```python3 +def pop( + self, + key, + default= +) +``` + + +D.pop(k[,d]) -> v, remove specified key and return the corresponding value. + +If key is not found, d is returned if given, otherwise KeyError is raised. + + +#### popitem + +```python3 +def popitem( + self +) +``` + + +D.popitem() -> (k, v), remove and return some (key, value) pair + +as a 2-tuple; but raise KeyError if D is empty. + + +#### setdefault + +```python3 +def setdefault( + self, + key, + default=None +) +``` + + +D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D + + +#### update + +```python3 +def update( + self, + other=(), + /, + **kwds +) +``` + + +D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. + +If E present and has a .keys() method, does: for k in E: D[k] = E[k] +If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v +In either case, this is followed by: for k, v in F.items(): D[k] = v + + +#### values + +```python3 +def values( + self +) +``` + + +D.values() -> an object providing a view on D's values + +### WEBPProfile + +```python3 +class WEBPProfile( + data={}, + **kwds +) +``` + +#### Ancestors (in MRO) + +* rasterio.profiles.Profile +* collections.UserDict +* collections.abc.MutableMapping +* collections.abc.Mapping +* collections.abc.Collection +* collections.abc.Sized +* collections.abc.Iterable +* collections.abc.Container + +#### Class variables + +```python3 +defaults +``` + +#### Static methods + + +#### fromkeys + +```python3 +def fromkeys( + iterable, + value=None +) +``` + + + +#### Methods + + +#### clear + +```python3 +def clear( + self +) +``` + + +D.clear() -> None. Remove all items from D. + + +#### copy + +```python3 +def copy( + self +) +``` + + + + +#### get + +```python3 +def get( + self, + key, + default=None +) +``` + + +D.get(k[,d]) -> D[k] if k in D, else d. d defaults to None. + + +#### items + +```python3 +def items( + self +) +``` + + +D.items() -> a set-like object providing a view on D's items + + +#### keys + +```python3 +def keys( + self +) +``` + + +D.keys() -> a set-like object providing a view on D's keys + + +#### pop + +```python3 +def pop( + self, + key, + default= +) +``` + + +D.pop(k[,d]) -> v, remove specified key and return the corresponding value. + +If key is not found, d is returned if given, otherwise KeyError is raised. + + +#### popitem + +```python3 +def popitem( + self +) +``` + + +D.popitem() -> (k, v), remove and return some (key, value) pair + +as a 2-tuple; but raise KeyError if D is empty. + + +#### setdefault + +```python3 +def setdefault( + self, + key, + default=None +) +``` + + +D.setdefault(k[,d]) -> D.get(k,d), also set D[k]=d if k not in D + + +#### update + +```python3 +def update( + self, + other=(), + /, + **kwds +) +``` + + +D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. + +If E present and has a .keys() method, does: for k in E: D[k] = E[k] +If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v +In either case, this is followed by: for k, v in F.items(): D[k] = v + + +#### values + +```python3 +def values( + self +) +``` + + +D.values() -> an object providing a view on D's values \ No newline at end of file diff --git a/docs/src/api/rio_tiler/reader.md b/docs/src/api/rio_tiler/reader.md new file mode 100644 index 00000000..3c9d431c --- /dev/null +++ b/docs/src/api/rio_tiler/reader.md @@ -0,0 +1,169 @@ +# Module rio_tiler.reader + +rio-tiler.reader: low level reader. + +None + +## Functions + + +### part + +```python3 +def part( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT], + bounds: Tuple[float, float, float, float], + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + padding: int = 0, + dst_crs: Union[rasterio.crs.CRS, NoneType] = None, + bounds_crs: Union[rasterio.crs.CRS, NoneType] = None, + minimum_overlap: Union[float, NoneType] = None, + vrt_options: Union[Dict, NoneType] = None, + max_size: Union[int, NoneType] = None, + **kwargs: Any +) -> Tuple[numpy.ndarray, numpy.ndarray] +``` + + +Read part of a dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| src_dst | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| bounds | tuple | Output bounds (left, bottom, right, top). By default the coordinates are considered to be in either the dataset CRS or in the `dst_crs` if set. Use `bounds_crs` to set a specific CRS. | None | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| padding | int | Padding to apply to each edge of the tile when retrieving data to assist in reducing resampling artefacts along edges. Defaults to `0`. | `0` | +| dst_crs | rasterio.crs.CRS | Target coordinate reference system. | None | +| bounds_crs | rasterio.crs.CRS | Overwrite bounds Coordinate Reference System. | None | +| minimum_overlap | float | Minimum % overlap for which to raise an error with dataset not covering enough of the tile. | None | +| vrt_options | dict | Options to be passed to the rasterio.warp.WarpedVRT class. | None | +| max_size | int | Limit output size array if not width and height. | None | +| kwargs | optional | Additional options to forward to `rio_tiler.reader.read`. | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | Data (numpy.ndarray) and Mask (numpy.ndarray) values. | + + +### point + +```python3 +def point( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT], + coordinates: Tuple[float, float], + indexes: Union[Sequence[int], int, NoneType] = None, + coord_crs: rasterio.crs.CRS = CRS.from_epsg(4326), + masked: bool = True, + nodata: Union[float, int, str, NoneType] = None, + unscale: bool = False, + resampling_method: rasterio.enums.Resampling = 'nearest', + vrt_options: Union[Dict, NoneType] = None, + post_process: Union[Callable[[numpy.ndarray, numpy.ndarray], Tuple[numpy.ndarray, numpy.ndarray]], NoneType] = None +) -> List +``` + + +Read a pixel value for a point. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| src_dst | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| coordinates | tuple | Coordinates in form of (X, Y). | None | +| indexes | sequence of int or int | Band indexes. | None | +| coord_crs | rasterio.crs.CRS | Coordinate Reference System of the input coords. Defaults to `epsg:4326`. | `epsg:4326` | +| masked | bool | Mask samples that fall outside the extent of the dataset. Defaults to `True`. | `True` | +| nodata | int or float | Overwrite dataset internal nodata value. | None | +| unscale | bool | Apply 'scales' and 'offsets' on output data value. Defaults to `False`. | `False` | +| resampling_method | rasterio.enums.Resampling | Rasterio's resampling algorithm. Defaults to `nearest`. | `nearest` | +| vrt_options | dict | Options to be passed to the rasterio.warp.WarpedVRT class. | None | +| post_process | callable | Function to apply on output data and mask values. | None | + +**Returns:** + +| Type | Description | +|---|---| +| list | Pixel value per band indexes. | + + +### preview + +```python3 +def preview( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT], + max_size: int = 1024, + height: int = None, + width: int = None, + **kwargs: Any +) -> Tuple[numpy.ndarray, numpy.ndarray] +``` + + +Read decimated version of a dataset. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| src_dst | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| max_size | int | Limit output size array if not width and height. Defaults to `1024`. | `1024` | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| kwargs | optional | Additional options to forward to `rio_tiler.reader.read`. | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | Data (numpy.ndarray) and Mask (numpy.ndarray) values. | + + +### read + +```python3 +def read( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT], + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + indexes: Union[Sequence[int], int, NoneType] = None, + window: Union[rasterio.windows.Window, NoneType] = None, + force_binary_mask: bool = True, + nodata: Union[float, int, str, NoneType] = None, + unscale: bool = False, + resampling_method: rasterio.enums.Resampling = 'nearest', + vrt_options: Union[Dict, NoneType] = None, + post_process: Union[Callable[[numpy.ndarray, numpy.ndarray], Tuple[numpy.ndarray, numpy.ndarray]], NoneType] = None +) -> Tuple[numpy.ndarray, numpy.ndarray] +``` + + +Low level read function. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| src_dst | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| height | int | Output height of the array. | None | +| width | int | Output width of the array. | None | +| indexes | sequence of int or int | Band indexes. | None | +| window | rasterio.windows.Window | Window to read. | None | +| force_binary_mask | bool | Cast returned mask to binary values (0 or 255). Defaults to `True`. | `True` | +| nodata | int or float | Overwrite dataset internal nodata value. | None | +| unscale | bool | Apply 'scales' and 'offsets' on output data value. Defaults to `False`. | `False` | +| resampling_method | rasterio.enums.Resampling | Rasterio's resampling algorithm. Defaults to `nearest`. | `nearest` | +| vrt_options | dict | Options to be passed to the rasterio.warp.WarpedVRT class. | None | +| post_process | callable | Function to apply on output data and mask values. | None | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | Data (numpy.ndarray) and Mask (numpy.ndarray) values. | \ No newline at end of file diff --git a/docs/src/api/rio_tiler/tasks.md b/docs/src/api/rio_tiler/tasks.md new file mode 100644 index 00000000..98537f48 --- /dev/null +++ b/docs/src/api/rio_tiler/tasks.md @@ -0,0 +1,93 @@ +# Module rio_tiler.tasks + +rio_tiler.tasks: tools for handling rio-tiler's future tasks. + +None + +## Variables + +```python3 +MAX_THREADS +``` + +```python3 +TaskType +``` + +## Functions + + +### create_tasks + +```python3 +def create_tasks( + reader: Callable, + asset_list: Sequence, + threads: int, + *args, + **kwargs +) -> Sequence[Tuple[Union[concurrent.futures._base.Future, Callable], Any]] +``` + + +Create Future Tasks. + + +### filter_tasks + +```python3 +def filter_tasks( + tasks: Sequence[Tuple[Union[concurrent.futures._base.Future, Callable], Any]], + allowed_exceptions: Union[Tuple, NoneType] = None +) -> Generator +``` + + +Filter Tasks to remove Exceptions. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| tasks | sequence | Sequence of 'concurrent.futures._base.Future' or 'Callable' | None | +| allowed_exceptions | tuple | List of exceptions which won't be raised. | None | + +**Yields:** + +| Type | Description | +|---|---| +| None | Task results. | + + +### multi_arrays + +```python3 +def multi_arrays( + asset_list: Sequence, + reader: Callable[..., rio_tiler.models.ImageData], + *args: Any, + threads: int = 40, + allowed_exceptions: Union[Tuple, NoneType] = None, + **kwargs: Any +) -> rio_tiler.models.ImageData +``` + + +Merge arrays returned from tasks. + + +### multi_values + +```python3 +def multi_values( + asset_list: Sequence, + reader: Callable, + *args: Any, + threads: int = 40, + allowed_exceptions: Union[Tuple, NoneType] = None, + **kwargs: Any +) -> Dict +``` + + +Merge values returned from tasks. \ No newline at end of file diff --git a/docs/src/api/rio_tiler/utils.md b/docs/src/api/rio_tiler/utils.md new file mode 100644 index 00000000..07288974 --- /dev/null +++ b/docs/src/api/rio_tiler/utils.md @@ -0,0 +1,314 @@ +# Module rio_tiler.utils + +rio_tiler.utils: utility functions. + +None + +## Functions + + +### aws_get_object + +```python3 +def aws_get_object( + bucket: str, + key: str, + request_pays: bool = False, + client: = None +) -> bytes +``` + + +AWS s3 get object content. + + +### create_cutline + +```python3 +def create_cutline( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT], + geometry: Dict, + geometry_crs: rasterio.crs.CRS = None +) -> str +``` + + +Create WKT Polygon Cutline for GDALWarpOptions. + +Ref: https://gdal.org/api/gdalwarp_cpp.html?highlight=vrt#_CPPv415GDALWarpOptions + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| src_dst | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| geometry | dict | GeoJSON feature or GeoJSON geometry. By default the coordinates are considered to be in the dataset CRS. Use `geometry_crs` to set a specific CRS. | None | +| geometry_crs | rasterio.crs.CRS | Input geometry Coordinate Reference System | None | + +**Returns:** + +| Type | Description | +|---|---| +| str | WKT geometry in form of `POLYGON ((x y, x y, ...))) | + + +### get_array_statistics + +```python3 +def get_array_statistics( + data: numpy.ma.core.MaskedArray, + categorical: bool = False, + categories: Union[List[float], NoneType] = None, + percentiles: List[int] = [2, 98], + **kwargs: Any +) -> List[Dict[Any, Any]] +``` + + +Calculate per band array statistics. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| data | numpy.ma.MaskedArray | input masked array data to get the statistics from. | None | +| categorical | bool | treat input data as categorical data. Defaults to False. | False | +| categories | list of numbers | list of categories to return value for. | None | +| percentiles | list of numbers | list of percentile values to calculate. Defaults to `[2, 98]`. | `[2, 98]` | +| kwargs | optional | options to forward to `numpy.histogram` function (only applies for non-categorical data). | None | + +**Returns:** + +| Type | Description | +|---|---| +| None | list of dict | + + +### get_bands_names + +```python3 +def get_bands_names( + indexes: Union[Sequence[int], NoneType] = None, + expression: Union[str, NoneType] = None, + count: Union[int, NoneType] = None +) -> List[str] +``` + + +Define bands names based on expression, indexes or band count. + + +### get_overview_level + +```python3 +def get_overview_level( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT], + bounds: Tuple[float, float, float, float], + height: int, + width: int, + dst_crs: rasterio.crs.CRS = CRS.from_epsg(3857) +) -> int +``` + + +Return the overview level corresponding to the tile resolution. + +Freely adapted from https://github.com/OSGeo/gdal/blob/41993f127e6e1669fbd9e944744b7c9b2bd6c400/gdal/apps/gdalwarp_lib.cpp#L2293-L2362 + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| src_dst | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| bounds | tuple | Bounding box coordinates in target crs (**dst_crs**). | None | +| height | int | Desired output height of the array for the input bounds. | None | +| width | int | Desired output width of the array for the input bounds. | None | +| dst_crs | rasterio.crs.CRS | Target Coordinate Reference System. Defaults to `epsg:3857`. | `epsg:3857` | + +**Returns:** + +| Type | Description | +|---|---| +| int | Overview level. | + + +### get_vrt_transform + +```python3 +def get_vrt_transform( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT], + bounds: Tuple[float, float, float, float], + height: Union[int, NoneType] = None, + width: Union[int, NoneType] = None, + dst_crs: rasterio.crs.CRS = CRS.from_epsg(3857), + window_precision: int = 6 +) -> Tuple[affine.Affine, int, int] +``` + + +Calculate VRT transform. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| src_dst | rasterio.io.DatasetReader or rasterio.io.DatasetWriter or rasterio.vrt.WarpedVRT | Rasterio dataset. | None | +| bounds | tuple | Bounding box coordinates in target crs (**dst_crs**). | None | +| height | int | Desired output height of the array for the input bounds. | None | +| width | int | Desired output width of the array for the input bounds. | None | +| dst_crs | rasterio.crs.CRS | Target Coordinate Reference System. Defaults to `epsg:3857`. | `epsg:3857` | + +**Returns:** + +| Type | Description | +|---|---| +| tuple | VRT transform (affine.Affine), width (int) and height (int) | + + +### has_alpha_band + +```python3 +def has_alpha_band( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT] +) -> bool +``` + + +Check for alpha band or mask in source. + + +### has_mask_band + +```python3 +def has_mask_band( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT] +) -> bool +``` + + +Check for mask band in source. + + +### linear_rescale + +```python3 +def linear_rescale( + image: numpy.ndarray, + in_range: Tuple[Union[float, int], Union[float, int]], + out_range: Tuple[Union[float, int], Union[float, int]] = (0, 255) +) -> numpy.ndarray +``` + + +Apply linear rescaling to a numpy array. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| image | numpy.ndarray | array to rescale. | None | +| in_range | tuple | array min/max value to rescale from. | None | +| out_range | tuple | output min/max bounds to rescale to. Defaults to `(0, 255)`. | `(0, 255)` | + +**Returns:** + +| Type | Description | +|---|---| +| numpy.ndarray | linear rescaled array. | + + +### mapzen_elevation_rgb + +```python3 +def mapzen_elevation_rgb( + data: numpy.ndarray +) -> numpy.ndarray +``` + + +Encode elevation value to RGB values compatible with Mapzen tangram. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| data | numpy.ndarray | Image array to encode. +Returns | None | +| numpy.ndarray | None | Elevation encoded in a RGB array. | None | + + +### non_alpha_indexes + +```python3 +def non_alpha_indexes( + src_dst: Union[rasterio.io.DatasetReader, rasterio.io.DatasetWriter, rasterio.vrt.WarpedVRT] +) -> Tuple +``` + + +Return indexes of non-alpha bands. + + +### pansharpening_brovey + +```python3 +def pansharpening_brovey( + rgb: numpy.ndarray, + pan: numpy.ndarray, + weight: float, + pan_dtype: str +) -> numpy.ndarray +``` + + +Apply Brovey pansharpening method. + +Brovey Method: Each resampled, multispectral pixel is +multiplied by the ratio of the corresponding +panchromatic pixel intensity to the sum of all the +multispectral intensities. + +Original code from https://github.com/mapbox/rio-pansharpen + + +### render + +```python3 +def render( + data: numpy.ndarray, + mask: Union[numpy.ndarray, NoneType] = None, + img_format: str = 'PNG', + colormap: Union[Dict[int, Tuple[int, int, int, int]], Sequence[Tuple[Tuple[Union[float, int], Union[float, int]], Tuple[int, int, int, int]]], NoneType] = None, + **creation_options: Any +) -> bytes +``` + + +Translate numpy.ndarray to image bytes. + +**Parameters:** + +| Name | Type | Description | Default | +|---|---|---|---| +| data | numpy.ndarray | Image array to encode. | None | +| mask | numpy.ndarray | Mask array. | None | +| img_format | str | Image format. See: for the list of supported format by GDAL: https://www.gdal.org/formats_list.html. Defaults to `PNG`. | `PNG` | +| colormap | dict or sequence | RGBA Color Table dictionary or sequence. | None | +| creation_options | optional | Image driver creation options to forward to GDAL. +Returns | None | +| bytes | None | image body. | None | + + +### resize_array + +```python3 +def resize_array( + data: numpy.ndarray, + height: int, + width: int, + resampling_method: rasterio.enums.Resampling = 'nearest' +) -> numpy.ndarray +``` + + +resize array to a given height and width. \ No newline at end of file diff --git a/docs/colormap.md b/docs/src/colormap.md similarity index 97% rename from docs/colormap.md rename to docs/src/colormap.md index e8f17764..9799c63b 100644 --- a/docs/colormap.md +++ b/docs/src/colormap.md @@ -145,8 +145,8 @@ data, mask = apply_cmap(data, cmap) ### Update images for new colormaps To regenerate these images for new colormaps, update the list of colormaps at -the top of `scripts/colormap_thumb.py` and then run +the top of `docs/scripts/colormap_thumb.py` and then run ```bash -python scripts/colormap_thumb.py +python docs/scripts/colormap_thumb.py ``` diff --git a/docs/src/contributing.md b/docs/src/contributing.md new file mode 120000 index 00000000..f939e75f --- /dev/null +++ b/docs/src/contributing.md @@ -0,0 +1 @@ +../../CONTRIBUTING.md \ No newline at end of file diff --git a/docs/examples/Using-nonEarth-dataset.ipynb b/docs/src/examples/Using-nonEarth-dataset.ipynb similarity index 100% rename from docs/examples/Using-nonEarth-dataset.ipynb rename to docs/src/examples/Using-nonEarth-dataset.ipynb diff --git a/docs/examples/Using-rio-tiler-STACReader.ipynb b/docs/src/examples/Using-rio-tiler-STACReader.ipynb similarity index 100% rename from docs/examples/Using-rio-tiler-STACReader.ipynb rename to docs/src/examples/Using-rio-tiler-STACReader.ipynb diff --git a/docs/examples/Using-rio-tiler-mosaic.ipynb b/docs/src/examples/Using-rio-tiler-mosaic.ipynb similarity index 100% rename from docs/examples/Using-rio-tiler-mosaic.ipynb rename to docs/src/examples/Using-rio-tiler-mosaic.ipynb diff --git a/docs/examples/Using-rio-tiler.ipynb b/docs/src/examples/Using-rio-tiler.ipynb similarity index 100% rename from docs/examples/Using-rio-tiler.ipynb rename to docs/src/examples/Using-rio-tiler.ipynb diff --git a/docs/examples/Using-tms.ipynb b/docs/src/examples/Using-tms.ipynb similarity index 100% rename from docs/examples/Using-tms.ipynb rename to docs/src/examples/Using-tms.ipynb diff --git a/docs/img/custom.png b/docs/src/img/custom.png similarity index 100% rename from docs/img/custom.png rename to docs/src/img/custom.png diff --git a/docs/img/cyclic.png b/docs/src/img/cyclic.png similarity index 100% rename from docs/img/cyclic.png rename to docs/src/img/cyclic.png diff --git a/docs/img/diverging.png b/docs/src/img/diverging.png similarity index 100% rename from docs/img/diverging.png rename to docs/src/img/diverging.png diff --git a/docs/img/miscellaneous.png b/docs/src/img/miscellaneous.png similarity index 100% rename from docs/img/miscellaneous.png rename to docs/src/img/miscellaneous.png diff --git a/docs/img/perceptually_uniform_sequential.png b/docs/src/img/perceptually_uniform_sequential.png similarity index 100% rename from docs/img/perceptually_uniform_sequential.png rename to docs/src/img/perceptually_uniform_sequential.png diff --git a/docs/img/qualitative.png b/docs/src/img/qualitative.png similarity index 100% rename from docs/img/qualitative.png rename to docs/src/img/qualitative.png diff --git a/docs/img/sequential.png b/docs/src/img/sequential.png similarity index 100% rename from docs/img/sequential.png rename to docs/src/img/sequential.png diff --git a/docs/img/sequential_(2).png b/docs/src/img/sequential_(2).png similarity index 100% rename from docs/img/sequential_(2).png rename to docs/src/img/sequential_(2).png diff --git a/docs/img/vrt_tile.png b/docs/src/img/vrt_tile.png similarity index 100% rename from docs/img/vrt_tile.png rename to docs/src/img/vrt_tile.png diff --git a/docs/src/index.md b/docs/src/index.md new file mode 120000 index 00000000..fe840054 --- /dev/null +++ b/docs/src/index.md @@ -0,0 +1 @@ +../../README.md \ No newline at end of file diff --git a/docs/intro.md b/docs/src/intro.md similarity index 100% rename from docs/intro.md rename to docs/src/intro.md diff --git a/docs/models.md b/docs/src/models.md similarity index 100% rename from docs/models.md rename to docs/src/models.md diff --git a/docs/mosaic.md b/docs/src/mosaic.md similarity index 100% rename from docs/mosaic.md rename to docs/src/mosaic.md diff --git a/docs/overrides/main.html b/docs/src/overrides/main.html similarity index 100% rename from docs/overrides/main.html rename to docs/src/overrides/main.html diff --git a/docs/readers.md b/docs/src/readers.md similarity index 100% rename from docs/readers.md rename to docs/src/readers.md diff --git a/docs/src/release-notes.md b/docs/src/release-notes.md new file mode 120000 index 00000000..8980b4a7 --- /dev/null +++ b/docs/src/release-notes.md @@ -0,0 +1 @@ +../../CHANGES.md \ No newline at end of file diff --git a/docs/supported_format.md b/docs/src/supported_format.md similarity index 100% rename from docs/supported_format.md rename to docs/src/supported_format.md diff --git a/docs/v2_migration.md b/docs/src/v2_migration.md similarity index 100% rename from docs/v2_migration.md rename to docs/src/v2_migration.md diff --git a/docs/v3_migration.md b/docs/src/v3_migration.md similarity index 100% rename from docs/v3_migration.md rename to docs/src/v3_migration.md diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..66740332 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,90 @@ +[project] +name = "rio-tiler" +description = "User friendly Rasterio plugin to read raster datasets." +readme = "README.md" +requires-python = ">=3.7" +license = {file = "LICENSE"} +authors = [ + {name = "Vincent Sarago", email = "vincent@developmentseed.com"}, +] +keywords = ["COGEO", "Cloud Optimized Geotiff", "rasterio", "slippy-map", "STAC"] +classifiers = [ + "Intended Audience :: Information Technology", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Topic :: Scientific/Engineering :: GIS", +] +dynamic = ["version"] +dependencies = [ + "attrs", + "boto3", + "cachetools", + "httpx", + "numexpr", + "numpy", + "morecantile>=3.1,<4.0", + "pydantic", + "pystac>=0.5.4", + "rasterio>=1.1.7", + "rio-color", + "importlib_resources>=1.1.0; python_version < '3.9'", +] + +[project.optional-dependencies] +test = [ + "pytest", + "pytest-asyncio", + "pytest-benchmark", + "pytest-cov", +] +dev = [ + "pre-commit", +] +docs = [ + "nbconvert", + "mkdocs", + "mkdocs-jupyter", + "mkdocs-material", + "pygments", +] + +[project.urls] +Source = "https://github.com/cogeotiff/rio-tiler" +Documentation = "https://cogeotiff.github.io/rio-tiler/" + +[build-system] +requires = ["flit>=3.2,<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.module] +name = "rio_tiler" + +[tool.flit.sdist] +exclude = [ + "tests/", + "docs/", + ".github/", + "CHANGES.md", + "CONTRIBUTING.md", +] + +[tool.isort] +profile = "black" +known_first_party = ["rio_tiler"] +known_third_party = [ + "rasterio", + "morecantile", + "affine", + "pystac", +] +default_section = "THIRDPARTY" + +[tool.mypy] +no_strict_optional = "True" + +[tool.pydocstyle] +select = "D1" +match = "(?!test).*.py" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 36164b97..00000000 --- a/requirements.txt +++ /dev/null @@ -1,11 +0,0 @@ -attrs -boto3 -numexpr -numpy -morecantile>=3.1,<4.0 -pydantic -pystac>=0.5.4 -rasterio>=1.1.7 -httpx -rio-color -importlib_resources>=1.1.0;python_version<'3.9' diff --git a/rio_tiler/__init__.py b/rio_tiler/__init__.py index 9d7c15b4..13efab65 100644 --- a/rio_tiler/__init__.py +++ b/rio_tiler/__init__.py @@ -1,5 +1,7 @@ """rio-tiler.""" +__version__ = "3.1.2" + from . import ( # noqa colormap, constants, @@ -12,5 +14,3 @@ tasks, utils, ) - -__version__ = "3.1.2" diff --git a/rio_tiler/colormap.py b/rio_tiler/colormap.py index 2a8bda97..b8500f39 100644 --- a/rio_tiler/colormap.py +++ b/rio_tiler/colormap.py @@ -246,7 +246,7 @@ def parse_color(rgba: Union[Sequence[int], str]) -> Tuple[int, int, int, int]: match = re.match(hex_pattern, rgba) rgba = [ - int(n * factor, 16) for n in match.groupdict().values() if n is not None + int(n * factor, 16) for n in match.groupdict().values() if n is not None # type: ignore ] if len(rgba) > 4 or len(rgba) < 3: diff --git a/rio_tiler/io/base.py b/rio_tiler/io/base.py index 912f02a9..5e52e171 100644 --- a/rio_tiler/io/base.py +++ b/rio_tiler/io/base.py @@ -373,7 +373,7 @@ def _get_asset_url(self, asset: str) -> str: def parse_expression(self, expression: str) -> Tuple: """Parse rio-tiler band math expression.""" - assets = "|".join([fr"\b{asset}\b" for asset in self.assets]) + assets = "|".join([rf"\b{asset}\b" for asset in self.assets]) _re = re.compile(assets.replace("\\\\", "\\")) return tuple(set(re.findall(_re, expression))) @@ -445,8 +445,8 @@ def _reader(asset: str, *args, **kwargs) -> Dict: with self.reader(url, tms=self.tms, **self.reader_options) as cog: # type: ignore return cog.statistics( *args, - indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), - expression=asset_expression.get(asset), + indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), # type: ignore + expression=asset_expression.get(asset), # type: ignore **kwargs, ) @@ -573,8 +573,8 @@ def _reader(asset: str, *args: Any, **kwargs: Any) -> ImageData: with self.reader(url, tms=self.tms, **self.reader_options) as cog: # type: ignore data = cog.tile( *args, - indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), - expression=asset_expression.get(asset), + indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), # type: ignore + expression=asset_expression.get(asset), # type: ignore **kwargs, ) data.band_names = [f"{asset}_{n}" for n in data.band_names] @@ -644,8 +644,8 @@ def _reader(asset: str, *args: Any, **kwargs: Any) -> ImageData: with self.reader(url, tms=self.tms, **self.reader_options) as cog: # type: ignore data = cog.part( *args, - indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), - expression=asset_expression.get(asset), + indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), # type: ignore + expression=asset_expression.get(asset), # type: ignore **kwargs, ) data.band_names = [f"{asset}_{n}" for n in data.band_names] @@ -705,8 +705,8 @@ def _reader(asset: str, **kwargs: Any) -> ImageData: url = self._get_asset_url(asset) with self.reader(url, tms=self.tms, **self.reader_options) as cog: # type: ignore data = cog.preview( - indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), - expression=asset_expression.get(asset), + indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), # type: ignore + expression=asset_expression.get(asset), # type: ignore **kwargs, ) data.band_names = [f"{asset}_{n}" for n in data.band_names] @@ -771,8 +771,8 @@ def _reader(asset: str, *args, **kwargs: Any) -> Dict: with self.reader(url, tms=self.tms, **self.reader_options) as cog: # type: ignore return cog.point( *args, - indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), - expression=asset_expression.get(asset), + indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), # type: ignore + expression=asset_expression.get(asset), # type: ignore **kwargs, ) @@ -833,8 +833,8 @@ def _reader(asset: str, *args: Any, **kwargs: Any) -> ImageData: with self.reader(url, tms=self.tms, **self.reader_options) as cog: # type: ignore data = cog.feature( *args, - indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), - expression=asset_expression.get(asset), + indexes=asset_indexes.get(asset, kwargs.pop("indexes", None)), # type: ignore + expression=asset_expression.get(asset), # type: ignore **kwargs, ) data.band_names = [f"{asset}_{n}" for n in data.band_names] @@ -887,7 +887,7 @@ def _get_band_url(self, band: str) -> str: def parse_expression(self, expression: str) -> Tuple: """Parse rio-tiler band math expression.""" - bands = "|".join([fr"\b{band}\b" for band in self.bands]) + bands = "|".join([rf"\b{band}\b" for band in self.bands]) _re = re.compile(bands.replace("\\\\", "\\")) return tuple(set(re.findall(_re, expression))) diff --git a/rio_tiler/io/cogeo.py b/rio_tiler/io/cogeo.py index 76871649..38268ce1 100644 --- a/rio_tiler/io/cogeo.py +++ b/rio_tiler/io/cogeo.py @@ -171,7 +171,7 @@ def get_zooms(self, tilesize: int = 256) -> Tuple[int, int]: # The minzoom is defined by the resolution of the maximum theoretical overview level overview_level = get_maximum_overview_level(w, h, minsize=tilesize) - ovr_resolution = resolution * (2 ** overview_level) + ovr_resolution = resolution * (2**overview_level) minzoom = self.tms.zoom_for_res(ovr_resolution) return (minzoom, maxzoom) @@ -416,7 +416,7 @@ def part( **kwargs, ) - if expression: + if expression and indexes: blocks = get_expression_blocks(expression) bands = [f"b{bidx}" for bidx in indexes] data = apply_expression(blocks, bands, data) @@ -481,7 +481,7 @@ def preview( **kwargs, ) - if expression: + if expression and indexes: blocks = get_expression_blocks(expression) bands = [f"b{bidx}" for bidx in indexes] data = apply_expression(blocks, bands, data) @@ -538,7 +538,7 @@ def point( self.dataset, (lon, lat), indexes=indexes, coord_crs=coord_crs, **kwargs ) - if expression: + if expression and indexes: blocks = get_expression_blocks(expression) bands = [f"b{bidx}" for bidx in indexes] point = apply_expression(blocks, bands, numpy.array(point)).tolist() @@ -630,7 +630,7 @@ def read( data, mask = reader.read(self.dataset, indexes=indexes, **kwargs) - if expression: + if expression and indexes: blocks = get_expression_blocks(expression) bands = [f"b{bidx}" for bidx in indexes] data = apply_expression(blocks, bands, data) diff --git a/rio_tiler/models.py b/rio_tiler/models.py index 634cb7c0..9e557ec0 100644 --- a/rio_tiler/models.py +++ b/rio_tiler/models.py @@ -122,7 +122,7 @@ class ImageData: bounds: Optional[BoundingBox] = attr.ib(default=None, converter=to_coordsbbox) crs: Optional[CRS] = attr.ib(default=None) metadata: Optional[Dict] = attr.ib(factory=dict) - band_names: Optional[List[str]] = attr.ib() + band_names: List[str] = attr.ib() @data.validator def _validate_data(self, attribute, value): diff --git a/rio_tiler/mosaic/reader.py b/rio_tiler/mosaic/reader.py index bd093ee5..3b94f2ae 100644 --- a/rio_tiler/mosaic/reader.py +++ b/rio_tiler/mosaic/reader.py @@ -73,9 +73,9 @@ def mosaic_reader( chunk_size = threads if threads > 1 else len(mosaic_assets) assets_used: List = [] - crs: Optional[CRS] = None - bounds: Optional[BBox] = None - band_names: Optional[List[str]] = None + crs: Optional[CRS] + bounds: Optional[BBox] + band_names: List[str] for chunks in _chunks(mosaic_assets, chunk_size): tasks = create_tasks(reader, chunks, threads, *args, **kwargs) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index f364f67f..00000000 --- a/setup.cfg +++ /dev/null @@ -1,37 +0,0 @@ -[bumpversion] -current_version = 3.1.2 -commit = True -tag = True -tag_name = {new_version} -parse = - (?P\d+)\.(?P\d+)\.(?P\d+) - ((?P
a|b|rc)(?P\d+))?
-serialize = 
-	{major}.{minor}.{patch}{pre}{prenum}
-	{major}.{minor}.{patch}
-
-[metadata]
-version = attr: rio_tiler.__version__
-
-[bumpversion:file:rio_tiler/__init__.py]
-search = __version__ = "{current_version}"
-replace = __version__ = "{new_version}"
-
-[isort]
-profile = black
-known_first_party = rio_tiler
-known_third_party = rasterio,morecantile,mercantile,supermercado,affine,pystac
-default_section = THIRDPARTY
-
-[flake8]
-ignore = E501,W503,E203
-exclude = .git,__pycache__,docs/source/conf.py,old,build,dist
-max-complexity = 12
-max-line-length = 90
-
-[mypy]
-no_strict_optional = True
-
-[pydocstyle]
-select = D1
-match = (?!test).*\.py
diff --git a/setup.py b/setup.py
deleted file mode 100644
index e003c625..00000000
--- a/setup.py
+++ /dev/null
@@ -1,68 +0,0 @@
-"""Setup for rio-tiler."""
-
-from setuptools import find_packages, setup
-
-with open("README.md") as f:
-    readme = f.read()
-
-# Runtime requirements.
-inst_reqs = [
-    "attrs",
-    "boto3",
-    "numexpr",
-    "numpy",
-    "morecantile>=3.1,<4.0",
-    "pydantic",
-    "pystac>=0.5.4",
-    "rasterio>=1.1.7",
-    "httpx",
-    "rio-color",
-    "cachetools",
-    "importlib_resources>=1.1.0;python_version<'3.9'",
-]
-
-extra_reqs = {
-    "test": [
-        "pytest",
-        "pytest-asyncio",
-        "pytest-benchmark",
-        "pytest-cov",
-    ],
-    "dev": [
-        "pytest",
-        "pytest-benchmark",
-        "pytest-cov",
-        "pytest-asyncio",
-        "pre-commit",
-        "tox",
-    ],
-    "docs": ["nbconvert", "mkdocs", "mkdocs-material", "pygments", "mkdocs-jupyter"],
-}
-
-setup(
-    name="rio-tiler",
-    python_requires=">=3.7",
-    description="User friendly Rasterio plugin to read raster datasets.",
-    long_description=readme,
-    long_description_content_type="text/markdown",
-    classifiers=[
-        "Intended Audience :: Information Technology",
-        "Intended Audience :: Science/Research",
-        "License :: OSI Approved :: BSD License",
-        "Programming Language :: Python :: 3.9",
-        "Programming Language :: Python :: 3.8",
-        "Programming Language :: Python :: 3.7",
-        "Topic :: Scientific/Engineering :: GIS",
-    ],
-    keywords="cog cogeotiff raster map tiles gdal rasterio raster-processing slippy-map",
-    author="Vincent Sarago",
-    author_email="vincent@developmentseed.org",
-    url="https://github.com/cogeotiff/rio-tiler",
-    license="BSD",
-    packages=find_packages(exclude=["tests*"]),
-    include_package_data=True,
-    package_data={"rio_tiler": ["py.typed", "cmap_data/*.npy"]},
-    zip_safe=False,
-    install_requires=inst_reqs,
-    extras_require=extra_reqs,
-)
diff --git a/tox.ini b/tox.ini
deleted file mode 100644
index af7a814a..00000000
--- a/tox.ini
+++ /dev/null
@@ -1,35 +0,0 @@
-[tox]
-envlist = py37,py38,p39
-
-[testenv]
-extras = test
-commands=
-    python -m pytest --cov rio_tiler --cov-report xml --cov-report term-missing --benchmark-skip --ignore=venv
-
-[testenv:benchmark]
-extras = test
-commands=
-    python -m pytest --benchmark-only --benchmark-autosave --benchmark-columns 'min, max, mean, median' --benchmark-sort 'min'
-
-# Release tooling
-[testenv:build]
-basepython = python3
-skip_install = true
-deps =
-    wheel
-    setuptools
-commands =
-    python setup.py sdist
-
-[testenv:release]
-setenv =
-    TWINE_USERNAME = {env:TWINE_USERNAME}
-    TWINE_PASSWORD = {env:TWINE_PASSWORD}
-basepython = python3
-skip_install = true
-deps =
-    {[testenv:build]deps}
-    twine >= 1.5.0
-commands =
-    {[testenv:build]commands}
-    twine upload --skip-existing dist/*