How to use the contextily.tile._calculate_zoom function in contextily

To help you get started, we’ve selected a few contextily examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ResidentMario / geoplot / geoplot / geoplot.py View on Github external
# input, in which case the default plot extent for the given projection is used. But
            # the default extent is not well-exposed inside of the Cartopy API, so in edge cases
            # where we are forced to fall back to default extent we don't actually know the true
            # plot extent.
            #
            # For this reason we (1) recalculate "good case" plot extent here, instead of saving
            # the value to an init variable and (2) accept that this calculation is potentially
            # incorrect in edge cases.
            extent = relax_bounds(*self.df.total_bounds) if self.extent is None else self.extent

            if zoom is None:
                zoom = ctx.tile._calculate_zoom(*extent)
            else:
                howmany = ctx.tile.howmany(*extent, zoom, ll=True, verbose=False)
                if howmany > 100:
                    better_zoom_level = ctx.tile._calculate_zoom(*extent)
                    warnings.warn(
                        f'Generating a webmap at zoom level {zoom} for the given plot extent '
                        f'requires downloading {howmany} individual tiles. This slows down '
                        f'plot generation and places additional pressure on the tile '
                        f'provider\'s server, which many deny your request when placed under '
                        f'high load or high request volume. Consider setting "zoom" to '
                        f'{better_zoom_level} instead. This is the recommended zoom level for '
                        f'the given plot extent.'
                    )
            self.zoom = zoom
            self._webmap_extent = extent

contextily

Context geo-tiles in Python

BSD-3-Clause
Latest version published 16 days ago

Package Health Score

88 / 100
Full package analysis

Similar packages