forked from geopandas/geopandas
/
plotting.py
57 lines (44 loc) · 2.07 KB
/
plotting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import random
from geopandas import GeoDataFrame, GeoSeries
from shapely.geometry import Point, LineString, Polygon, MultiPolygon
import numpy as np
class Bench:
param_names = ['geom_type']
params = [('Point', 'LineString', 'Polygon', 'MultiPolygon', 'mixed')]
def setup(self, geom_type):
if geom_type == 'Point':
geoms = GeoSeries([Point(i, i) for i in range(1000)])
elif geom_type == 'LineString':
geoms = GeoSeries([LineString([(random.random(), random.random())
for _ in range(5)])
for _ in range(100)])
elif geom_type == 'Polygon':
geoms = GeoSeries([Polygon([(random.random(), random.random())
for _ in range(3)])
for _ in range(100)])
elif geom_type == 'MultiPolygon':
geoms = GeoSeries(
[MultiPolygon([Polygon([(random.random(), random.random())
for _ in range(3)])
for _ in range(3)])
for _ in range(20)])
elif geom_type == 'mixed':
g1 = GeoSeries([Point(i, i) for i in range(100)])
g2 = GeoSeries([LineString([(random.random(), random.random())
for _ in range(5)])
for _ in range(100)])
g3 = GeoSeries([Polygon([(random.random(), random.random())
for _ in range(3)])
for _ in range(100)])
geoms = g1
geoms.iloc[np.random.randint(0, 100, 50)] = g2
geoms.iloc[np.random.randint(0, 100, 33)] = g3
print(geoms.geom_type.value_counts())
df = GeoDataFrame({'geometry': geoms,
'values': np.random.randn(len(geoms))})
self.geoms = geoms
self.df = df
def time_plot_series(self, *args):
self.geoms.plot()
def time_plot_values(self, *args):
self.df.plot(column='values')