Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Projection the shape type is projected to.""")
# Defines the types of elements supported by the operation
supported_types = []
def _process(self, element, key=None):
return element.map(self._process_element, self.supported_types)
class project_path(_project_operation):
"""
Projects Polygons and Path Elements from their source coordinate
reference system to the supplied projection.
"""
supported_types = [Polygons, Path, Contours, EdgePaths]
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.')
Projection the shape type is projected to.""")
# Defines the types of elements supported by the operation
supported_types = []
def _process(self, element, key=None):
return element.map(self._process_element, self.supported_types)
class project_path(_project_operation):
"""
Projects Polygons and Path Elements from their source coordinate
reference system to the supplied projection.
"""
supported_types = [Polygons, Path, Contours, EdgePaths]
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.)
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)
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,
QuadMesh: GeoQuadMeshPlot}, 'bokeh')
# 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')