import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from lets_plot import *
LetsPlot.setup_html()
from geopandas import GeoDataFrame
from shapely.geometry import MultiPolygon, Polygon, LinearRing, Point, mapping
POINT = Point(-5, 17)
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)]))
])
gdf = GeoDataFrame(
data={'id': ['A', 'B', 'C'],
'coord': [POINT, POLYGON, MULTIPOLYGON]},
geometry='coord')
ggplot() + geom_polygon(aes(fill = 'id'), gdf)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) C:\Temp/ipykernel_9592/3737669046.py in <module> ----> 1 ggplot() + geom_polygon(aes(fill = 'id'), gdf) TypeError: geom_polygon() takes from 0 to 1 positional arguments but 2 were given
Mapping doesn't work for DataFrame in map
ggplot() + geom_polygon(aes(fill = 'id'), map = gdf)
ggplot() + geom_polygon(map = gdf)
df = pd.DataFrame(
{'name': ['A', 'B', 'C'],
'value': [42, 23, 87]})
ggplot() + geom_polygon(aes(fill = 'value'), df, map = gdf, map_join=('name', 'id'))
ggplot() + geom_polygon(data = gdf)
ggplot() + geom_point(aes(color='id'), gdf, size=5)
ggplot() + geom_rect(aes(fill='id'), gdf)
ggplot() + geom_path(data = gdf)
ggplot() + geom_map(map = gdf)
ggplot() + geom_map(data = gdf)
Error message contains autogenerated column "__key__". It's ok.
ggplot() + geom_polygon(aes(fill = 'id'), gdf)