How to use the geoplot.utils.gaussian_points function in geoplot

To help you get started, we’ve selected a few geoplot 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 / tests / viz_tests.py View on Github external
import numpy as np
import geopandas as gpd
from shapely.geometry import Polygon
from matplotlib.colors import Normalize
import matplotlib.pyplot as plt

from geoplot import utils
from geoplot import (
    pointplot, voronoi, kdeplot, polyplot, webmap, choropleth, cartogram, quadtree,
    sankey
)
from geoplot.crs import AlbersEqualArea, WebMercator


np.random.seed(42)
p_srs = gpd.GeoSeries(utils.gaussian_points(n=100))
p_df = gpd.GeoDataFrame(geometry=p_srs)
p_df = p_df.assign(var=p_df.geometry.map(lambda p: abs(p.y) + abs(p.x)))
p_df = p_df.assign(var_cat=np.floor(p_df['var'] // (p_df['var'].max() / 5)).astype(str))

poly_df = gpd.GeoDataFrame(geometry=utils.gaussian_polygons(p_srs.geometry, n=10))
poly_df = poly_df.assign(
    var=poly_df.geometry.centroid.x.abs() + poly_df.geometry.centroid.y.abs()
)

ls_df = gpd.GeoDataFrame(geometry=utils.gaussian_linestrings(p_srs.geometry))
ls_df = ls_df.assign(var=ls_df.geometry.centroid.x.abs() + ls_df.geometry.centroid.y.abs())

clip_geom = gpd.GeoSeries(Polygon([[-10, -10], [10, -10], [10, 10], [-10, 10]]))
non_clip_geom = gpd.GeoSeries(Polygon([[-30, -30], [30, -30], [30, 30], [-30, 30]]))

def identity_scale(minval, maxval):
github ResidentMario / geoplot / tests / mixin_tests.py View on Github external
def create_huemixin():
            huemixin = HueMixin()
            # set props the mixin is responsible for
            huemixin.kwargs = {'hue': 'foo', 'cmap': 'viridis', 'norm': None}
            # set props set by the plot object initializer
            huemixin.ax = None
            huemixin.figsize = (8, 6)
            huemixin.extent = None
            huemixin.projection = None

            np.random.seed(42)
            huemixin.df = gpd.GeoDataFrame(
                {'foo': np.random.random(100), 'geometry': utils.gaussian_points(n=100)}
            )
            return huemixin
github ResidentMario / geoplot / tests / property_tests.py View on Github external
    @given(projections,
           hue_vars(),
           scale_vars(),
           legend_vars(),
           data_kwargs)
    def test_sankey(self, projection, hue_vars, scale_vars, legend_vars, data_kwargs):
        kwargs = {'projection': projection}
        kwargs = {**kwargs, **hue_vars, **scale_vars, **legend_vars, **data_kwargs}

        try: gplt.sankey(network, **kwargs)
        finally: plt.close()


# Additional strategies
# Static inputs.
agg_gaussian_points = gplt.utils.gaussian_points(n=100)
agg_gaussian_polys = gplt.utils.gaussian_polygons(gplt.utils.gaussian_points(n=100), n=2)
agg_gaussian_multipolys = gplt.utils.gaussian_multi_polygons(gplt.utils.gaussian_points(n=100), n=2)
agg_data = gpd.GeoDataFrame(geometry=agg_gaussian_points)

# Data input.
# For quadtree mode.
mode = st.integers(min_value=0, max_value=2)
nmin = st.integers(min_value=10, max_value=21).map(lambda v: v if v < 21 else None)
nmax = st.integers(min_value=20, max_value=51).map(lambda v: v if v < 51 else None)
nsig = st.integers(min_value=0, max_value=10)

# For by mode.
cats = st.lists(st.integers(min_value=0, max_value=1), min_size=100, max_size=100)

# For geometry mode.
indexed_geometry = gpd.GeoSeries({0: agg_gaussian_polys[0], 1: agg_gaussian_multipolys[1]})
github ResidentMario / geoplot / tests / mixin_tests.py View on Github external
def create_clipmixin():
            clipmixin = ClipMixin()
            clipmixin.kwargs = {
                'clip': gpd.GeoSeries(Polygon([[0, 0], [0, 100], [100, 100], [100, 0]]))
            }
            clipmixin.ax = None
            clipmixin.figsize = (8, 6)
            clipmixin.extent = None
            clipmixin.projection = None

            np.random.seed(42)
            points = utils.gaussian_points(n=2000)
            geoms = np.hstack([
                utils.gaussian_polygons(points, n=50), utils.gaussian_multi_polygons(points, n=50)
            ])
            clipmixin.df = gpd.GeoDataFrame({'foo': np.random.random(100), 'geometry': geoms})
            return clipmixin