How to use the geoplot.utils.gaussian_multi_polygons 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 / property_tests.py View on Github external
import unittest
from hypothesis import given
import hypothesis.strategies as st
import geopandas as gpd
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import shapely
import numpy as np


# Define strategies.

# Static inputs.
gaussian_points = gplt.utils.gaussian_points(n=10)
gaussian_polys = gplt.utils.gaussian_polygons(gplt.utils.gaussian_points(n=100), n=2).append(
                 gplt.utils.gaussian_multi_polygons(gplt.utils.gaussian_points(n=100), n=2)
)

# Projections.
projections = st.sampled_from((None, gcrs.PlateCarree()))

# Hue data.
schemes = st.sampled_from((None, "equal_interval", "quantiles", "fisher_jenks"))
k = st.integers(min_value=4, max_value=9).map(lambda f: None if f == 4 else f)
datasets_numeric = st.lists(st.floats(allow_nan=False, allow_infinity=False, min_value=10**-10, max_value=10**10),
                            min_size=10, max_size=10, unique=True)
datasets_categorical = st.lists(st.text(st.characters(max_codepoint=1000, blacklist_categories=('Cc', 'Cs')),
                                                      max_size=20), min_size=10, max_size=10)
categorical = st.booleans()
use_hue = st.booleans()
github ResidentMario / geoplot / tests / input_tests.py View on Github external
import pandas as pd


# Point-type DataFrame input.
list_gaussian_points = gplt.utils.gaussian_points(n=4)
series_gaussian_points = gpd.GeoSeries(list_gaussian_points)
dataframe_gaussian_points = gpd.GeoDataFrame(
    geometry=series_gaussian_points
).assign(hue_var=[1,2,3,4])


# Polygon-type DataFrame input.
list_gaussian_polys = gplt.utils.gaussian_polygons(
    gplt.utils.gaussian_points(n=1000), n=2
).append(
    gplt.utils.gaussian_multi_polygons(gplt.utils.gaussian_points(n=1000), n=2)
)
series_gaussian_polys = gpd.GeoSeries(list_gaussian_polys)
dataframe_gaussian_polys = gpd.GeoDataFrame(
    geometry=series_gaussian_polys
).assign(hue_var=[1,2,3,4])

# Hue input.
list_hue_values = [1, 2, 3, 4]
series_hue_values = pd.Series(list_hue_values)
def map_hue_values(): return map(lambda i: list_hue_values[i], list(range(len(list_hue_values))))


# (Sankey) point input.
# Start and End variables.
list_start_points = [Point(a + 2, a - 2) for a in range(0, 4)]
list_end_points = [Point(a - 2, a + 2) for a in range(1, 5)]
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
github ResidentMario / geoplot / tests / kwarg_tests.py View on Github external
import matplotlib.pyplot as plt
from shapely.geometry import Point, LineString
import numpy as np
import geoplot.crs as gcrs


# Point-type DataFrame input.
list_gaussian_points = gplt.utils.gaussian_points(n=4)
dataframe_gaussian_points = gpd.GeoDataFrame(
    geometry=list_gaussian_points
).assign(hue_var=[1,2,3,4])


# Polygon-type DataFrame input.
list_gaussian_polys = gplt.utils.gaussian_polygons(gplt.utils.gaussian_points(n=1000), n=2).append(
    gplt.utils.gaussian_multi_polygons(gplt.utils.gaussian_points(n=1000), n=2)
)
dataframe_gaussian_polys = gpd.GeoDataFrame(geometry=list_gaussian_polys).assign(hue_var=[1,2,3,4])

# (Sankey) point input.
# Start and end variables.
list_start_points = [Point(a + 2, a - 2) for a in range(0, 4)]
list_end_points = [Point(a - 2, a + 2) for a in range(1, 5)]

# (Sankey) paths.
list_paths = [
    LineString([[a.x, a.y], [b.x, b.y]]) for a, b in zip(list_start_points, list_end_points)
]

# (Aggplot) geometry.
dataframe_gaussian_points = dataframe_gaussian_points.assign(mock_category=np.random.randint(1, 5))
aggplot_geometries = dataframe_gaussian_polys.set_index('hue_var', drop=True)
github ResidentMario / geoplot / tests / property_tests.py View on Github external
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]})

# For hue.