forked from geopandas/geopandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsjoin.py
35 lines (27 loc) · 962 Bytes
/
sjoin.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
import random
from geopandas import GeoDataFrame, GeoSeries, sjoin
from shapely.geometry import Point, LineString, Polygon
import numpy as np
class Bench:
param_names = ["op"]
params = [("intersects", "contains", "within")]
def setup(self, *args):
triangles = GeoSeries(
[
Polygon([(random.random(), random.random()) for _ in range(3)])
for _ in range(1000)
]
)
points = GeoSeries(
[
Point(x, y)
for x, y in zip(np.random.random(10000), np.random.random(10000))
]
)
df1 = GeoDataFrame(
{"val1": np.random.randn(len(triangles)), "geometry": triangles}
)
df2 = GeoDataFrame({"val1": np.random.randn(len(points)), "geometry": points})
self.df1, self.df2 = df1, df2
def time_sjoin(self, predicate):
sjoin(self.df1, self.df2, predicate=predicate)