Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions benchmarks/rasterizer_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@

import numpy as np
import geopandas as gpd
import spatialpandas
from rasterio.features import rasterize as rio_rasterize
from rasterio.transform import from_bounds
from shapely.geometry import (
Point, Polygon, MultiPolygon, LineString, MultiLineString, MultiPoint,
box,
)

import datashader as ds
from geocube.api.core import make_geocube
from xrspatial.rasterize import rasterize as xrs_rasterize

# datashader is a deliberate A/B comparison here but is no longer a default
# dependency. Guard the import (and spatialpandas, which only feeds the
# datashader path) so the benchmark still runs when it is absent; the
# datashader column is skipped in that case.
try:
import datashader as ds
import spatialpandas
HAS_DATASHADER = True
except ImportError:
HAS_DATASHADER = False


# ---------------------------------------------------------------------------
# Geometry generators
Expand Down Expand Up @@ -598,7 +607,7 @@ def main():
for gen_name, gen_cfg in GENERATORS.items():
gen_fn = gen_cfg["fn"]
kind = gen_cfg["kind"]
use_datashader = kind == "polygon"
use_datashader = kind == "polygon" and HAS_DATASHADER

for n in feature_counts:
geoms, vals = gen_fn(n, rng)
Expand Down
Loading