Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if isinstance(element, HexTiles):
element = project_points._process(self, element)
return hex_binning._process(self, element)
compositor = Compositor(
"HexTiles", geo_hex_binning, None, 'data', output_type=HexTiles,
transfer_options=True, transfer_parameters=True, backends=['bokeh']
)
Compositor.register(compositor)
Store.register({WMTS: TilePlot,
Points: GeoPointPlot,
Labels: GeoLabelsPlot,
VectorField: GeoVectorFieldPlot,
Polygons: GeoPolygonPlot,
Contours: GeoContourPlot,
Path: GeoPathPlot,
Shape: GeoShapePlot,
Image: GeoRasterPlot,
RGB: GeoRGBPlot,
LineContours: LineContourPlot,
FilledContours: FilledContourPlot,
Feature: FeaturePlot,
HexTiles: HexTilesPlot,
Text: GeoTextPlot,
Overlay: GeoOverlayPlot,
NdOverlay: GeoOverlayPlot,
Graph: GeoGraphPlot,
TriMesh: GeoTriMeshPlot,
Nodes: GeoPointPlot,
EdgePaths: GeoPathPlot,
def _process_element(self, element):
if not len(element):
return element.clone(crs=self.p.projection)
crs = element.crs
cylindrical = isinstance(crs, ccrs._CylindricalProjection)
proj = self.p.projection
if isinstance(proj, ccrs.CRS) and not isinstance(proj, ccrs.Projection):
raise ValueError('invalid transform:'
' Spherical contouring is not supported - '
' consider using PlateCarree/RotatedPole.')
boundary = Polygon(crs.boundary)
bounds = [round(b, 10) for b in boundary.bounds]
xoffset = round((boundary.bounds[2]-boundary.bounds[0])/2.)
if isinstance(element, Polygons):
geoms = polygons_to_geom_dicts(element, skip_invalid=False)
else:
geoms = path_to_geom_dicts(element, skip_invalid=False)
data_bounds = max_extents([g['geometry'].bounds for g in geoms])
total_bounds = tuple(round(b, 10) for b in data_bounds)
projected = []
for path in geoms:
geom = path['geometry']
if (cylindrical and total_bounds[0] >= (bounds[0]+xoffset) and
total_bounds[2] > (bounds[2]+xoffset//2)):
# Offset if lon and not centered on 0 longitude
# i.e. lon_min > 0 and lon_max > 270
geom = shapely.affinity.translate(geom, xoff=-xoffset)
geom_bounds = [round(b, 10) for b in geom.bounds]
def _process_element(self, element):
if not bool(element):
return element.clone(crs=self.p.projection)
crs = element.crs
proj = self.p.projection
if (isinstance(crs, ccrs.PlateCarree) and not isinstance(proj, ccrs.PlateCarree)
and crs.proj4_params['lon_0'] != 0):
element = self.instance(projection=ccrs.PlateCarree())(element)
if isinstance(proj, ccrs.CRS) and not isinstance(proj, ccrs.Projection):
raise ValueError('invalid transform:'
' Spherical contouring is not supported - '
' consider using PlateCarree/RotatedPole.')
if isinstance(element, Polygons):
geoms = polygons_to_geom_dicts(element, skip_invalid=False)
else:
geoms = path_to_geom_dicts(element, skip_invalid=False)
projected = []
for path in geoms:
geom = path['geometry']
# Ensure minimum area for polygons (precision issues cause errors)
if isinstance(geom, Polygon) and geom.area < 1e-15:
continue
elif isinstance(geom, MultiPolygon):
polys = [g for g in geom if g.area > 1e-15]
if not polys:
continue
geom = MultiPolygon(polys)
# Register plots with HoloViews
Store.register({LineContours: LineContourPlot,
FilledContours: FilledContourPlot,
Image: GeoImagePlot,
Feature: FeaturePlot,
WMTS: WMTSPlot,
Tiles: WMTSPlot,
Points: GeoPointPlot,
Labels: GeoLabelsPlot,
VectorField: GeoVectorFieldPlot,
Text: GeoTextPlot,
Layout: LayoutPlot,
NdLayout: LayoutPlot,
Overlay: GeoOverlayPlot,
Polygons: GeoPolygonPlot,
Path: GeoPathPlot,
Contours: GeoContourPlot,
RGB: GeoRGBPlot,
Shape: GeoShapePlot,
Graph: GeoGraphPlot,
TriMesh: GeoTriMeshPlot,
Nodes: GeoPointPlot,
EdgePaths: GeoPathPlot,
HexTiles: GeoHexTilesPlot,
QuadMesh: GeoQuadMeshPlot}, 'matplotlib')
# Define plot and style options
options = Store.options(backend='matplotlib')
options.Shape = Options('style', edgecolor='black', facecolor='#30A2DA')
def _process_element(self, element):
if not len(element):
return element.clone(crs=self.p.projection)
geom = element.geom()
vertices = geom_to_array(geom)
if isinstance(geom, (MultiPolygon, Polygon)):
obj = Polygons([vertices])
else:
obj = Path([vertices])
geom = project_path(obj, projection=self.p.projection).geom()
return element.clone(geom, crs=self.p.projection)
def _process_element(self, element):
if not len(element):
return element.clone(crs=self.p.projection)
geom = element.geom()
vertices = geom_to_array(geom)
if isinstance(geom, (MultiPolygon, Polygon)):
obj = Polygons([vertices])
else:
obj = Path([vertices])
geom = project_path(obj, projection=self.p.projection).geom()
return element.clone(geom, crs=self.p.projection)
pass
try:
from . import bokeh # noqa
except ImportError:
pass
Compositor.register(Compositor("LineContours", contours, None,
'data', transfer_options=True,
transfer_parameters=True,
output_type=Contours,
backends=['bokeh', 'matplotlib']))
Compositor.register(Compositor("FilledContours", contours.instance(filled=True),
None, 'data', transfer_options=True,
transfer_parameters=True,
output_type=Polygons,
backends=['bokeh', 'matplotlib']))