Skip to content

Commit

Permalink
Renamed ProjectImage and added project_shape
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 2, 2016
1 parent 54358ca commit c6c5ce2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
27 changes: 23 additions & 4 deletions geoviews/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,30 @@

from holoviews.operation import ElementOperation

from .element import Image

from .element import Image, Shape, Shape, Polygons, Path
from .util import project_extents

class project_shape(ElementOperation):
"""
Projects Shape, Polygons and Path Elements from their source
coordinate reference system to the supplied projection.
"""

projection = param.ClassSelector(default=ccrs.GOOGLE_MERCATOR,
class_=ccrs.Projection,
instantiate=False, doc="""
Projection the shape type is projected to.""")

def _process_element(self, element):
geom = self.p.projection.project_geometry(element.geom(),
element.crs)
return element.clone(geom, crs=self.p.projection)

def _process(self, element, key=None):
return element.map(self._process_element, [Shape, Polygons, Path])


class ProjectImage(ElementOperation):
class project_image(ElementOperation):
"""
Projects an geoviews Image to the specified projection,
returning a regular HoloViews Image type. Works by
Expand All @@ -19,7 +37,8 @@ class ProjectImage(ElementOperation):
"""

projection = param.ClassSelector(default=ccrs.GOOGLE_MERCATOR,
class_=ccrs.Projection, doc="""
class_=ccrs.Projection,
instantiate=False, doc="""
Projection the image type is projected to.""")

def _process(self, img, key=None):
Expand Down
4 changes: 2 additions & 2 deletions geoviews/plotting/bokeh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from ...element import (WMTS, Points, Polygons, Path, Shape, Image,
Feature, is_geographic, Text)
from ...operation import ProjectImage
from ...operation import project_image
from ...util import project_extents, geom_to_array

DEFAULT_PROJ = GOOGLE_MERCATOR
Expand Down Expand Up @@ -98,7 +98,7 @@ class GeoRasterPlot(GeoPlot, RasterPlot):
def get_data(self, element, ranges=None, empty=False):
l, b, r, t = self.get_extents(element, ranges)
if self.geographic:
element = ProjectImage(element, projection=DEFAULT_PROJ)
element = project_image(element, projection=DEFAULT_PROJ)
img = element.dimension_values(2, flat=False)
mapping = dict(image='image', x='x', y='y', dw='dw', dh='dh')
if empty:
Expand Down

0 comments on commit c6c5ce2

Please sign in to comment.