{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "GeoViews is a [Python](http://python.org) library that makes it easy to explore and visualize geographical, meteorological, and oceanographic datasets, such as those used in weather, climate, and remote sensing research. \n", "\n", "GeoViews is built on the [HoloViews](http://holoviews.org) library for building flexible visualizations of multidimensional data. GeoViews adds a family of geographic plot types based on the [Cartopy](http://scitools.org.uk/cartopy) library, plotted using either the [Matplotlib](http://matplotlib.org) or [Bokeh](http://bokeh.pydata.org) packages. \n", "With GeoViews, you can now work easily and naturally with large, multidimensional geographic datasets, instantly visualizing any subset or combination of them, while always being able to access the raw data underlying any plot. Here's a simple example:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geoviews as gv\n", "import geoviews.feature as gf\n", "import xarray as xr\n", "from cartopy import crs\n", "\n", "gv.extension('bokeh', 'matplotlib')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "(gf.ocean + gf.land + gf.ocean * gf.land * gf.coastline * gf.borders).opts(\n", " 'Feature', projection=crs.Geostationary(), global_extent=True, height=325)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "GeoViews is designed to work well with the [Iris](http://scitools.org.uk/iris) and [xarray](http://xarray.pydata.org) libraries for working with multidimensional arrays, such as those stored in netCDF files. GeoViews also accepts data as NumPy arrays and Pandas data frames. In each case, the data can be left stored in its original, native format, wrapped in a HoloViews or GeoViews object that provides instant interactive visualizations.\n", "\n", "The following example loads a dataset originally taken from [iris-sample-data](https://github.com/SciTools/iris-sample-data) and quickly builds an interactive tool for exploring how the data changes over time:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dataset = gv.Dataset(xr.open_dataset('./data/ensemble.nc'))\n", "ensemble = dataset.to(gv.Image, ['longitude', 'latitude'], 'surface_temperature')\n", "\n", "gv.output(ensemble.opts(cmap='viridis', colorbar=True, fig_size=120, backend='matplotlib') * gf.coastline(),\n", " backend='matplotlib')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "GeoViews also natively supports geopandas datastructures allowing us to easily plot shapefiles and choropleths:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd\n", "import geodatasets as gds\n", "\n", "nybb = gpd.read_file(gds.get_path('nybb'))\n", "poly_data = nybb.to_crs(crs.GOOGLE_MERCATOR.proj4_init)\n", "gv.tile_sources.OSM * gv.Polygons(poly_data, vdims='BoroName', crs=crs.GOOGLE_MERCATOR).opts(height=500, width=500, tools=[\"hover\"])" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }