Skip to content

Margin size error #2

@srose89

Description

@srose89

The following error thrown for some samples:

ValueError: Margin (20.0) is too large, causing 2 tile(s) to disappear. Consider using a smaller margin.

Implemented fix that just gives a warning and removes the missing tiles.

in _query_tiles in tiling.py

        if margin < 0:
            raise ValueError(
                f"The margin must be non-negative, but got {margin}."
            )
        # Buffer tiles
        tiles = self.tiles
        if margin > 0:
            buffered = tiles.buffer(
                -margin,
                cap_style='square',
                join_style='mitre',
                mitre_limit=margin / 2,
            )
            missing = buffered.is_empty.sum()
            # handling tiles too small for buffer
            if missing != 0:
                import warnings
                warnings.warn(
                    f"Margin ({margin}) is too large, causing {missing} "
                    f"tile(s) to disappear. These tiles will be removed from the query."
                )
                # Filter out the empty tiles
                buffered = buffered[~buffered.is_empty]
            tiles = buffered

The samples now complete. Could consider throwing an error if too many tiles are missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions