File: clip.py

package info (click to toggle)
python-geopandas 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,752 kB
  • sloc: python: 26,021; makefile: 147; sh: 25
file content (24 lines) | stat: -rw-r--r-- 733 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from geopandas import read_file, clip
from shapely.geometry import box

try:
    from geopandas.tests.util import _NATURALEARTH_LOWRES
    from geopandas.tests.util import _NATURALEARTH_CITIES
except:
    # geopandas <=0.14 compat
    from geopandas.datasets import get_path

    _NATURALEARTH_LOWRES = get_path("naturalearth_lowres")
    _NATURALEARTH_CITIES = get_path("naturalearth_cities")


class Bench:
    def setup(self, *args):
        world = read_file(_NATURALEARTH_LOWRES)
        capitals = read_file(_NATURALEARTH_CITIES)
        self.bounds = [box(*geom.bounds) for geom in world.geometry]
        self.points = capitals

    def time_clip(self):
        for bound in self.bounds:
            clip(self.points, bound)