{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Choropleth classification schemes from PySAL for use with GeoPandas\n", "\n", "\n", "PySAL is a [Spatial Analysis Library](), which packages fast spatial algorithms used in various fields. These include Exploratory spatial data analysis, spatial inequality analysis, spatial analysis on networks, spatial dynamics, and many more.\n", "\n", "It is used under the hood in geopandas when plotting measures with a set of colors. There are many ways to classify data into different bins, depending on a number of classification schemes.\n", "\n", "\n", "\n", "For example, if we have 20 countries whose average annual temperature varies between 5C and 25C, we can classify them in 4 bins by:\n", "\n", "* Quantiles\n", " - Separates the rows into equal parts, 5 countries per bin.\n", "* Equal Intervals\n", " - Separates the measure's interval into equal parts, 5C per bin.\n", "* Natural Breaks (Fischer Jenks)\n", " - This algorithm tries to split the rows into naturally occurring clusters. The numbers per bin will depend on how the observations are located on the interval." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2017-12-15T21:29:37.736444Z", "start_time": "2017-12-15T21:29:37.716444Z" } }, "outputs": [], "source": [ "import geopandas as gpd\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2017-12-15T21:29:39.866422Z", "start_time": "2017-12-15T21:29:39.846422Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Observations, Attributes: (49, 21)\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AREAPERIMETERCOLUMBUS_COLUMBUS_IPOLYIDNEIGHOVALINCCRIMEOPEN...DISCBDXYNSANSBEWCPTHOUSNEIGNOgeometry
00.3094412.440629251580.46700319.53115.7259802.850747...5.0338.79999944.0700001.01.01.00.01000.01005.0POLYGON ((8.62413 14.23698, 8.55970 14.74245, ...
10.2593292.236939312144.56700121.23218.8017545.296720...4.2735.61999942.3800011.01.00.00.01000.01001.0POLYGON ((8.25279 14.23694, 8.28276 14.22994, ...
20.1924682.187547463626.35000015.95630.6267814.534649...3.8939.82000041.1800001.01.01.00.01000.01006.0POLYGON ((8.65331 14.00809, 8.81814 14.00205, ...
30.0838411.427635524233.2000014.47732.3877600.394427...3.7036.50000040.5200001.01.00.00.01000.01002.0POLYGON ((8.45950 13.82035, 8.47341 13.83227, ...
40.4888882.997133675723.22500011.25250.7315100.405664...2.8340.00999838.0000001.01.01.00.01000.01007.0POLYGON ((8.68527 13.63952, 8.67758 13.72221, ...
\n", "

5 rows × 21 columns

\n", "