How to use the geoviews.project function in geoviews

To help you get started, we’ve selected a few geoviews examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyviz-topics / EarthSim / earthsim / annotators.py View on Github external
def _link_polys(self):
        style = dict(editable=True)
        plot = dict(width=self.table_width, height=self.table_height)

        # Add annotation columns to poly data
        for col in self.poly_columns:
            if col not in self.polys:
                self.polys = self.polys.add_dimension(col, 0, '', True)
        self.poly_stream.source = self.polys
        self.vertex_stream.source = self.polys
        self._poly_selection.source = self.polys

        if len(self.polys):
            poly_data = gv.project(self.polys).split()
            self.poly_stream.event(data={kd.name: [p.dimension_values(kd) for p in poly_data]
                                         for kd in self.polys.kdims})

        poly_data = {c: self.polys.dimension_values(c, expanded=False) for c in self.poly_columns}
        if len(set(len(v) for v in poly_data.values())) != 1:
            raise ValueError('poly_columns must refer to value dimensions '
                             'which vary per path while at least one of '
                             '%s varies by vertex.' % self.poly_columns)
        self.poly_table = Table(poly_data, self.poly_columns, []).opts(plot=plot, style=style)
        self.poly_link = DataLink(source=self.polys, target=self.poly_table)
        self.vertex_table = Table([], self.polys.kdims, self.vertex_columns).opts(plot=plot, style=style)
        self.vertex_link = VertexTableLink(self.polys, self.vertex_table)
github pyviz-topics / EarthSim / earthsim / annotators.py View on Github external
def _link_points(self):
        style = dict(editable=True)
        plot = dict(width=self.table_width, height=self.table_height)
        for col in self.point_columns:
            if col not in self.points:
                self.points = self.points.add_dimension(col, 0, None, True)
        self.point_stream = PointDraw(source=self.points, data={})
        projected = gv.project(self.points, projection=ccrs.PlateCarree())
        self.point_table = Table(projected).opts(plot=plot, style=style)
        self.point_link = PointTableLink(source=self.points, target=self.point_table)
        self.point_selection_link = PointTableSelectionLink(source=self.points, target=self.point_table)
        self._point_selection = Selection1D(source=self.points)
github pyviz-topics / EarthSim / earthsim / grabcut.py View on Github external
def fg_path_view(self):
        if self._clear:
            self._fg_data = []
        elif self._initialized:
            self._fg_data = self.draw_fg.element.data
        else:
            self._fg_data = gv.project(self.path_type(self._fg_data, crs=self.crs), projection=self.image.crs)
        return self.path_type(self._fg_data, crs=self.image.crs)
github pyviz-topics / EarthSim / earthsim / grabcut.py View on Github external
def bg_path_view(self):
        if self._clear:
            self._bg_data = []
        elif self._initialized:
            self._bg_data = self.draw_bg.element.data
        else:
            self._bg_data = gv.project(self.path_type(self._bg_data, crs=self.crs), projection=self.image.crs)
        return self.path_type(self._bg_data, crs=self.image.crs)
github holoviz / hvplot / hvplot / converter.py View on Github external
if self.grid:
                obj = obj.grid(self.grid).opts(shared_xaxis=True, shared_yaxis=True)
        else:
            if self.streaming:
                cbcallable = StreamingCallable(partial(method, x, y),
                                               periodic=self.cb)
                obj = DynamicMap(cbcallable, streams=[self.stream])
            else:
                obj = method(x, y)

        if self.crs and self.project:
            # Apply projection before rasterizing
            import cartopy.crs as ccrs
            from geoviews import project
            projection = self._plot_opts.get('projection', ccrs.GOOGLE_MERCATOR)
            obj = project(obj, projection=projection)

        if not (self.datashade or self.rasterize):
            return self._apply_layers(obj)

        try:
            from holoviews.operation.datashader import datashade, rasterize, dynspread
            from datashader import reductions
        except:
            raise ImportError('Datashading is not available')

        opts = dict(dynamic=self.dynamic)
        if self._plot_opts.get('width') is not None:
            opts['width'] = self._plot_opts['width']
        if self._plot_opts.get('height') is not None:
            opts['height'] = self._plot_opts['height']
github holoviz / hvplot / hvplot / converter.py View on Github external
import cartopy.crs as ccrs
            t = self._plot_opts['projection']
            if isinstance(t, ccrs.CRS) and not isinstance(t, ccrs.Projection):
                raise ValueError('invalid transform:'
                                 ' Spherical contouring is not supported - '
                                 ' consider using PlateCarree/RotatedPole.')

        opts = dict(plot=self._plot_opts, style=self._style_opts, norm=self._norm_opts)
        qmesh = self.quadmesh(x, y, z, data)

        if self.geo:
            # Apply projection before contouring
            import cartopy.crs as ccrs
            from geoviews import project
            projection = self._plot_opts.get('projection', ccrs.GOOGLE_MERCATOR)
            qmesh = project(qmesh, projection=projection)

        if filled:
            opts['style']['line_alpha'] = 0

        if opts['plot']['colorbar']:
            opts['plot']['show_legend'] = False
        levels = self.kwds.get('levels', 5)
        if isinstance(levels, int):
            opts['plot']['color_levels'] = levels
        return contours(qmesh, filled=filled, levels=levels).opts(**opts)
github pyviz-topics / EarthSim / earthsim / grabcut.py View on Github external
def _simplify_contours(self, obj, **kwargs):
        if self.tolerance > 0:
            obj = simplify_paths(obj, tolerance=self.tolerance)
        self.result = gv.project(obj, projection=self.crs)
        return obj