{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Datasets for use with libpysal\n",
    "As of version 4.2, libpysal has refactored the `examples` package to:\n",
    "\n",
    "- reduce the size of the source installation\n",
    "- allow the use of remote datasets from the [Center for Spatial Data Science at the Unversity of Chicago](https://spatial.uchicago.edu/), and other remotes\n",
    "\n",
    "This notebook highlights the new functionality"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Backwards compatibility is maintained"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "If you were familiar with previous versions of libpysal, the newest version maintains backwards compatibility so any code that relied on the previous API should work. \n",
    "\n",
    "For example:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from libpysal.examples import get_path \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'/home/serge/Documents/p/pysal/src/subpackages/libpysal/libpysal/examples/mexico/mexicojoin.dbf'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "get_path(\"mexicojoin.dbf\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "An important thing to note here is that the path to the file for this particular example is within the source distribution that was installed. Such an example data set is now referred to as a `builtin` dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import libpysal\n",
    "dbf = libpysal.io.open(get_path(\"mexicojoin.dbf\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['POLY_ID',\n",
       " 'AREA',\n",
       " 'CODE',\n",
       " 'NAME',\n",
       " 'PERIMETER',\n",
       " 'ACRES',\n",
       " 'HECTARES',\n",
       " 'PCGDP1940',\n",
       " 'PCGDP1950',\n",
       " 'PCGDP1960',\n",
       " 'PCGDP1970',\n",
       " 'PCGDP1980',\n",
       " 'PCGDP1990',\n",
       " 'PCGDP2000',\n",
       " 'HANSON03',\n",
       " 'HANSON98',\n",
       " 'ESQUIVEL99',\n",
       " 'INEGI',\n",
       " 'INEGI2',\n",
       " 'MAXP',\n",
       " 'GR4000',\n",
       " 'GR5000',\n",
       " 'GR6000',\n",
       " 'GR7000',\n",
       " 'GR8000',\n",
       " 'GR9000',\n",
       " 'LPCGDP40',\n",
       " 'LPCGDP50',\n",
       " 'LPCGDP60',\n",
       " 'LPCGDP70',\n",
       " 'LPCGDP80',\n",
       " 'LPCGDP90',\n",
       " 'LPCGDP00',\n",
       " 'TEST']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dbf.header"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The function `available` is also available but has been updated to return a Pandas DataFrame. In addition to the builtin datasets, `available` will report on what datasets are available, either as builtin or remotes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "from libpysal.examples import available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = available()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(98, 3)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "98 datasets available, 27 installed, 71 remote.\n"
     ]
    }
   ],
   "source": [
    "libpysal.examples.summary()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We see that there are 98 total datasets available for use with PySAL. On an initial install (i.e., `examples` has not been used yet), 27 of these are builtin datasets and 71 are remote. The latter can be downloaded and installed."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Downloading Remote Datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Description</th>\n",
       "      <th>Installed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10740</td>\n",
       "      <td>Albuquerque, New Mexico, Census 2000 Tract Dat...</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AirBnB</td>\n",
       "      <td>Airbnb rentals, socioeconomics, and crime in C...</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Atlanta, GA region homicide counts and rates</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Baltimore</td>\n",
       "      <td>Baltimore house sales prices and hedonics</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Bostonhsg</td>\n",
       "      <td>Boston housing and neighborhood data</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Name                                        Description  Installed\n",
       "0      10740  Albuquerque, New Mexico, Census 2000 Tract Dat...       True\n",
       "1     AirBnB  Airbnb rentals, socioeconomics, and crime in C...      False\n",
       "2    Atlanta       Atlanta, GA region homicide counts and rates      False\n",
       "3  Baltimore          Baltimore house sales prices and hedonics      False\n",
       "4  Bostonhsg               Boston housing and neighborhood data      False"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The remote `AirBnB` can be installed by calling `load_example`:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading AirBnB to /home/serge/.local/share/pysal/AirBnB\n"
     ]
    }
   ],
   "source": [
    "airbnb = libpysal.examples.load_example(\"AirBnB\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "98 datasets available, 28 installed, 70 remote.\n"
     ]
    }
   ],
   "source": [
    "libpysal.examples.summary()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And we see that the number of remotes as declined by one and the number of installed has increased by 1."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Trying to load an example that doesn't exist will return None and alert the user:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Example not available: dataset42\n"
     ]
    }
   ],
   "source": [
    "libpysal.examples.load_example('dataset42')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Getting remote urls\n",
    "\n",
    "If the url, rather than the dataset, is needed this can be obtained on a remote with `get_url`. \n",
    "As the `Baltimore` dataset has not yet been downloaded in this example, we can grab it's url:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'https://geodacenter.github.io/data-and-lab//data/baltimore.zip'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "balt_url = libpysal.examples.get_url('Baltimore')\n",
    "balt_url"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Explaining a dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "taz\n",
      "===\n",
      "\n",
      "Dataset used for regionalization\n",
      "--------------------------------\n",
      "\n",
      "* taz.dbf: attribute data. (k=14)\n",
      "* taz.shp: Polygon shapefile. (n=4109)\n",
      "* taz.shx: spatial index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "libpysal.examples.explain('taz')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading taz to /home/serge/.local/share/pysal/taz\n"
     ]
    }
   ],
   "source": [
    "taz = libpysal.examples.load_example('taz')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/home/serge/.local/share/pysal/taz/taz-master/taz.dbf',\n",
       " '/home/serge/.local/share/pysal/taz/taz-master/taz.shp',\n",
       " '/home/serge/.local/share/pysal/taz/taz-master/README.md',\n",
       " '/home/serge/.local/share/pysal/taz/taz-master/taz.shx']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "taz.get_file_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <iframe\n",
       "            width=\"700\"\n",
       "            height=\"350\"\n",
       "            src=\"https://geodacenter.github.io/data-and-lab//baltim/\"\n",
       "            frameborder=\"0\"\n",
       "            allowfullscreen\n",
       "            \n",
       "        ></iframe>\n",
       "        "
      ],
      "text/plain": [
       "<IPython.lib.display.IFrame at 0x7febc3b56c50>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "libpysal.examples.explain('Baltimore')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading Baltimore to /home/serge/.local/share/pysal/Baltimore\n"
     ]
    }
   ],
   "source": [
    "balt = libpysal.examples.load_example('Baltimore')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Description</th>\n",
       "      <th>Installed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10740</td>\n",
       "      <td>Albuquerque, New Mexico, Census 2000 Tract Dat...</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>AirBnB</td>\n",
       "      <td>Airbnb rentals, socioeconomics, and crime in C...</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Atlanta</td>\n",
       "      <td>Atlanta, GA region homicide counts and rates</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Baltimore</td>\n",
       "      <td>Baltimore house sales prices and hedonics</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Bostonhsg</td>\n",
       "      <td>Boston housing and neighborhood data</td>\n",
       "      <td>False</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>93</th>\n",
       "      <td>taz</td>\n",
       "      <td>Traffic Analysis Zones in So. California</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>94</th>\n",
       "      <td>tokyo</td>\n",
       "      <td>Tokyo Mortality data</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>95</th>\n",
       "      <td>us_income</td>\n",
       "      <td>Per-capita income for the lower 48 US states 1...</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>96</th>\n",
       "      <td>virginia</td>\n",
       "      <td>Virginia counties shapefile</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>97</th>\n",
       "      <td>wmat</td>\n",
       "      <td>Datasets used for spatial weights testing</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>98 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         Name                                        Description  Installed\n",
       "0       10740  Albuquerque, New Mexico, Census 2000 Tract Dat...       True\n",
       "1      AirBnB  Airbnb rentals, socioeconomics, and crime in C...       True\n",
       "2     Atlanta       Atlanta, GA region homicide counts and rates      False\n",
       "3   Baltimore          Baltimore house sales prices and hedonics       True\n",
       "4   Bostonhsg               Boston housing and neighborhood data      False\n",
       "..        ...                                                ...        ...\n",
       "93        taz           Traffic Analysis Zones in So. California       True\n",
       "94      tokyo                               Tokyo Mortality data       True\n",
       "95  us_income  Per-capita income for the lower 48 US states 1...       True\n",
       "96   virginia                        Virginia counties shapefile       True\n",
       "97       wmat          Datasets used for spatial weights testing       True\n",
       "\n",
       "[98 rows x 3 columns]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "libpysal.examples.available()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Working with an example dataset\n",
    "\n",
    "`explain` will render maps for an example if available"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "        <iframe\n",
       "            width=\"700\"\n",
       "            height=\"350\"\n",
       "            src=\"https://geodacenter.github.io/data-and-lab//tampa1/\"\n",
       "            frameborder=\"0\"\n",
       "            allowfullscreen\n",
       "            \n",
       "        ></iframe>\n",
       "        "
      ],
      "text/plain": [
       "<IPython.lib.display.IFrame at 0x7febc3b56890>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from libpysal.examples import explain\n",
    "explain('Tampa1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading Tampa1 to /home/serge/.local/share/pysal/Tampa1\n"
     ]
    }
   ],
   "source": [
    "from libpysal.examples import load_example\n",
    "tampa1 = load_example('Tampa1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tampa1.installed"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.shp',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.prj',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/2000 Census Data Variables_Documentation.pdf',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.kml',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.dbf',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.kml',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.sbn',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.mif',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.prj',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.sqlite',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.shx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.sbn',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.sbx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000001.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000004.FDO_UUID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000002.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.CatRelTypesByName.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a0000000a.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000003.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000009.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000002.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000006.CatRelsByType.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000009.spx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.CatRelTypesByDestItemTypeID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000005.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/timestamps',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000005.CatItemTypesByName.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000003.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000004.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000006.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000009.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000005.CatItemTypesByUUID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000005.CatItemTypesByParentTypeID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000004.CatItemsByType.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a0000000a.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.CatRelTypesByForwardLabel.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a0000000a.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000006.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000006.FDO_UUID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.CatRelTypesByUUID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000001.TablesByName.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000001.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000009.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000006.CatRelsByOriginID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000003.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000004.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a0000000a.spx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000004.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000004.CatItemsByPhysicalName.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000005.gdbtablx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.CatRelTypesByOriginItemTypeID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000006.gdbtable',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/gdb',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000001.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000004.spx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000007.CatRelTypesByBackwardLabel.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000005.gdbindexes',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/TampaMSA.gdb/a00000006.CatRelsByDestinationID.atx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.mid',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.sbx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.geojson',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.mid',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.xlsx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.mif',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.dbf',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.shp',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.gpkg',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.gpkg',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.xlsx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.shx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_final_census2.sqlite',\n",
       " '/home/serge/.local/share/pysal/Tampa1/TampaMSA/tampa_counties.geojson',\n",
       " '/home/serge/.local/share/pysal/Tampa1/__MACOSX/TampaMSA/._2000 Census Data Variables_Documentation.pdf',\n",
       " '/home/serge/.local/share/pysal/Tampa1/__MACOSX/TampaMSA/._tampa_counties.sbn',\n",
       " '/home/serge/.local/share/pysal/Tampa1/__MACOSX/TampaMSA/._tampa_final_census2.sbn',\n",
       " '/home/serge/.local/share/pysal/Tampa1/__MACOSX/TampaMSA/._tampa_counties.sbx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/__MACOSX/TampaMSA/._tampa_final_census2.sbx',\n",
       " '/home/serge/.local/share/pysal/Tampa1/__MACOSX/._TampaMSA']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tampa1.get_file_list()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "tampa_counties_shp = tampa1.load('tampa_counties.shp')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<libpysal.io.iohandlers.pyShpIO.PurePyShpWrapper at 0x7febc3b1bd00>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tampa_counties_shp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "import geopandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "tampa_df = geopandas.read_file(tampa1.get_path('tampa_counties.shp'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:>"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 30096 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "tampa_df.plot()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Other Remotes\n",
    "\n",
    "In addition to the remote datasets from the GeoData Data Science Center, there are several large remotes available at github repositories. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rio_Grande_do_Sul\n",
      "======================\n",
      "\n",
      "Cities of the Brazilian State of Rio Grande do Sul\n",
      "-------------------------------------------------------\n",
      "\n",
      "* 43MUE250GC_SIR.dbf: attribute data (k=2)\n",
      "* 43MUE250GC_SIR.shp: Polygon shapefile (n=499)\n",
      "* 43MUE250GC_SIR.shx: spatial index\n",
      "* 43MUE250GC_SIR.cpg: encoding file \n",
      "* 43MUE250GC_SIR.prj: projection information \n",
      "* map_RS_BR.dbf: attribute data (k=3)\n",
      "* map_RS_BR.shp: Polygon shapefile (no lakes) (n=497)\n",
      "* map_RS_BR.prj: projection information\n",
      "* map_RS_BR.shx: spatial index\n",
      "\n",
      "\n",
      "\n",
      "Source: Renan Xavier Cortes \n",
      "Reference: https://github.com/pysal/pysal/issues/889#issuecomment-396693495\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "libpysal.examples.explain('Rio Grande do Sul')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Note that the `explain` function generates a textual description of this example dataset - no rendering of the map is done as the source repository does not include that functionality."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading Rio Grande do Sul to /home/serge/.local/share/pysal/Rio_Grande_do_Sul\n"
     ]
    }
   ],
   "source": [
    "rio = libpysal.examples.load_example('Rio Grande do Sul')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'AirBnB': <libpysal.examples.base.Example at 0x7febc78c00d0>,\n",
       " 'Atlanta': <libpysal.examples.base.Example at 0x7febc4a5efb0>,\n",
       " 'Baltimore': <libpysal.examples.base.Example at 0x7febc4a5ed40>,\n",
       " 'Bostonhsg': <libpysal.examples.base.Example at 0x7febc4a5ef50>,\n",
       " 'Buenosaires': <libpysal.examples.base.Example at 0x7febc4a5efe0>,\n",
       " 'Charleston1': <libpysal.examples.base.Example at 0x7febc4a5ef80>,\n",
       " 'Charleston2': <libpysal.examples.base.Example at 0x7febc4a5ee90>,\n",
       " 'Chicago Health': <libpysal.examples.base.Example at 0x7febc4a5ef20>,\n",
       " 'Chicago commpop': <libpysal.examples.base.Example at 0x7febc4a5f070>,\n",
       " 'Chicago parcels': <libpysal.examples.base.Example at 0x7febc4a5f0a0>,\n",
       " 'Chile Labor': <libpysal.examples.base.Example at 0x7febc4a5f100>,\n",
       " 'Chile Migration': <libpysal.examples.base.Example at 0x7febc4a5f130>,\n",
       " 'Cincinnati': <libpysal.examples.base.Example at 0x7febc4a5f1f0>,\n",
       " 'Cleveland': <libpysal.examples.base.Example at 0x7febc4a5f190>,\n",
       " 'Columbus': <libpysal.examples.base.Example at 0x7febc4a5f250>,\n",
       " 'Elections': <libpysal.examples.base.Example at 0x7febc4a5f0d0>,\n",
       " 'Grid100': <libpysal.examples.base.Example at 0x7febc4a5f220>,\n",
       " 'Groceries': <libpysal.examples.base.Example at 0x7febc4a5f160>,\n",
       " 'Guerry': <libpysal.examples.base.Example at 0x7febc4a5f280>,\n",
       " 'Health+': <libpysal.examples.base.Example at 0x7febc4a5f040>,\n",
       " 'Health Indicators': <libpysal.examples.base.Example at 0x7febc4a5f2b0>,\n",
       " 'Hickory1': <libpysal.examples.base.Example at 0x7febc4a5f2e0>,\n",
       " 'Hickory2': <libpysal.examples.base.Example at 0x7febc4a5f310>,\n",
       " 'Home Sales': <libpysal.examples.base.Example at 0x7febc4a5f340>,\n",
       " 'Houston': <libpysal.examples.base.Example at 0x7febc4a5f370>,\n",
       " 'Juvenile': <libpysal.examples.base.Example at 0x7febc4a5f3a0>,\n",
       " 'Lansing1': <libpysal.examples.base.Example at 0x7febc4a5f3d0>,\n",
       " 'Lansing2': <libpysal.examples.base.Example at 0x7febc4a5f400>,\n",
       " 'Laozone': <libpysal.examples.base.Example at 0x7febc4a5f430>,\n",
       " 'LasRosas': <libpysal.examples.base.Example at 0x7febc4a5f460>,\n",
       " 'Liquor Stores': <libpysal.examples.base.Example at 0x7febc4a5f490>,\n",
       " 'Malaria': <libpysal.examples.base.Example at 0x7febc4a5f4c0>,\n",
       " 'Milwaukee1': <libpysal.examples.base.Example at 0x7febc4a5f4f0>,\n",
       " 'Milwaukee2': <libpysal.examples.base.Example at 0x7febc4a5f520>,\n",
       " 'NCOVR': <libpysal.examples.base.Example at 0x7febc4a5f550>,\n",
       " 'Natregimes': <libpysal.examples.base.Example at 0x7febc4a5f580>,\n",
       " 'NDVI': <libpysal.examples.base.Example at 0x7febc4a5f5b0>,\n",
       " 'Nepal': <libpysal.examples.base.Example at 0x7febc4a5f5e0>,\n",
       " 'NYC': <libpysal.examples.base.Example at 0x7febc4a5f610>,\n",
       " 'NYC Earnings': <libpysal.examples.base.Example at 0x7febc4a5f640>,\n",
       " 'NYC Education': <libpysal.examples.base.Example at 0x7febc4a5f670>,\n",
       " 'NYC Neighborhoods': <libpysal.examples.base.Example at 0x7febc4a5f6a0>,\n",
       " 'NYC Socio-Demographics': <libpysal.examples.base.Example at 0x7febc4a5f6d0>,\n",
       " 'Ohiolung': <libpysal.examples.base.Example at 0x7febc4a5f700>,\n",
       " 'Orlando1': <libpysal.examples.base.Example at 0x7febc4a5f730>,\n",
       " 'Orlando2': <libpysal.examples.base.Example at 0x7febc4a5f760>,\n",
       " 'Oz9799': <libpysal.examples.base.Example at 0x7febc4a5f790>,\n",
       " 'Phoenix ACS': <libpysal.examples.base.Example at 0x7febc4a5f7c0>,\n",
       " 'Pittsburgh': <libpysal.examples.base.Example at 0x7febc4a5f7f0>,\n",
       " 'Police': <libpysal.examples.base.Example at 0x7febc4a5f820>,\n",
       " 'Sacramento1': <libpysal.examples.base.Example at 0x7febc4a5f850>,\n",
       " 'Sacramento2': <libpysal.examples.base.Example at 0x7febc4a5f880>,\n",
       " 'SanFran Crime': <libpysal.examples.base.Example at 0x7febc4a5f8b0>,\n",
       " 'Savannah1': <libpysal.examples.base.Example at 0x7febc4a5f8e0>,\n",
       " 'Savannah2': <libpysal.examples.base.Example at 0x7febc4a5f910>,\n",
       " 'Scotlip': <libpysal.examples.base.Example at 0x7febc4a5f940>,\n",
       " 'Seattle1': <libpysal.examples.base.Example at 0x7febc4a5f970>,\n",
       " 'Seattle2': <libpysal.examples.base.Example at 0x7febc4a5f9a0>,\n",
       " 'SIDS': <libpysal.examples.base.Example at 0x7febc4a5f9d0>,\n",
       " 'SIDS2': <libpysal.examples.base.Example at 0x7febc4a5fa00>,\n",
       " 'Snow': <libpysal.examples.base.Example at 0x7febc4a5fa30>,\n",
       " 'South': <libpysal.examples.base.Example at 0x7febc4a5fa60>,\n",
       " 'Spirals': <libpysal.examples.base.Example at 0x7febc4a5fa90>,\n",
       " 'StLouis': <libpysal.examples.base.Example at 0x7febc4a5fac0>,\n",
       " 'Tampa1': <libpysal.examples.base.Example at 0x7febc4a5faf0>,\n",
       " 'US SDOH': <libpysal.examples.base.Example at 0x7febc4a5fb20>,\n",
       " 'Rio Grande do Sul': <libpysal.examples.base.Example at 0x7febc78c0130>,\n",
       " 'nyc_bikes': <libpysal.examples.base.Example at 0x7febc4a5fb80>,\n",
       " 'taz': <libpysal.examples.base.Example at 0x7febc4a5fc70>,\n",
       " 'clearwater': <libpysal.examples.base.Example at 0x7febc4a5fbe0>,\n",
       " 'newHaven': <libpysal.examples.base.Example at 0x7febc4a5eec0>}"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "libpysal.examples.remote_datasets.datasets # a listing of all remotes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
