{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 04_Geoviews_Datashader_NLDN" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview:\n", "1. Read in a multi-million row dataframe containing National Lightning Detection Network data from August 2021\n", "1. Use `Datashader` to create a rasterized representation of the dataframe\n", "1. Create an interactive, georeferenced visualization of NLDN data using the [Holoviz](https://holoviz.org) ecosystem" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Prerequisites\n", "\n", "| Concepts | Importance | Notes |\n", "| --- | --- | --- |\n", "| Pandas | Necessary | |\n", "| Geoviews 1-2 | Necessary| |\n", "\n", "* **Time to learn**: 30 minutes\n", "***" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import datashader as ds\n", "import pandas as pd\n", "from colorcet import fire\n", "from datashader import transfer_functions as tf\n", "import geoviews as gv\n", "from geoviews import opts\n", "import holoviews as hv\n", "from holoviews.element.tiles import OSM\n", "from holoviews.operation.datashader import datashade,rasterize" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "hv.extension('bokeh')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read in a multi-million row dataframe containing National Lightning Detection Network data from August 2021" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, we load in all of the detected cloud-to-ground flashes from August 2021. The data was originally derived from a Pandas-friendly text file, with over 50 million lines (one per flash, cloud-to-cloud as well as cloud-to-ground). While we could use Pandas `read_csv` to create a `Dataframe` from it, here we read in the dataset as expressed in [Feather](https://arrow.apache.org/docs/python/feather.html) format." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%time df = pd.read_feather('/spare11/atm533/data/202108_NLDN_CG.ftr')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
alpha
argument as a value from 0 to 255 here, as opposed to a floating point range of 0 to 1. This will make it so we can see the underlying map background.