How to use the geoviews.Polygons 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 / grabcut.py View on Github external
def __init__(self, poly_data=[], **params):
        super(SelectRegionPanel, self).__init__(**params)
        self.boxes = gv.Polygons(poly_data).options(
            fill_alpha=0.5, color='grey', line_color='white',
            line_width=2, width=self.width, height=self.height
        )
        if not self.boxes:
            self.boxes = self.boxes.options(global_extent=True)
        self.box_stream = BoxEdit(source=self.boxes, num_objects=1)
github pyviz-topics / EarthSim / earthsim / io.py View on Github external
def save_shapefile(cdsdata, path, template):
    """
    Accepts bokeh ColumnDataSource data and saves it as a shapefile,
    using an existing template to determine the required schema.
    """
    collection = fiona.open(template)
    arrays = [np.column_stack([xs, ys]) for xs, ys in zip(cdsdata['xs'], cdsdata['ys'])]
    polys = gv.Polygons(arrays, crs=ccrs.GOOGLE_MERCATOR)
    projected = gv.operation.project_path(polys, projection=ccrs.PlateCarree())
    data = [list(map(tuple, arr)) for arr in projected.split(datatype='array')]
    shape_data = list(collection.items())[0][1]
    shape_data['geometry']['coordinates'] = data
    with fiona.open(path, 'w', collection.driver, collection.schema, collection.crs) as c:
        c.write(shape_data)
github sentinel-hub / eo-learn / visualization / eolearn / visualization / eopatch_visualization.py View on Github external
def plot_shapes_one(self, data_gpd, timestamp, crs):
        """ Plots shapes for one timestamp from geopandas GeoDataFrame

        :param data_gpd: data to plot
        :type data_gpd: geopandas.GeoDataFrame
        :param timestamp: timestamp to plot data for
        :type timestamp: datetime
        :param crs: in which crs is the data to plot
        :type crs: sentinelhub.crs
        :return: visualization
        :rtype: geoviews
        """
        out = data_gpd.loc[data_gpd[self.timestamp_column] == timestamp]
        return gv.Polygons(out, crs=ccrs.epsg(int(crs.value)))
github pyviz-topics / EarthSim / earthsim / annotators.py View on Github external
geom = p['geometry']
        holes = []
        if 'holes' in p:
            holes = [LinearRing(h) for h in p['holes']]

        if 'Multi' in geom.type:
            polys = []
            for g in geom:
                subholes = [h for h in holes if g.intersects(h)]
                polys.append(Polygon(g, subholes))
            poly = MultiPolygon(polys)
        else:
            poly = Polygon(geom, holes)
        p['geometry'] = poly
        polys_with_holes.append(p)
    return path.clone(polys_with_holes, new_type=gv.Polygons)
github sentinel-hub / eo-learn / visualization / eolearn / visualization / eopatch_visualization.py View on Github external
def plot_vector_timeless(self, feature_name):
        """ Plot FeatureType.VECTOR_TIMELESS data

        :param feature_name: name of the eopatch featrue
        :type feature_name: str
        :return: visalization
        :rtype: geoviews
        """
        crs = self.eopatch.bbox.crs
        if crs is CRS.WGS84:
            crs = CRS.POP_WEB
            data_gpd = self.eopatch[FeatureType.VECTOR_TIMELESS][feature_name].to_crs(
                {'init': 'epsg:{}'.format(crs.value)})
        else:
            data_gpd = self.eopatch[FeatureType.VECTOR_TIMELESS][feature_name]
        return gv.Polygons(data_gpd, crs=ccrs.epsg(int(crs.value)), vdims=self.vdims)