<jupyter_start><jupyter_text>Geopandas and GeoDataFrame<jupyter_code>import pandas as pd
from geopandas import GeoDataFrame
from shapely.geometry import MultiPolygon, Polygon, LinearRing, Point, MultiPoint, LineString, MultiLineString, mapping

from lets_plot import *
LetsPlot.setup_html()<jupyter_output><empty_output><jupyter_text>Let's draw GeoDataFrame on plot<jupyter_code>POINT = Point(-5, 17)

MULTI_POINT = MultiPoint([Point(3, 15), Point(6, 13)])

LINE = LineString([(0, 0), (5, 5)])

MULTI_LINE = MultiLineString([
    LineString([(10, 0), (15, 5)]),
    LineString([(10, 5), (15, 0)])
])

POLYGON = Polygon(
    LinearRing([(1, 1), (1, 9), (9, 9), (9, 1)]),
    [LinearRing([(2, 2), (3, 2), (3, 3), (2, 3)]),
     LinearRing([(4, 4), (6, 4), (6, 6), (4, 6)])]
)

MULTIPOLYGON = MultiPolygon([
    Polygon(LinearRing([(11, 12), (13, 14), (15, 13), (7, 4)])),
    Polygon(LinearRing([(10, 2), (13, 10), (12, 3)]))
])
gdf = GeoDataFrame(
    data={
        'key': ['<KEY>'],
        'kind': ['Point', 'MPoint', 'Line', 'MLine', 'Polygon', 'MPolygon'],
        'coord': [POINT, MULTI_POINT, LINE, MULTI_LINE, POLYGON, MULTIPOLYGON]
    },
    geometry='coord'
)<jupyter_output><empty_output><jupyter_text>Geom kinds that support GeoDataFrame  geom_polygon()GeoDataFrame is supported natively in the 'data' parameter. Geometries of shapes Polygon and MultiPolygon are automatically taken from GeoDataFrame for geom_polygon().<jupyter_code>ggplot() + geom_polygon(aes(fill='kind'), data=gdf)<jupyter_output><empty_output><jupyter_text>GeoDataFrame can be used in the 'map' parameter (without 'data' specified). Geometries of shapes Polygon and MultiPolygon are automatically taken from GeoDataFrame for geom_polygon().<jupyter_code>ggplot() + geom_polygon(map=gdf)<jupyter_output><empty_output><jupyter_text>The data specified in the 'data' and geometries from the 'map' can be joined by a key value from 'map_id' aesthetic.<jupyter_code>df = pd.DataFrame({
    'name': ['A', 'B', 'C'],
    'value': [42, 23, 87],
})
ggplot() + geom_polygon(aes(fill='value'), data=df, map=gdf, map_join=['name', 'key'])<jupyter_output><empty_output><jupyter_text>geom_point() and geom_text()GeoDataFrame is supported natively in the 'data' parameter for geom_point() and geom_text(). Geometries of shapes Point and MultiPoint are automatically taken from GeoDataFrame.<jupyter_code>ggplot() + geom_point(aes(color='kind'), data=gdf, size=10) + \
    geom_text(aes(label='kind'), data=gdf, angle=25)
ggplot() + geom_text(aes(label='key', color='kind'), data=gdf)<jupyter_output><empty_output><jupyter_text>GeoDataFrame can be used in the 'map' parameter (without 'data' specified). Geometries of shapes Point and MultiPoint are automatically taken from GeoDataFrame for geom_point().<jupyter_code>ggplot() + geom_point(map=gdf, size=10)<jupyter_output><empty_output><jupyter_text>The data specified in the 'data' and geometries from the 'map' can be joined by a pair of keys from 'map_join' param.<jupyter_code>ggplot() + geom_point(aes(color='value'), data=df, map=gdf, size=10, map_join=['name','key'])<jupyter_output><empty_output><jupyter_text>geom_rect()GeoDataFrame is supported natively in the 'data' parameter of geom_rect(). Geometries of shapes MultiPoint, Line, MultiLine, Polygon and MultiPolygon are automatically taken from GeoDataFrame, their bounding boxes will be drawn.<jupyter_code>ggplot() + geom_rect(aes(fill='kind'), data=gdf)<jupyter_output><empty_output><jupyter_text>GeoDataFrame can be used in the 'map' parameter. Geometries of shapes MultiPoint, Line, MultiLine, Polygon and MultiPolygon are automatically taken from GeoDataFrame for geom_rect(), their bounding boxes will be drawn.<jupyter_code>ggplot() + geom_rect(map=gdf)<jupyter_output><empty_output><jupyter_text>The data specified in the 'data' and geometries from the 'map' can be joined by a pair of keys from 'map_join' param.<jupyter_code>ggplot() + geom_rect(aes(fill='value'), data=df, map=gdf, map_join=['name', 'key'])<jupyter_output><empty_output><jupyter_text>geom_path()GeoDataFrame is supported natively in the 'data' parameter for geom_path(). Geometries of shapes Line and MultiLine are automatically taken from GeoDataFrame.<jupyter_code>ggplot() + geom_path(aes(color='kind'), data=gdf)<jupyter_output><empty_output><jupyter_text>Can be used in the 'map' parameter for geom_path() without specifying 'data'.<jupyter_code>ggplot() + geom_path(map=gdf)<jupyter_output><empty_output><jupyter_text>The data specified in the 'data' and geometries from the 'map' can be joined by a pair of keys from 'map_join' param.<jupyter_code>ggplot() + geom_path(aes(color='value'), data=df, map=gdf, map_join=['name', 'key'])<jupyter_output><empty_output><jupyter_text>geom_map()GeoDataFrame is supported natively in the 'data' parameter of geom_map(). Geometries of shapes Polygon and MultiPolygon are automatically taken from GeoDataFrame.<jupyter_code>ggplot() + geom_map(aes(color='kind'), data=gdf, size=1)<jupyter_output><empty_output><jupyter_text>Can be used in the 'map' parameter for geom_map().<jupyter_code>ggplot() + geom_map(map=gdf)<jupyter_output><empty_output><jupyter_text>The data specified in the 'data' and geometries from the 'map' can be joined by a pair of keys from 'map_join' param.<jupyter_code>ggplot() + geom_map(aes(fill='value'), data=df, map=gdf, map_join=['name', 'key'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1412460713625439, 'fraction_numerical': 0.016269180994638564, 'mean_word_length': 7.533123028391167, 'pattern_counts': {'":': 0, '<': 70, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '17', 'dir': 'jupyter-structured-clean-dedup', 'id': '552547', 'license': 'MIT', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1873, 'n_words': 490, 'path': 'source/examples/cookbook/geopandas_GeoDataFrame.ipynb', 'repo_name': 'JetBrains/lets-plot-docs', 'size': '5430'}