{ "cells": [ { "cell_type": "markdown", "id": "8bb25ba4-698b-466b-89d3-52a3f6808b54", "metadata": {}, "source": [ "## United States 2020 Census data\n", "\n", "In this tutorial, you will explore various subsets of geographic data in the [United States 2020 Census](https://www.census.gov/programs-surveys/decennial-census/decade/2020/2020-census-main.html). You will learn how the data is structured and how to access the data.\n", "\n", "The data consists of two groups:\n", "1. **Census data by census block boundaries**: This group contains data for each census block, grouped by US counties. Census blocks are the smallest available unit made available by the US Census Bureau. This group also includes population totals broken down by census block, available in a second table.\n", "2. **Census data by cartographic boundaries**: This group contains data that is aggregated by 29 different geographic boundaries, ranging from block groups to regional datasets such as metropolitan divisions and states. This group does not include any demographic information.\n", "\n", "This notebook contains details about all geographic datasets within the 2020 census data. Use the table of contents to jump to any section relevant to you. For a brief introduction, [Accessing US Census data with the Planetary Computer STAC API](../datasets/us-census/us-census-example.ipynb).\n", "\n", "### Table of Contents\n", "\n", "* [Accessing the Data](#Accessing-the-Data)\n", "* [Import Dependencies](#Import-Dependencies)\n", "* [Census data by census block boundaries](#Census-data-by-census-block-boundaries)\n", " * [Census Block Boundaries](#Census-Block-Boundaries) (8,180,866 features)\n", "* [Census data by cartographic boundaries](#Census-data-by-cartographic-boundaries)\n", " * [American Indian Area Geographies](#American-Indian-Area-Geographies)\n", " * [American Indian/Alaska Native Areas/Hawaiian Home Lands](#American-Indian/Alaska-Native-Areas/Hawaiian-Home-Lands-(AIANNH)) (704 features)\n", " * [American Indian Tribal Subdivisions](#American-Indian-Tribal-Subdivisions-(AITSN)) (484 features)\n", " * [Alaska Native Regional Corporations](#Alaska-Native-Regional-Corporations-(ANRC)) (12 features)\n", " * [Tribal Block Groups](#Tribal-Block-Groups-(TBG)) (934 features)\n", " * [Tribal Census Tracts](#Tribal-Census-Tracts-(TTRACT)) (492 features)\n", " * [Census Block Groups](#Census-Block-Groups-(BG)) (242,305 features)\n", " * [Census Tracts](#Census-Tracts-(TRACT)) (85,190 features)\n", " * [Congressional Districts](#Congressional-Districts:-116th-Congress-(CD116)) (441 features)\n", " * [Consolidated Cities](#Consolidated-Cities-(CONCITY)) (8 features)\n", " * [Counties](#Counties-(COUNTY)) (3,234 features)\n", " * [Counties within Congressional Districts](#Counties-within-Congressional-Districts:-116th-Congress-(COUNTY_within_CD116)) (3,836 features)\n", " * [County Subdivisions](#County-Subdivisions-(COUSUB)) (36,502 features)\n", " * [Divisions](#Divisions-(DIVISION)) (9 features)\n", " * [Metropolitan and Micropolitan Statistical Areas and Related Statistical Areas](#Metropolitan-and-Micropolitan-Statistical-Areas-and-Related-Statistical-Areas)\n", " * [Core Based Statistical Areas](#Core-Based-Statistical-Areas-(CBSA)) (939 features)\n", " * [Combined Statistical Areas](#Combined-Statistical-Areas-(CSA)) (175 features)\n", " * [Metropolitan Divisions](#Metropolitan-Divisions-(METDIV)) (31 features)\n", " * [New England City and Town Areas](#New-England-City-and-Town-Areas-(NECTA)) (40 features)\n", " * [New England City and Town Areas Division](#New-England-City-and-Town-Areas-Division(NECTADIV)) (11 features)\n", " * [Combined New England City and Town Areas](#Combined-New-England-City-and-Town-Areas-(CNECTA)) (7 features)\n", " * [Places](#Places-(PLACE)) (32,188 features)\n", " * [Regions](#Regions-(REGION)) (4 features)\n", " * [School Districts](#School-Districts)\n", " * [Elementary](#School-Districts---Elementary-(ELSD)) (1,945 features)\n", " * [Secondary](#School-Districts---Secondary-(SCSD)) (473 features)\n", " * [Unified](#School-Districts---Unified-(UNSD)) (10,867 features)\n", " * [State Legislative Districts](#State-Legislative-Districts)\n", " * [Lower Chamber](#State-Legislative-Districts---Lower-Chamber-(SLDL)) (4,829 features)\n", " * [Upper Chamber](#State-Legislative-Districts---Upper-Chamber-(SLDU)) (1,958 features)\n", " * [States](#States-(STATE)) (56 features)\n", " * [Subbarrios](#Subbarrios-(SUBBARRIO)) (145 features)\n", " * [United States Outline](#United-States-Outline) (1 feature)\n", " * [Voting Districts](#Voting-Districts-(VTD)) (158,320 features)\n", "\n", "### Accessing the Data\n", "\n", "Like other datasets on the Planetary Computer, US Census datasets are cataloged using [STAC](https://stacspec.org/). Each table, corresponding a particular level of cartographic aggregation, is available as a STAC item under the `us-census` collection." ] }, { "cell_type": "code", "execution_count": 1, "id": "27f8a592-1b81-49ed-a06a-731119df9113", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
\n", "
\n", " \n", "
\n", "
" ], "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pystac_client\n", "import planetary_computer\n", "\n", "catalog = pystac_client.Client.open(\n", " \"https://planetarycomputer.microsoft.com/api/stac/v1/\",\n", " modifier=planetary_computer.sign_inplace,\n", ")\n", "census = catalog.get_collection(\"us-census\")\n", "census" ] }, { "cell_type": "markdown", "id": "61d331c9-be0b-488a-b2e8-17cf9fb49d44", "metadata": {}, "source": [ "The actual files themselves are stored as [Apache Parquet](https://parquet.apache.org/) datasets in Azure Blob Storage. These files can be loaded with pandas or geopandas, or dask-geopandas if the files are larger than memory.\n", "\n", "Loading each of the tables will follow the same basic pattern:\n", "\n", "1. Get the Item from the collection with `census.get_item(item_id)`\n", "2. Use the `href` and `table:storage_options` fields from the `data` asset to load the data with `read_parquet`." ] }, { "cell_type": "markdown", "id": "fb3fad76", "metadata": {}, "source": [ "### Import Dependencies\n", "\n", "We'll import a few libraries to use for accessing and plotting the data. In particular,[geopandas](https://geopandas.org/) and [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to load the parquet datasets and [contextily](https://github.com/geopandas/contextily). Before getting started, make sure you have these two dependencies installed and imported:" ] }, { "cell_type": "code", "execution_count": 2, "id": "69f74280", "metadata": { "scrolled": true }, "outputs": [], "source": [ "import geopandas\n", "import dask_geopandas\n", "import contextily as ctx\n", "import planetary_computer" ] }, { "cell_type": "markdown", "id": "436d6ded", "metadata": {}, "source": [ "### Census data by census block boundaries\n", "\n", "The first block of data is organized by [Census blocks](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_5). Census blocks are the smallest geographic grouping available in the current dataset. There are over eight million census blocks, resulting in large datasets. To facilitate parallelism and accessing subsets of the data, the Census block-level data are partitioned by state.\n", "\n", "There are two tables available at the Census block level: \"geo\", containing the boundaries and other data about the block, and \"population\", containing the population counts in that geometry by various features.\n", "\n", "**geo**\n", "\n", "* GEOID = Concatenation of county FIPS code, census tract code, and census block number. *In pandas and Dask, this is used as the index*.\n", "* STATEFP = State FIPS code\n", "* COUNTYFP = County FIPS code\n", "* TRACTCE = Census Tract code\n", "* BLOCKCE = Census Block code\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* INTPTLAT = Current latitude of the internal point\n", "* INTPTLON = Current longitude of the internal point\n", "* geometry = Coordinates for block polygons" ] }, { "cell_type": "code", "execution_count": 3, "id": "9dbb83a0", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Dask DataFrame Structure:
\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", "
STATEFPCOUNTYFPTRACTCEBLOCKCEALANDAWATERINTPTLATINTPTLONgeometry
npartitions=56
010010201001000category[unknown]category[unknown]int64int64int64int64float64float64geometry
020130001001000...........................
..............................
780109701001000...........................
780309900000008...........................
\n", "
Dask Name: readparquetfsspec, 1 expression
" ], "text/plain": [ "Dask DataFrame Structure:\n", " STATEFP COUNTYFP TRACTCE BLOCKCE ALAND AWATER INTPTLAT INTPTLON geometry\n", "npartitions=56 \n", "010010201001000 category[unknown] category[unknown] int64 int64 int64 int64 float64 float64 geometry\n", "020130001001000 ... ... ... ... ... ... ... ... ...\n", "... ... ... ... ... ... ... ... ... ...\n", "780109701001000 ... ... ... ... ... ... ... ... ...\n", "780309900000008 ... ... ... ... ... ... ... ... ...\n", "Dask Name: readparquetfsspec, 1 expression\n", "Expr=ReadParquetFSSpec(2c201cc)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-census-blocks-geo\").assets[\"data\"]\n", "\n", "geo = dask_geopandas.read_parquet(\n", " asset.href,\n", " storage_options=asset.extra_fields[\"table:storage_options\"],\n", " calculate_divisions=True,\n", ")\n", "geo" ] }, { "cell_type": "markdown", "id": "60b0b30b", "metadata": {}, "source": [ "**pop**\n", "\n", "The population table contains may columns. Two are important to call out:\n", "\n", "* GEOID = Concatenation of county FIPS code, census tract code, and census block number. *In pandas and Dask, this is used as the index*.\n", "* P0010001 = Total Block Population\n", "\n", "The remainder of the columns provide the Block's population faceted by various features. [This document (pdf)](https://www2.census.gov/programs-surveys/decennial/2010/technical-documentation/complete-tech-docs/summary-file/nsfrd.pdf) documents the meaning of all the additional variables." ] }, { "cell_type": "code", "execution_count": 4, "id": "e94a7420", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Dask DataFrame Structure:
\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", " \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", " \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", " \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", " \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", " \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", " \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", "
P0010001P0010002P0010003P0010004P0010005P0010006P0010007P0010008P0010009P0010010P0010011P0010012P0010013P0010014P0010015P0010016P0010017P0010018P0010019P0010020P0010021P0010022P0010023P0010024P0010025P0010026P0010027P0010028P0010029P0010030P0010031P0010032P0010033P0010034P0010035P0010036P0010037P0010038P0010039P0010040P0010041P0010042P0010043P0010044P0010045P0010046P0010047P0010048P0010049P0010050P0010051P0010052P0010053P0010054P0010055P0010056P0010057P0010058P0010059P0010060P0010061P0010062P0010063P0010064P0010065P0010066P0010067P0010068P0010069P0010070P0010071P0020001P0020002P0020003P0020004P0020005P0020006P0020007P0020008P0020009P0020010P0020011P0020012P0020013P0020014P0020015P0020016P0020017P0020018P0020019P0020020P0020021P0020022P0020023P0020024P0020025P0020026P0020027P0020028P0020029P0020030P0020031P0020032P0020033P0020034P0020035P0020036P0020037P0020038P0020039P0020040P0020041P0020042P0020043P0020044P0020045P0020046P0020047P0020048P0020049P0020050P0020051P0020052P0020053P0020054P0020055P0020056P0020057P0020058P0020059P0020060P0020061P0020062P0020063P0020064P0020065P0020066P0020067P0020068P0020069P0020070P0020071P0020072P0020073
npartitions=52
010010201001000int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64int64
020130001001000................................................................................................................................................................................................................................................................................................................................................................................................................................................
...................................................................................................................................................................................................................................................................................................................................................................................................................................................
720019563001000................................................................................................................................................................................................................................................................................................................................................................................................................................................
721537506022015................................................................................................................................................................................................................................................................................................................................................................................................................................................
\n", "
Dask Name: readparquetfsspec, 1 expression
" ], "text/plain": [ "Dask DataFrame Structure:\n", " P0010001 P0010002 P0010003 P0010004 P0010005 P0010006 P0010007 P0010008 P0010009 P0010010 P0010011 P0010012 P0010013 P0010014 P0010015 P0010016 P0010017 P0010018 P0010019 P0010020 P0010021 P0010022 P0010023 P0010024 P0010025 P0010026 P0010027 P0010028 P0010029 P0010030 P0010031 P0010032 P0010033 P0010034 P0010035 P0010036 P0010037 P0010038 P0010039 P0010040 P0010041 P0010042 P0010043 P0010044 P0010045 P0010046 P0010047 P0010048 P0010049 P0010050 P0010051 P0010052 P0010053 P0010054 P0010055 P0010056 P0010057 P0010058 P0010059 P0010060 P0010061 P0010062 P0010063 P0010064 P0010065 P0010066 P0010067 P0010068 P0010069 P0010070 P0010071 P0020001 P0020002 P0020003 P0020004 P0020005 P0020006 P0020007 P0020008 P0020009 P0020010 P0020011 P0020012 P0020013 P0020014 P0020015 P0020016 P0020017 P0020018 P0020019 P0020020 P0020021 P0020022 P0020023 P0020024 P0020025 P0020026 P0020027 P0020028 P0020029 P0020030 P0020031 P0020032 P0020033 P0020034 P0020035 P0020036 P0020037 P0020038 P0020039 P0020040 P0020041 P0020042 P0020043 P0020044 P0020045 P0020046 P0020047 P0020048 P0020049 P0020050 P0020051 P0020052 P0020053 P0020054 P0020055 P0020056 P0020057 P0020058 P0020059 P0020060 P0020061 P0020062 P0020063 P0020064 P0020065 P0020066 P0020067 P0020068 P0020069 P0020070 P0020071 P0020072 P0020073\n", "npartitions=52 \n", "010010201001000 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64 int64\n", "020130001001000 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...\n", "... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...\n", "720019563001000 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...\n", "721537506022015 ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...\n", "Dask Name: readparquetfsspec, 1 expression\n", "Expr=ReadParquetFSSpec(88bbc32)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import dask.dataframe\n", "\n", "asset = census.get_item(\"2020-census-blocks-population\").assets[\"data\"]\n", "\n", "pop = dask.dataframe.read_parquet(\n", " asset.href,\n", " storage_options=asset.extra_fields[\"table:storage_options\"],\n", " calculate_divisions=True,\n", ")\n", "pop" ] }, { "cell_type": "code", "execution_count": 6, "id": "e2ab4a76-bca3-4cd0-bd51-346a5d06ef2e", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 455 ms, sys: 97.6 ms, total: 552 ms\n", "Wall time: 672 ms\n" ] } ], "source": [ "ri = geo.get_partition(39).compute()" ] }, { "cell_type": "markdown", "id": "4cb56966", "metadata": {}, "source": [ "The datasets use `GEOID` as their index and are partitioned by state, so we can use the FIPS codes [efficiently access subsets](https://docs.dask.org/en/latest/dataframe-best-practices.html#use-the-index) of the data." ] }, { "cell_type": "code", "execution_count": 7, "id": "efc0d2a2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ax = ri.to_crs(epsg=3857).plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Census Blocks: Rhode Island\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "9df40551", "metadata": {}, "source": [ "Both the geo and population tables use `GEOID` as a unique identifier, so the geometries and population data can be joined together. Remember that population data are not available for territories, so we'll use an inner join." ] }, { "cell_type": "code", "execution_count": 8, "id": "ac89a359", "metadata": {}, "outputs": [], "source": [ "ri = (\n", " geo.get_partition(39)\n", " .compute()\n", " .join(pop[[\"P0010001\"]].get_partition(39).compute(), how=\"inner\")\n", ")\n", "ri = ri[ri.P0010001 > 10]" ] }, { "cell_type": "markdown", "id": "d3b04ba6", "metadata": {}, "source": [ "Now lets plot the census blocks in Providence County with at least 150 people." ] }, { "cell_type": "code", "execution_count": 9, "id": "06e238f2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "providence = ri[(ri.P0010001 >= 150) & (ri.COUNTYFP == \"007\")]\n", "\n", "ax = providence.to_crs(epsg=3857).plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Census Blocks with Population Greater than 150: Providence County, RI\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "41152424", "metadata": {}, "source": [ "You can use this method with any census block within any county in the US.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**" ] }, { "cell_type": "markdown", "id": "eeb56385", "metadata": {}, "source": [ "### Census data by cartographic boundaries\n", "\n", "The second block of data is organized by different cartographic categories. These boundaries cover larger areas than the individual census blocks discussed [above](#Census-data-by-census-block-boundaries). The different categories range from census block groups (consisting of several census blocks) all the way up to a National Boundary file (encompassing the entire USA).\n", "\n", "The files in this second group tend to be smaller in size than the census block data in the first group. Therefore, the files in the second group are not partitioned into multiple files, and each dataset only consists of one parquet file. Another difference is that the datasets in this second group include different information than the census block files in the first group and do not contain population statistics. Which additional data is included differs from dataset to dataset. See [Appendix E. in the 2020 TIGER/Line Technical Documentation](https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2020/TGRSHP2020_TechDoc.pdf) for more details on the available feature classes.\n", "\n", "The following sections are examples of how to access and view each cartographic boundary file in this second group of data. Each example uses the same basic workflow and dependencies as the [Census Block Boundaries](#Census-data-by-census-block-boundaries) for the first group of data. An important thing to note when using this data is that before plotting the data onto a basemap, the datasets need to be converted to Web Mercator [(EPSG 3857)](https://epsg.io/3857) using the [to_crs](https://geopandas.org/docs/reference/api/geopandas.GeoDataFrame.to_crs.html) function of [GeoPandas](https://geopandas.org/).\n", "\n", "Some of the datasets are grouped together based on their type. It is important to note that some of the files may have gaps where no relevant data exists because states with no Tribal Block Groups do not have any Tribal Block Group data. The header for each example also includes the relevant abbreviation used for data access and retrieval.\n", "\n", "### American Indian Area Geographies\n", "\n", "American Indian Area Geographies is the first grouping of cartographic boundary files available.\n", "\n", "#### American Indian/Alaska Native Areas/Hawaiian Home Lands (AIANNH)\n", "\n", "This file contains data for legal and statistical [American Indian/Alaska Native Areas/Hawaiian Home Lands (AIANNH)](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_1) entities published by the US Census Bureau.\n", "\n", "The attribute table contains the following information:\n", "\n", "* AIANNHCE = AIANNH census code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = concatenation of AIANNH census code and reservation/statistical area or off-reservation trust land Hawaiian home land indicator\n", "* NAME = Current Area Name\n", "* NAMELSAD = Current name and legal/statistical status for each entity\n", "* LSAD = Current legal/statistical area code\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for AIANNH polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the AIANNH data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 10, "id": "b510cd26-90a0-4d47-ba87-b805e0d839a8", "metadata": {}, "outputs": [ { "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", "
AIANNHCEAIANNHNSAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
0951524187752500000US95159515Apache ChoctawApache Choctaw SDTSA922217513642632531POLYGON ((-93.77547 31.61937, -93.77411 31.619...
193709794942500000US93709370ShinnecockShinnecock (state) Reservation8634942920POLYGON ((-72.44070 40.87749, -72.43870 40.879...
2982024186932500000US98209820MaChis Lower CreekMaChis Lower Creek SDTSA9216807670356816074MULTIPOLYGON (((-85.54654 31.21440, -85.54342 ...
3612524187742500000US61256125AnvikAnvik ANVSA79245786436308736POLYGON ((-160.24545 62.69478, -160.24517 62.6...
4635024188362500000US63506350CircleCircle ANVSA792746340161398608POLYGON ((-144.38284 65.73496, -144.37907 65.7...
\n", "
" ], "text/plain": [ " AIANNHCE AIANNHNS AFFGEOID GEOID NAME \\\n", "0 9515 2418775 2500000US9515 9515 Apache Choctaw \n", "1 9370 979494 2500000US9370 9370 Shinnecock \n", "2 9820 2418693 2500000US9820 9820 MaChis Lower Creek \n", "3 6125 2418774 2500000US6125 6125 Anvik \n", "4 6350 2418836 2500000US6350 6350 Circle \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 Apache Choctaw SDTSA 92 221751364 2632531 \n", "1 Shinnecock (state) Reservation 86 3494292 0 \n", "2 MaChis Lower Creek SDTSA 92 1680767035 6816074 \n", "3 Anvik ANVSA 79 24578643 6308736 \n", "4 Circle ANVSA 79 274634016 1398608 \n", "\n", " geometry \n", "0 POLYGON ((-93.77547 31.61937, -93.77411 31.619... \n", "1 POLYGON ((-72.44070 40.87749, -72.43870 40.879... \n", "2 MULTIPOLYGON (((-85.54654 31.21440, -85.54342 ... \n", "3 POLYGON ((-160.24545 62.69478, -160.24517 62.6... \n", "4 POLYGON ((-144.38284 65.73496, -144.37907 65.7... " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_aiannh_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "eebc0042", "metadata": {}, "source": [ "Next, plot the data from this parquet file and apply a basemap. Rather than displaying the whole dataset, show only the Apache Choctaw American Indian Homeland by selecting a subset of the dataframe where the values in the `NAME` column match `\"Apache Choctaw\"`." ] }, { "cell_type": "code", "execution_count": 11, "id": "cdfbc7a7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"Apache Choctaw\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Apache Choctaw American Indian Home Land\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "9eee53ca", "metadata": {}, "source": [ "This map shows the shape of the Apache Choctaw American Indian Homeland overlaid on a Stamen Terrain Style basemap. To display the entire dataset, remove the part of the code that limits the dataframe to only the Apache Choctaw homeland. To plot a different area, change the dataframe's filter to a different attribute or value.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### American Indian Tribal Subdivisions (AITSN)\n", "\n", "This file contains data on [American Indian Tribal Subdivisions](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_1). These areas are the legally defined subdivisions of American Indian Reservations (AIR), Oklahoma Tribal Statistical Areas (OTSA), and Off-Reservation Trust Land (ORTL).\n", "\n", "The attribute table contains the following information:\n", "\n", "* AIANNHCE = AIANNH census code\n", "* TRSUBCE = Current AITSN census code\n", "* TRSUBNS = ANSI feature code for American Indian Tribal Subdivision\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = concatenation of AIANNH census code and AITSN census code\n", "* NAME = Current Area Name\n", "* NAMELSAD = Current name and legal/statistical AITSN description\n", "* LSAD = Current legal/statistical area code\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for AITSN polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the AIANNH data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 12, "id": "1c74dc98", "metadata": {}, "outputs": [ { "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", "
AIANNHCETRSUBCETRSUBNSAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
033510024189042510000US03351000335100Deer CreekDeer Creek SegmentT3910393851744201POLYGON ((-93.59601 47.89783, -93.57287 47.898...
1115040024189592510000US11504001150400HaysHays District077955974882961386MULTIPOLYGON (((-108.90981 47.91399, -108.8883...
2116030024190072510000US11603001160300MandareeMandaree SegmentT3919294747148670196POLYGON ((-102.78425 47.67410, -102.78497 47.7...
3559075024188862510000US5590750559075010County District 10TC330287650641402950POLYGON ((-96.45392 34.19828, -96.45372 34.257...
4559015024188892510000US559015055901502County District 2TC216651779572598055POLYGON ((-95.04677 34.41936, -95.00595 34.419...
\n", "
" ], "text/plain": [ " AIANNHCE TRSUBCE TRSUBNS AFFGEOID GEOID NAME \\\n", "0 335 100 2418904 2510000US0335100 0335100 Deer Creek \n", "1 1150 400 2418959 2510000US1150400 1150400 Hays \n", "2 1160 300 2419007 2510000US1160300 1160300 Mandaree \n", "3 5590 750 2418886 2510000US5590750 5590750 10 \n", "4 5590 150 2418889 2510000US5590150 5590150 2 \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 Deer Creek Segment T3 91039385 1744201 \n", "1 Hays District 07 795597488 2961386 \n", "2 Mandaree Segment T3 919294747 148670196 \n", "3 County District 10 TC 3302876506 41402950 \n", "4 County District 2 TC 2166517795 72598055 \n", "\n", " geometry \n", "0 POLYGON ((-93.59601 47.89783, -93.57287 47.898... \n", "1 MULTIPOLYGON (((-108.90981 47.91399, -108.8883... \n", "2 POLYGON ((-102.78425 47.67410, -102.78497 47.7... \n", "3 POLYGON ((-96.45392 34.19828, -96.45372 34.257... \n", "4 POLYGON ((-95.04677 34.41936, -95.00595 34.419... " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_aitsn_500k\").assets[\"data\"]\n", "\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "fd89271f", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap." ] }, { "cell_type": "code", "execution_count": 13, "id": "51964e06", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf.plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"American Indian Tribal Subdivisions\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "318cfa2c", "metadata": {}, "source": [ "The map created shows all the American Indian Tribal Subdivisions.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### Alaska Native Regional Corporations (ANRC)\n", "\n", "This file contains data on [Alaska Native Regional Corporations](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_1), which are corporations created according to the Alaska Native Claims Settlement Act. \n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* ANRCFP = ANRC FIPS code\n", "* ANRCNS = ANSI feature code for Alaska Native Regional Corporation\n", "* AFFGEOID American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = concatenation of state FIPS code and ANRC FIPS Code\n", "* NAME = Current area name\n", "* NAMELSAD = Current name and legal/statistical area description\n", "* LSAD = Legal/statistical area description code\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for ANRC polygon\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the ANRC data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 14, "id": "cc7937a8", "metadata": {}, "outputs": [ { "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", "
STATEFPANRCFPANRCNSAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
002904024193212300000US02090400209040Bristol BayBristol Bay Alaska Native Regional Corporation7710411027064025993444733MULTIPOLYGON (((-158.15947 56.14452, -158.1537...
10259024192952300000US02005900200590AhtnaAhtna Alaska Native Regional Corporation77740274137361391256190POLYGON ((-149.38382 63.35746, -148.96463 63.4...
2026794024191362300000US02679400267940SealaskaSealaska Alaska Native Regional Corporation779107366061341754708205MULTIPOLYGON (((-132.09854 56.07761, -132.0974...
3021714024188782300000US02171400217140Cook InletCook Inlet Alaska Native Regional Corporation779636140341820418982039MULTIPOLYGON (((-150.28586 61.12704, -150.2808...
402980024193282300000US02098000209800CalistaCalista Alaska Native Regional Corporation7714246487647519389800572MULTIPOLYGON (((-161.67073 58.56075, -161.6672...
\n", "
" ], "text/plain": [ " STATEFP ANRCFP ANRCNS AFFGEOID GEOID NAME \\\n", "0 02 9040 2419321 2300000US0209040 0209040 Bristol Bay \n", "1 02 590 2419295 2300000US0200590 0200590 Ahtna \n", "2 02 67940 2419136 2300000US0267940 0267940 Sealaska \n", "3 02 17140 2418878 2300000US0217140 0217140 Cook Inlet \n", "4 02 9800 2419328 2300000US0209800 0209800 Calista \n", "\n", " NAMELSAD LSAD ALAND \\\n", "0 Bristol Bay Alaska Native Regional Corporation 77 104110270640 \n", "1 Ahtna Alaska Native Regional Corporation 77 74027413736 \n", "2 Sealaska Alaska Native Regional Corporation 77 91073660613 \n", "3 Cook Inlet Alaska Native Regional Corporation 77 96361403418 \n", "4 Calista Alaska Native Regional Corporation 77 142464876475 \n", "\n", " AWATER geometry \n", "0 25993444733 MULTIPOLYGON (((-158.15947 56.14452, -158.1537... \n", "1 1391256190 POLYGON ((-149.38382 63.35746, -148.96463 63.4... \n", "2 41754708205 MULTIPOLYGON (((-132.09854 56.07761, -132.0974... \n", "3 20418982039 MULTIPOLYGON (((-150.28586 61.12704, -150.2808... \n", "4 19389800572 MULTIPOLYGON (((-161.67073 58.56075, -161.6672... " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_02_anrc_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "569e997b", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. To make the data work better with the Mercator Projection, exclude part of the dataset from the plot. To do so, limit your dataframe to rows that do not include `\"Aleut\"` in the AIANNHCE column." ] }, { "cell_type": "code", "execution_count": 15, "id": "66c0a74b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME != \"Aleut\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Alaska Native Regional Corporations (excluding Aleut)\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "d0f2e77b", "metadata": {}, "source": [ "The map created shows all the Alaskan Native Regional Corporations except for Aleut.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### Tribal Block Groups (TBG)\n", "\n", "This file includes data on [Tribal Block Groups](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_26), which are subdivisions of Tribal Census Tracts. These block groups can extend over multiple AIRs and ORTLs due to areas not meeting Block Group minimum population thresholds.\n", "\n", "The attribute table contains the following information:\n", "\n", "* AIANNHCE = AIANNH census code\n", "* TTRACTCE = Tribal Census Tract Code\n", "* TBLKGPCE = Tribal Block Group letter\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = concatenation of AIANNH census code, trivial census tract code, and tribal block group letter\n", "* NAMELSAD = Current legal/statistical description and tribal block group letter\n", "* LSAD = Current legal/statistical area code\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Block Group polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Tribal Block Group data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 16, "id": "18ae6242", "metadata": {}, "outputs": [ { "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", "
AIANNHCETTRACTCETBLKGPCEAFFGEOIDGEOIDNAMELSADLSADALANDAWATERgeometry
02430T03700C2580000US2430T03700C2430T03700CTribal Block Group CIB39451950POLYGON ((-111.26008 36.10715, -111.25910 36.1...
120T00400B2580000US0020T00400B0020T00400BTribal Block Group BIB1200584100165POLYGON ((-116.47052 33.78691, -116.46940 33.7...
21150T00100C2580000US1150T00100C1150T00100CTribal Block Group CIB6543546132911122MULTIPOLYGON (((-108.90981 47.91399, -108.8883...
32555T01000A2580000US2555T01000A2555T01000ATribal Block Group AIB396343904216784POLYGON ((-75.91155 43.00678, -75.90228 43.006...
4275T00100A2580000US0275T00100A0275T00100ATribal Block Group AIB4826510POLYGON ((-122.88954 39.02367, -122.88639 39.0...
\n", "
" ], "text/plain": [ " AIANNHCE TTRACTCE TBLKGPCE AFFGEOID GEOID \\\n", "0 2430 T03700 C 2580000US2430T03700C 2430T03700C \n", "1 20 T00400 B 2580000US0020T00400B 0020T00400B \n", "2 1150 T00100 C 2580000US1150T00100C 1150T00100C \n", "3 2555 T01000 A 2580000US2555T01000A 2555T01000A \n", "4 275 T00100 A 2580000US0275T00100A 0275T00100A \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 Tribal Block Group C IB 3945195 0 \n", "1 Tribal Block Group B IB 1200584 100165 \n", "2 Tribal Block Group C IB 654354613 2911122 \n", "3 Tribal Block Group A IB 39634390 4216784 \n", "4 Tribal Block Group A IB 482651 0 \n", "\n", " geometry \n", "0 POLYGON ((-111.26008 36.10715, -111.25910 36.1... \n", "1 POLYGON ((-116.47052 33.78691, -116.46940 33.7... \n", "2 MULTIPOLYGON (((-108.90981 47.91399, -108.8883... \n", "3 POLYGON ((-75.91155 43.00678, -75.90228 43.006... \n", "4 POLYGON ((-122.88954 39.02367, -122.88639 39.0... " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_tbg_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "cfb35a5a", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data for Tribal Block Group A by filtering by the TBLKGPCE column. Due to block group population threshold minimums, Tribal Block Group A spans a large portion of the contiguous United States and is not fully connected." ] }, { "cell_type": "code", "execution_count": 17, "id": "61459222", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.TBLKGPCE == \"A\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Tribal Block Group A\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "74623101", "metadata": {}, "source": [ "The map created shows Tribal Block Group A.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### Tribal Census Tracts (TTRACT)\n", "\n", "This file includes data on [Tribal Census Tracts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_27) which are relatively small statistical subdivisions of AIRs and ORTLs defined by federally recognized tribal government officials in partnership with the Census Bureau. Due to population thresholds, the Tracts may consist of multiple non-contiguous areas.\n", "\n", "The attribute table contains the following information:\n", "\n", "* AIANNHCE = AIANNH census code\n", "* TTRACTCE = Tribal Census Tract Code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = concatenation of AIANNH census code and tribal census tract code\n", "* NAME = Tribal Census Tract name\n", "* NAMELSAD = Current legal/statistical description and tribal census tract name\n", "* LSAD = Current legal/statistical area code\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Tribal Census Tract polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Tribal Block Group data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 18, "id": "5699593e", "metadata": {}, "outputs": [ { "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", "
AIANNHCETTRACTCEAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
0990T001002560000US0990T001000990T00100T001Tribal Census Tract T001IT13467251447477MULTIPOLYGON (((-83.38715 35.46808, -83.38610 ...
13935T001002560000US3935T001003935T00100T001Tribal Census Tract T001IT61425977020267661MULTIPOLYGON (((-98.76648 48.00405, -98.76471 ...
21160T002002560000US1160T002001160T00200T002Tribal Census Tract T002IT1955706500421434881POLYGON ((-102.65466 47.87091, -102.65497 47.8...
3525T001002560000US0525T001000525T00100T001Tribal Census Tract T001IT41769880MULTIPOLYGON (((-80.89902 34.90259, -80.89470 ...
44390T001002560000US4390T001004390T00100T001Tribal Census Tract T001IT16123751795684784POLYGON ((-110.53722 40.44993, -110.53444 40.4...
\n", "
" ], "text/plain": [ " AIANNHCE TTRACTCE AFFGEOID GEOID NAME \\\n", "0 990 T00100 2560000US0990T00100 0990T00100 T001 \n", "1 3935 T00100 2560000US3935T00100 3935T00100 T001 \n", "2 1160 T00200 2560000US1160T00200 1160T00200 T002 \n", "3 525 T00100 2560000US0525T00100 0525T00100 T001 \n", "4 4390 T00100 2560000US4390T00100 4390T00100 T001 \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 Tribal Census Tract T001 IT 134672514 47477 \n", "1 Tribal Census Tract T001 IT 614259770 20267661 \n", "2 Tribal Census Tract T002 IT 1955706500 421434881 \n", "3 Tribal Census Tract T001 IT 4176988 0 \n", "4 Tribal Census Tract T001 IT 1612375179 5684784 \n", "\n", " geometry \n", "0 MULTIPOLYGON (((-83.38715 35.46808, -83.38610 ... \n", "1 MULTIPOLYGON (((-98.76648 48.00405, -98.76471 ... \n", "2 POLYGON ((-102.65466 47.87091, -102.65497 47.8... \n", "3 MULTIPOLYGON (((-80.89902 34.90259, -80.89470 ... \n", "4 POLYGON ((-110.53722 40.44993, -110.53444 40.4... " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_ttract_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "6f48715e", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data for Tribal Census Tract T002 by filtering by the NAME column. Due to census tract population threshold minimums, Tribal Census Tract T002 spans a large portion of the contiguous United States and is not fully connected." ] }, { "cell_type": "code", "execution_count": 19, "id": "1d5dbef0", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"T002\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Tribal Census Tract T002\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "336eb01b", "metadata": {}, "source": [ "The map created shows Tribal Census Tract T002.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Census Block Groups (BG)\n", "\n", "This file contains data on [Census Block Groups](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_4). These groups are the second smallest geographic grouping. They consist of clusters of blocks within the same census tract that share the same first digit of their 4-character census block number. Census Block Groups generally contain between 600 and 3,000 people and generally cover contiguous areas.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* COUNTYFP = County FIPS code\n", "* TRACTCE = Census tract code\n", "* BLKGRPCE = Block group number\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS, County FIPS, Census tract code, and block group number\n", "* NAME = Block group number\n", "* NAMELSAD = Legal/statistical description and group number\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Block Group polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Block Group data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 20, "id": "f93a809d", "metadata": {}, "outputs": [ { "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", "
STATEFPCOUNTYFPTRACTCEBLKGRPCEAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
036029420021500000US3602900420023602900420022Block Group 2BG1688020POLYGON ((-78.81870 42.93591, -78.81814 42.936...
1360611240081500000US3606101240083606101240088Block Group 8BG185100POLYGON ((-73.95425 40.76617, -73.95203 40.765...
23605941040041500000US3605941040043605941040044Block Group 4BG3059900POLYGON ((-73.72361 40.66781, -73.72217 40.672...
33604711880021500000US3604711880023604711880022Block Group 2BG520330POLYGON ((-73.86754 40.68043, -73.86575 40.680...
4360051250011500000US3600501250013600501250011Block Group 1BG1007940POLYGON ((-73.89529 40.82814, -73.89506 40.828...
\n", "
" ], "text/plain": [ " STATEFP COUNTYFP TRACTCE BLKGRPCE AFFGEOID GEOID \\\n", "0 36 029 4200 2 1500000US360290042002 360290042002 \n", "1 36 061 12400 8 1500000US360610124008 360610124008 \n", "2 36 059 410400 4 1500000US360594104004 360594104004 \n", "3 36 047 118800 2 1500000US360471188002 360471188002 \n", "4 36 005 12500 1 1500000US360050125001 360050125001 \n", "\n", " NAME NAMELSAD LSAD ALAND AWATER \\\n", "0 2 Block Group 2 BG 168802 0 \n", "1 8 Block Group 8 BG 18510 0 \n", "2 4 Block Group 4 BG 305990 0 \n", "3 2 Block Group 2 BG 52033 0 \n", "4 1 Block Group 1 BG 100794 0 \n", "\n", " geometry \n", "0 POLYGON ((-78.81870 42.93591, -78.81814 42.936... \n", "1 POLYGON ((-73.95425 40.76617, -73.95203 40.765... \n", "2 POLYGON ((-73.72361 40.66781, -73.72217 40.672... \n", "3 POLYGON ((-73.86754 40.68043, -73.86575 40.680... \n", "4 POLYGON ((-73.89529 40.82814, -73.89506 40.828... " ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_bg_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "1123b826", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data for the state of California by filtering by the State FIPS code (`\"06\"`) in the STATEFP column." ] }, { "cell_type": "code", "execution_count": 21, "id": "67eb60d2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STATEFP == \"06\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Census Block Groups: California\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "03dfccae", "metadata": {}, "source": [ "The map created shows all the Census Block Groups in California.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Census Tracts (TRACT)\n", "\n", "This file contains data on [Census Tracts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_13) which are small and relatively permanent statistical subdivisions of a county or equivalent entity. Tract population size is generally between 1,200 and 8,000 people with an ideal size of 4,000. Boundaries tend to follow visible and identifiable features and are usually contiguous areas.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* COUNTYFP = County FIPS code\n", "* TRACTCE = Census tract code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS, County FIPS, and Census tract code\n", "* NAME = Census Tract name, it is the census tract code converted to an integer\n", "* NAMELSAD = Legal/statistical description and tract name\n", "* STUSPS = FIPS State Postal Code\n", "* NAMELSADCO = County name\n", "* STATE_NAME = State Name\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Census Tract polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Census Tract data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 22, "id": "b78bc969", "metadata": {}, "outputs": [ { "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", "
STATEFPCOUNTYFPTRACTCEAFFGEOIDGEOIDNAMENAMELSADSTUSPSNAMELSADCOSTATE_NAMELSADALANDAWATERgeometry
0170898530041400000US17089853004170898530048530.04Census Tract 8530.04ILKane CountyIllinoisCT362233491650POLYGON ((-88.35003 41.80764, -88.34938 41.810...
11100150031400000US110010050031100100500350.03Census Tract 50.03DCDistrict of ColumbiaDistrict of ColumbiaCT941360POLYGON ((-77.03195 38.90965, -77.03032 38.909...
2060374825031400000US06037482503060374825034825.03Census Tract 4825.03CALos Angeles CountyCaliforniaCT7296780POLYGON ((-118.09949 34.06262, -118.09466 34.0...
331153106301400000US3115301063031153010630106.30Census Tract 106.30NESarpy CountyNebraskaCT49648760POLYGON ((-96.23429 41.19035, -96.23010 41.190...
412057137061400000US1205701370612057013706137.06Census Tract 137.06FLHillsborough CountyFloridaCT53514110298POLYGON ((-82.34769 27.89656, -82.34680 27.898...
\n", "
" ], "text/plain": [ " STATEFP COUNTYFP TRACTCE AFFGEOID GEOID NAME \\\n", "0 17 089 853004 1400000US17089853004 17089853004 8530.04 \n", "1 11 001 5003 1400000US11001005003 11001005003 50.03 \n", "2 06 037 482503 1400000US06037482503 06037482503 4825.03 \n", "3 31 153 10630 1400000US31153010630 31153010630 106.30 \n", "4 12 057 13706 1400000US12057013706 12057013706 137.06 \n", "\n", " NAMELSAD STUSPS NAMELSADCO STATE_NAME \\\n", "0 Census Tract 8530.04 IL Kane County Illinois \n", "1 Census Tract 50.03 DC District of Columbia District of Columbia \n", "2 Census Tract 4825.03 CA Los Angeles County California \n", "3 Census Tract 106.30 NE Sarpy County Nebraska \n", "4 Census Tract 137.06 FL Hillsborough County Florida \n", "\n", " LSAD ALAND AWATER geometry \n", "0 CT 3622334 91650 POLYGON ((-88.35003 41.80764, -88.34938 41.810... \n", "1 CT 94136 0 POLYGON ((-77.03195 38.90965, -77.03032 38.909... \n", "2 CT 729678 0 POLYGON ((-118.09949 34.06262, -118.09466 34.0... \n", "3 CT 4964876 0 POLYGON ((-96.23429 41.19035, -96.23010 41.190... \n", "4 CT 535141 10298 POLYGON ((-82.34769 27.89656, -82.34680 27.898... " ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_tract_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "015f4c06", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data for Census Tracts located in Washington, DC by filtering for `\"DC\"` in the STUSPS column." ] }, { "cell_type": "code", "execution_count": 23, "id": "1f08cebb", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STUSPS == \"DC\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Census Tracts: Washington, DC\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "3e9da80b", "metadata": {}, "source": [ "The map created shows all the Census Tracts in Washington, DC.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Congressional Districts: 116th Congress (CD116)\n", "\n", "This file contains data on the [Congressional Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_9) for the 116th Congress. \n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS Code\n", "* CD116FP = Congressional District FIPS code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS and congressional district FIPS code\n", "* NAMELSAD = Legal/statistical description and name\n", "* LSAD = Legal/statistical classification\n", "* CDSESSN = Congressional Session Code\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Congressional District polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Congressional District data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 24, "id": "2bfe3289-6cff-4daf-97eb-d9eb96f9a950", "metadata": {}, "outputs": [ { "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", "
STATEFPCD116FPAFFGEOIDGEOIDNAMELSADLSADCDSESSNALANDAWATERgeometry
006425001600US06420642Congressional District 42C2116242475356344105315POLYGON ((-117.67629 33.88882, -117.65488 33.8...
13975001600US39073907Congressional District 7C21161001001639664562455MULTIPOLYGON (((-82.55933 40.78975, -82.55835 ...
24835001600US48034803Congressional District 3C2116124557401197890112POLYGON ((-96.84410 32.98891, -96.84403 32.992...
32825001600US28022802Congressional District 2C211640278711117951654563POLYGON ((-91.36371 31.78036, -91.35951 31.799...
442185001600US42184218Congressional District 18C211675765519519985421POLYGON ((-80.17834 40.33725, -80.17537 40.338...
\n", "
" ], "text/plain": [ " STATEFP CD116FP AFFGEOID GEOID NAMELSAD LSAD \\\n", "0 06 42 5001600US0642 0642 Congressional District 42 C2 \n", "1 39 7 5001600US3907 3907 Congressional District 7 C2 \n", "2 48 3 5001600US4803 4803 Congressional District 3 C2 \n", "3 28 2 5001600US2802 2802 Congressional District 2 C2 \n", "4 42 18 5001600US4218 4218 Congressional District 18 C2 \n", "\n", " CDSESSN ALAND AWATER \\\n", "0 116 2424753563 44105315 \n", "1 116 10010016396 64562455 \n", "2 116 1245574011 97890112 \n", "3 116 40278711117 951654563 \n", "4 116 757655195 19985421 \n", "\n", " geometry \n", "0 POLYGON ((-117.67629 33.88882, -117.65488 33.8... \n", "1 MULTIPOLYGON (((-82.55933 40.78975, -82.55835 ... \n", "2 POLYGON ((-96.84410 32.98891, -96.84403 32.992... \n", "3 POLYGON ((-91.36371 31.78036, -91.35951 31.799... \n", "4 POLYGON ((-80.17834 40.33725, -80.17537 40.338... " ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_cd116_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "9acf6553", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data for Maryland\"s 2nd Congressional District by filtering by the State FIPS code `24` and the Congressional District FIPS code `02` in the GEOID column." ] }, { "cell_type": "code", "execution_count": 25, "id": "9e41ef73", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.GEOID == \"2402\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"2nd Congressional District: Maryland\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "b2ea1246", "metadata": {}, "source": [ "The map created shows Maryland\"s 2nd Congressional District.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Consolidated Cities (CONCITY)\n", "\n", "This file contains data on [Consolidated Cities](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_8). These are areas where one or several other incorporated places in a county or Minor Civil Division are included in a consolidated government but still exist as separate legal entities.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS Code\n", "* CONCTYFP = Consolidated city FIPS code\n", "* CONCTYNS = Consolidated city GNIS code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS and consolidated city FIPS code\n", "* NAME = Consolidated city name\n", "* NAMELSAD = Name and Legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Consolidated City polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Consolidated City data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 26, "id": "948bf82e", "metadata": {}, "outputs": [ { "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", "
STATEFPCONCTYFPCONCTYNSAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
0202841026643571700000US20284102028410Greeley CountyGreeley County unified governmentUG20154246400POLYGON ((-102.04526 38.50540, -102.04526 38.5...
113343624074041700000US13034361303436Athens-Clarke CountyAthens-Clarke County unified governmentUG3087849274688313POLYGON ((-83.53739 33.96591, -83.49824 33.987...
2301139024096511700000US30113903011390Butte-Silver BowButte-Silver Bow0018595682711518178POLYGON ((-113.08552 45.86065, -113.08282 45.8...
3214800319674351700000US21480032148003Louisville/Jefferson CountyLouisville/Jefferson County metro governmentMT98627174043513298POLYGON ((-85.94711 38.00509, -85.94222 38.007...
4094750023783341700000US09475000947500MilfordMilford city255744404410216676POLYGON ((-73.12245 41.18290, -73.12137 41.187...
\n", "
" ], "text/plain": [ " STATEFP CONCTYFP CONCTYNS AFFGEOID GEOID \\\n", "0 20 28410 2664357 1700000US2028410 2028410 \n", "1 13 3436 2407404 1700000US1303436 1303436 \n", "2 30 11390 2409651 1700000US3011390 3011390 \n", "3 21 48003 1967435 1700000US2148003 2148003 \n", "4 09 47500 2378334 1700000US0947500 0947500 \n", "\n", " NAME NAMELSAD \\\n", "0 Greeley County Greeley County unified government \n", "1 Athens-Clarke County Athens-Clarke County unified government \n", "2 Butte-Silver Bow Butte-Silver Bow \n", "3 Louisville/Jefferson County Louisville/Jefferson County metro government \n", "4 Milford Milford city \n", "\n", " LSAD ALAND AWATER \\\n", "0 UG 2015424640 0 \n", "1 UG 308784927 4688313 \n", "2 00 1859568271 1518178 \n", "3 MT 986271740 43513298 \n", "4 25 57444044 10216676 \n", "\n", " geometry \n", "0 POLYGON ((-102.04526 38.50540, -102.04526 38.5... \n", "1 POLYGON ((-83.53739 33.96591, -83.49824 33.987... \n", "2 POLYGON ((-113.08552 45.86065, -113.08282 45.8... \n", "3 POLYGON ((-85.94711 38.00509, -85.94222 38.007... \n", "4 POLYGON ((-73.12245 41.18290, -73.12137 41.187... " ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_concity_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "e81eeeb3", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data for Athens-Clarke County, GA, which is a Consolidated City. Select the data by filtering by the NAME column." ] }, { "cell_type": "code", "execution_count": 27, "id": "5f1c64ab", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"Athens-Clarke County\"].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"Consolidated City: Athens-Clarke County, GA\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "92eb7d93", "metadata": {}, "source": [ "The map created shows Athens-Clarke County, GA.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Counties (COUNTY)\n", "\n", "This file contains data on [Counties and Equivalent Entities](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_12). These are the primary legal divisions of states. Most states use the term \"counties,\" but other terms such as \"Parishes,\" \"Municipios,\" or \"Independent Cities\" may be used. \n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS Code\n", "* COUNTYFP = County FIPS code\n", "* COUNTNS = ANSI feature code for the county\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS and county FIPS code\n", "* NAME = County name\n", "* NAMELSAD = Name and Legal/statistical description\n", "* STUSPS = FIPS State Postal Code\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for County polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Counties and Equivalent Entities data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 28, "id": "b814b4f8", "metadata": {}, "outputs": [ { "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", "
STATEFPCOUNTYFPCOUNTYNSAFFGEOIDGEOIDNAMENAMELSADSTUSPSSTATE_NAMELSADALANDAWATERgeometry
021141005169170500000US2114121141LoganLogan CountyKYKentucky06143022400212479211POLYGON ((-87.06037 36.68085, -87.06002 36.708...
136081009741390500000US3608136081QueensQueens CountyNYNew York06281594050188444349POLYGON ((-73.96262 40.73903, -73.96243 40.739...
234017008822780500000US3401734017HudsonHudson CountyNJNew Jersey0611964082241836491MULTIPOLYGON (((-74.04220 40.69997, -74.03900 ...
334019008822280500000US3401934019HunterdonHunterdon CountyNJNew Jersey06110808628424761598POLYGON ((-75.19511 40.57969, -75.19466 40.581...
421147005169260500000US2114721147McCrearyMcCreary CountyKYKentucky06110541669610730402POLYGON ((-84.77845 36.60329, -84.73068 36.665...
\n", "
" ], "text/plain": [ " STATEFP COUNTYFP COUNTYNS AFFGEOID GEOID NAME \\\n", "0 21 141 00516917 0500000US21141 21141 Logan \n", "1 36 081 00974139 0500000US36081 36081 Queens \n", "2 34 017 00882278 0500000US34017 34017 Hudson \n", "3 34 019 00882228 0500000US34019 34019 Hunterdon \n", "4 21 147 00516926 0500000US21147 21147 McCreary \n", "\n", " NAMELSAD STUSPS STATE_NAME LSAD ALAND AWATER \\\n", "0 Logan County KY Kentucky 06 1430224002 12479211 \n", "1 Queens County NY New York 06 281594050 188444349 \n", "2 Hudson County NJ New Jersey 06 119640822 41836491 \n", "3 Hunterdon County NJ New Jersey 06 1108086284 24761598 \n", "4 McCreary County KY Kentucky 06 1105416696 10730402 \n", "\n", " geometry \n", "0 POLYGON ((-87.06037 36.68085, -87.06002 36.708... \n", "1 POLYGON ((-73.96262 40.73903, -73.96243 40.739... \n", "2 MULTIPOLYGON (((-74.04220 40.69997, -74.03900 ... \n", "3 POLYGON ((-75.19511 40.57969, -75.19466 40.581... \n", "4 POLYGON ((-84.77845 36.60329, -84.73068 36.665... " ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_county_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "2128eb88", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data for counties in Minnesota by filtering by the STATE_NAME column." ] }, { "cell_type": "code", "execution_count": 29, "id": "eb882430", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STATE_NAME == \"Minnesota\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Minnesota: Counties\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "447c0b7e", "metadata": {}, "source": [ "The map created shows Minnesota Counties.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Counties within Congressional Districts: 116th Congress (COUNTY_within_CD116)\n", "\n", "This file contains data on Counties within Congressional Districts.\n", "\n", "The attribute PARTFLG identifies whether all or only part of a County is within a Congressional District:\n", "\n", "* N = All of a County is within a Congressional District\n", "* Y = only part of a county is within a Congressional District\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* COUNTYFP = County FIPS code\n", "* CD116FP = Congressional District FIPS code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS, Congressional District FIPS, and county FIPS code\n", "* PARTFLD = Identifies if all or part of entity is within the file\n", "* ALAND = Current Land Area\n", "* geometry = coordinates for polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Counties within Congressional Districts data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 30, "id": "316b1eb7", "metadata": {}, "outputs": [ { "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", "
STATEFPCOUNTYFPCD116FPAFFGEOIDGEOIDPARTFLGALANDgeometry
00505745101600US05040570504057N1883438547POLYGON ((-93.96945 33.74021, -93.96842 33.741...
15403725101600US54020375402037N542072983POLYGON ((-78.03545 39.27822, -78.03326 39.279...
20217005101600US02001700200170N63990747114POLYGON ((-153.00188 62.72583, -152.99961 62.7...
35401325101600US54020135402013N723253605POLYGON ((-81.27841 38.91487, -81.27417 38.918...
41207725101600US12020771202077N2164099094POLYGON ((-85.15381 30.09285, -85.15185 30.094...
\n", "
" ], "text/plain": [ " STATEFP COUNTYFP CD116FP AFFGEOID GEOID PARTFLG ALAND \\\n", "0 05 057 4 5101600US0504057 0504057 N 1883438547 \n", "1 54 037 2 5101600US5402037 5402037 N 542072983 \n", "2 02 170 0 5101600US0200170 0200170 N 63990747114 \n", "3 54 013 2 5101600US5402013 5402013 N 723253605 \n", "4 12 077 2 5101600US1202077 1202077 N 2164099094 \n", "\n", " geometry \n", "0 POLYGON ((-93.96945 33.74021, -93.96842 33.741... \n", "1 POLYGON ((-78.03545 39.27822, -78.03326 39.279... \n", "2 POLYGON ((-153.00188 62.72583, -152.99961 62.7... \n", "3 POLYGON ((-81.27841 38.91487, -81.27417 38.918... \n", "4 POLYGON ((-85.15381 30.09285, -85.15185 30.094... " ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_county_within_cd116_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "22adb689", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only polygons where only part of the County is within a Congressional District. Select the relevant data by filtering by `\"Y\"` in the PARTFLG column." ] }, { "cell_type": "code", "execution_count": 31, "id": "e60138d7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.PARTFLG == \"Y\"].plot(figsize=(20, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Counties only partially within a Congressional Districts\",\n", " fontdict={\"fontsize\": \"30\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "36fac814", "metadata": {}, "source": [ "The map created shows Counties partially within Congressional Districts.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### County Subdivisions (COUSUB)\n", "\n", "This file contains [County Subdivisions](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_11), which are the primary divisions of counties and equivalent entities. These divisions vary from state to state and include Barrios, Purchases, Townships, and other types of legal and statistical entities. \n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* COUNTYFP = County FIPS code\n", "* COUSUBFP = Subdivision FIPS code\n", "* COUSUBNS = ANSI feature for the subdivision\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS, county FIPS, and county subdivision FIPS\n", "* NAME = Subdivision name\n", "* NAMELSAD = Subdivision name and legal/statistical description\n", "* STUSPS = FIPS State Postal Code\n", "* NAMELSADCO = County name\n", "* STATE_NAME = State Name\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for County Subdivision polygons\n", "\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the County Subdivisions data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 32, "id": "2178f2d4", "metadata": {}, "outputs": [ { "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", "
STATEFPCOUNTYFPCOUSUBFPCOUSUBNSAFFGEOIDGEOIDNAMENAMELSADSTUSPSNAMELSADCOSTATE_NAMELSADALANDAWATERgeometry
04211752960012171180600000US42117529604211752960NelsonNelson townshipPATioga CountyPennsylvania442902081125916POLYGON ((-77.31788 41.97075, -77.31029 41.970...
14610942820012685500600000US46109428204610942820MinnesotaMinnesota townshipSDRoberts CountySouth Dakota441214656943383863POLYGON ((-97.10387 45.90342, -97.10309 45.908...
24608320780012673870600000US46083207804608320780FairviewFairview townSDLincoln CountySouth Dakota432213800POLYGON ((-96.49153 43.22389, -96.48526 43.224...
34700991340024646590600000US470099134047009913408District 8TNBlount CountyTennessee28646087619509512POLYGON ((-83.99881 35.55556, -83.99444 35.558...
44848993435019391690600000US48489934354848993435San PerlitaSan Perlita CCDTXWillacy CountyTexas22739156645483409952MULTIPOLYGON (((-97.25810 26.42544, -97.25596 ...
\n", "
" ], "text/plain": [ " STATEFP COUNTYFP COUSUBFP COUSUBNS AFFGEOID GEOID \\\n", "0 42 117 52960 01217118 0600000US4211752960 4211752960 \n", "1 46 109 42820 01268550 0600000US4610942820 4610942820 \n", "2 46 083 20780 01267387 0600000US4608320780 4608320780 \n", "3 47 009 91340 02464659 0600000US4700991340 4700991340 \n", "4 48 489 93435 01939169 0600000US4848993435 4848993435 \n", "\n", " NAME NAMELSAD STUSPS NAMELSADCO STATE_NAME LSAD \\\n", "0 Nelson Nelson township PA Tioga County Pennsylvania 44 \n", "1 Minnesota Minnesota township SD Roberts County South Dakota 44 \n", "2 Fairview Fairview town SD Lincoln County South Dakota 43 \n", "3 8 District 8 TN Blount County Tennessee 28 \n", "4 San Perlita San Perlita CCD TX Willacy County Texas 22 \n", "\n", " ALAND AWATER geometry \n", "0 29020811 25916 POLYGON ((-77.31788 41.97075, -77.31029 41.970... \n", "1 121465694 3383863 POLYGON ((-97.10387 45.90342, -97.10309 45.908... \n", "2 221380 0 POLYGON ((-96.49153 43.22389, -96.48526 43.224... \n", "3 646087619 509512 POLYGON ((-83.99881 35.55556, -83.99444 35.558... \n", "4 739156645 483409952 MULTIPOLYGON (((-97.25810 26.42544, -97.25596 ... " ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_cousub_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "ad6bd347", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, plot all the subdivisions, townships in this case, in Bergen County, NJ. Select the relevant data by filtering by the NAMELSADCO column." ] }, { "cell_type": "code", "execution_count": 33, "id": "7f2b68e2", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAMELSADCO == \"Bergen County\"].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"County Subdivisions: Bergen County, NJ\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "51f43698", "metadata": {}, "source": [ "The map created shows County Subdivisions in Bergen County, NJ.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Divisions (DIVISION)\n", "\n", "This file contains data on [Divisions](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_10) of the US. This file is similar to the Regions file but contains more divisions and encompasses several states per division.\n", "\n", "The attribute table contains the following information:\n", "\n", "* DIVISIONCE = Number assigned to each division\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = DIVISIONCE\n", "* NAME = Name of division\n", "* NAMELSAD = Division name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Division polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Division data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 34, "id": "14f15693", "metadata": {}, "outputs": [ { "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", "
DIVISIONCEAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
050300000US55South AtlanticSouth Atlantic Division6968712529833886339601557MULTIPOLYGON (((-75.56555 39.51485, -75.56174 ...
130300000US33East North CentralEast North Central Division69629298010339151248789139MULTIPOLYGON (((-82.73447 41.60351, -82.72425 ...
240300000US44West North CentralWest North Central Division69131470001073333034200327MULTIPOLYGON (((-89.59206 47.96668, -89.59147 ...
380300000US88MountainMountain Division69221735293182419266522413POLYGON ((-120.00574 39.22866, -120.00567 39.2...
490300000US99PacificPacific Division692319992840165296172644163MULTIPOLYGON (((-139.51201 59.70289, -139.5095...
\n", "
" ], "text/plain": [ " DIVISIONCE AFFGEOID GEOID NAME \\\n", "0 5 0300000US5 5 South Atlantic \n", "1 3 0300000US3 3 East North Central \n", "2 4 0300000US4 4 West North Central \n", "3 8 0300000US8 8 Mountain \n", "4 9 0300000US9 9 Pacific \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 South Atlantic Division 69 687125298338 86339601557 \n", "1 East North Central Division 69 629298010339 151248789139 \n", "2 West North Central Division 69 1314700010733 33034200327 \n", "3 Mountain Division 69 2217352931824 19266522413 \n", "4 Pacific Division 69 2319992840165 296172644163 \n", "\n", " geometry \n", "0 MULTIPOLYGON (((-75.56555 39.51485, -75.56174 ... \n", "1 MULTIPOLYGON (((-82.73447 41.60351, -82.72425 ... \n", "2 MULTIPOLYGON (((-89.59206 47.96668, -89.59147 ... \n", "3 POLYGON ((-120.00574 39.22866, -120.00567 39.2... \n", "4 MULTIPOLYGON (((-139.51201 59.70289, -139.5095... " ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_division_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "f37be166", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select only data from the Mountain division by filtering by the NAME column." ] }, { "cell_type": "code", "execution_count": 35, "id": "9aa415a3", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"Mountain\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Divisions: Mountain Region\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "e1286f9e", "metadata": {}, "source": [ "The map created shows the Mountain Region Division.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Metropolitan and Micropolitan Statistical Areas and Related Statistical Areas\n", "\n", "[Metropolitan and Micropolitan Statistical Areas and Related Statistical Areas](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_7) is the second grouping of datasets within the census data by cartographic boundaries group. A metropolitan or micropolitan statistical area contains a core area, with a substantial population with adjacent communities having a high degree of economic and social integration with that core. This grouping contains six datasets.\n", "\n", "#### Core Based Statistical Areas (CBSAs)\n", "\n", "This file contains data on [Core Based Statistical Areas (CBSAs)](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_7). This encompasses all metropolitan and micropolitan statistical areas.\n", "\n", "The attribute table contains the following information:\n", "\n", "* CSAFP = Combined statistical area code (if applicable)\n", "* CBSAFP = Metropolitan statistical area/micropolitan statistical area code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = CBSAFP\n", "* NAME = Metropolitan statistical area/micropolitan statistical area name\n", "* NAMELSAD = CBSA name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for CBSA polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the CBSA data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 36, "id": "83a2273d", "metadata": {}, "outputs": [ { "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", "
CSAFPCBSAFPAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
0<NA>11380310M600US1138011380Andrews, TXAndrews, TX Micro AreaM23886850259957039POLYGON ((-103.06470 32.52219, -103.00047 32.5...
119235140310M600US3514035140Newberry, SCNewberry, SC Micro AreaM2163245202244011454POLYGON ((-81.94372 34.20605, -81.94196 34.208...
2<NA>37540310M600US3754037540Paris, TNParis, TN Micro AreaM2145532036281582236POLYGON ((-88.52940 36.17018, -88.52636 36.229...
324629900310M600US2990029900Laurinburg, NCLaurinburg, NC Micro AreaM28265699863842049POLYGON ((-79.69251 34.80685, -79.68822 34.809...
431535460310M600US3546035460Newport, TNNewport, TN Micro AreaM2112958456317932684POLYGON ((-83.31519 35.89332, -83.31078 35.895...
\n", "
" ], "text/plain": [ " CSAFP CBSAFP AFFGEOID GEOID NAME \\\n", "0 11380 310M600US11380 11380 Andrews, TX \n", "1 192 35140 310M600US35140 35140 Newberry, SC \n", "2 37540 310M600US37540 37540 Paris, TN \n", "3 246 29900 310M600US29900 29900 Laurinburg, NC \n", "4 315 35460 310M600US35460 35460 Newport, TN \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 Andrews, TX Micro Area M2 3886850259 957039 \n", "1 Newberry, SC Micro Area M2 1632452022 44011454 \n", "2 Paris, TN Micro Area M2 1455320362 81582236 \n", "3 Laurinburg, NC Micro Area M2 826569986 3842049 \n", "4 Newport, TN Micro Area M2 1129584563 17932684 \n", "\n", " geometry \n", "0 POLYGON ((-103.06470 32.52219, -103.00047 32.5... \n", "1 POLYGON ((-81.94372 34.20605, -81.94196 34.208... \n", "2 POLYGON ((-88.52940 36.17018, -88.52636 36.229... \n", "3 POLYGON ((-79.69251 34.80685, -79.68822 34.809... \n", "4 POLYGON ((-83.31519 35.89332, -83.31078 35.895... " ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_cbsa_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "1ef58096", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select Kahului-Wailuku-Lahaina, HI Metro Area by filtering by the NAME column." ] }, { "cell_type": "code", "execution_count": 37, "id": "447b031a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"Kahului-Wailuku-Lahaina, HI\"].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"Core Based Statistical Area: Kahului-Wailuku-Lahaina, HI Metro Area\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "2fb24449", "metadata": {}, "source": [ "The map created shows the Kahului-Wailuku-Lahaina, HI Metro Area, Core Based Statistical Area.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### Combined Statistical Areas (CSA)\n", "\n", "This file contains data on [Combined Statistical Areas](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_7), which are areas that consist of two or more adjacent CBSAs that have significant employment interchanges.\n", "\n", "The attribute table contains the following information:\n", "\n", "* CSAFP = Combined statistical area code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = CSAFP\n", "* NAME = CSA Name\n", "* NAMELSAD = CSA name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for CSA polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the CSA data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 38, "id": "ce322267", "metadata": {}, "outputs": [ { "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", "
CSAFPAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
0146330M600US146146Bloomsburg-Berwick-Sunbury, PABloomsburg-Berwick-Sunbury, PA CSAM0444403910886464626POLYGON ((-77.36418 40.84694, -77.27924 40.909...
1368330M600US368368Memphis-Forrest City, TN-MS-ARMemphis-Forrest City, TN-MS-AR CSAM013493874541322004792POLYGON ((-91.15230 34.92548, -91.15074 34.968...
2356330M600US356356Macon-Bibb County--Warner Robins, GAMacon-Bibb County--Warner Robins, GA CSAM0582726575249165153POLYGON ((-84.20263 32.69002, -84.19676 32.701...
3290330M600US290290Huntsville-Decatur, ALHuntsville-Decatur, AL CSAM06816635309269975554POLYGON ((-87.53028 34.45756, -87.53011 34.469...
4206330M600US206206Dallas-Fort Worth, TX-OKDallas-Fort Worth, TX-OK CSAM0402344827781682397922POLYGON ((-98.57613 32.57248, -98.57600 32.624...
\n", "
" ], "text/plain": [ " CSAFP AFFGEOID GEOID NAME \\\n", "0 146 330M600US146 146 Bloomsburg-Berwick-Sunbury, PA \n", "1 368 330M600US368 368 Memphis-Forrest City, TN-MS-AR \n", "2 356 330M600US356 356 Macon-Bibb County--Warner Robins, GA \n", "3 290 330M600US290 290 Huntsville-Decatur, AL \n", "4 206 330M600US206 206 Dallas-Fort Worth, TX-OK \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 Bloomsburg-Berwick-Sunbury, PA CSA M0 4444039108 86464626 \n", "1 Memphis-Forrest City, TN-MS-AR CSA M0 13493874541 322004792 \n", "2 Macon-Bibb County--Warner Robins, GA CSA M0 5827265752 49165153 \n", "3 Huntsville-Decatur, AL CSA M0 6816635309 269975554 \n", "4 Dallas-Fort Worth, TX-OK CSA M0 40234482778 1682397922 \n", "\n", " geometry \n", "0 POLYGON ((-77.36418 40.84694, -77.27924 40.909... \n", "1 POLYGON ((-91.15230 34.92548, -91.15074 34.968... \n", "2 POLYGON ((-84.20263 32.69002, -84.19676 32.701... \n", "3 POLYGON ((-87.53028 34.45756, -87.53011 34.469... \n", "4 POLYGON ((-98.57613 32.57248, -98.57600 32.624... " ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_csa_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "df2dff21", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select the San Jose-San Francisco-Oakland CSA by filtering by the NAME column." ] }, { "cell_type": "code", "execution_count": 39, "id": "ea4f7d12", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"San Jose-San Francisco-Oakland, CA\"].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"Combined Statistical Area: San Jose-San Francisco-Oakland, CA\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "9f52d0a7", "metadata": {}, "source": [ "The map created shows the San Jose-San Francisco-Oakland, CA Combined Statistical Area.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### Metropolitan Divisions (METDIV)\n", "\n", "This file contains data on [Metropolitan Divisions](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_7). These areas are groupings of counties or equivalent entities within a metropolitan statistical area with a core of 2.5 million inhabitants and one or more main counties that represent employment centers, plus adjacent counties with commuting ties.\n", "\n", "The attribute table contains the following information:\n", "\n", "* CSAFP = Combined statistical area code\n", "* CBSAFP = Metropolitan statistical area/micropolitan statistical area code\n", "* METDIVFP = Metropolitan division code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of CBSAFP and METDIVFP\n", "* NAME = Metropolitan division name\n", "* NAMELSAD = MetDiv name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Metropolitan Division polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Metropolitan Division data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 40, "id": "3968d531", "metadata": {}, "outputs": [ { "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", "
CSAFPCBSAFPMETDIVFPAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
03483108011244314M600US31080112443108011244Anaheim-Santa Ana-Irvine, CAAnaheim-Santa Ana-Irvine, CA Metro DivisionM32053449483406294114POLYGON ((-118.11442 33.74518, -118.11305 33.7...
11481446014454314M600US14460144541446014454Boston, MABoston, MA Metro DivisionM328823015811411559356MULTIPOLYGON (((-70.88335 42.34049, -70.88158 ...
21481446015764314M600US14460157641446015764Cambridge-Newton-Framingham, MACambridge-Newton-Framingham, MA Metro DivisionM33393859579945476893MULTIPOLYGON (((-70.58029 42.63602, -70.57509 ...
34283798015804314M600US37980158043798015804Camden, NJCamden, NJ Metro DivisionM33477449505108072755POLYGON ((-75.42830 39.78437, -75.42168 39.787...
41761698016984314M600US16980169841698016984Chicago-Naperville-Evanston, ILChicago-Naperville-Evanston, IL Metro DivisionM381069810771895152877POLYGON ((-88.70738 42.49359, -88.67080 42.494...
\n", "
" ], "text/plain": [ " CSAFP CBSAFP METDIVFP AFFGEOID GEOID \\\n", "0 348 31080 11244 314M600US3108011244 3108011244 \n", "1 148 14460 14454 314M600US1446014454 1446014454 \n", "2 148 14460 15764 314M600US1446015764 1446015764 \n", "3 428 37980 15804 314M600US3798015804 3798015804 \n", "4 176 16980 16984 314M600US1698016984 1698016984 \n", "\n", " NAME \\\n", "0 Anaheim-Santa Ana-Irvine, CA \n", "1 Boston, MA \n", "2 Cambridge-Newton-Framingham, MA \n", "3 Camden, NJ \n", "4 Chicago-Naperville-Evanston, IL \n", "\n", " NAMELSAD LSAD ALAND \\\n", "0 Anaheim-Santa Ana-Irvine, CA Metro Division M3 2053449483 \n", "1 Boston, MA Metro Division M3 2882301581 \n", "2 Cambridge-Newton-Framingham, MA Metro Division M3 3393859579 \n", "3 Camden, NJ Metro Division M3 3477449505 \n", "4 Chicago-Naperville-Evanston, IL Metro Division M3 8106981077 \n", "\n", " AWATER geometry \n", "0 406294114 POLYGON ((-118.11442 33.74518, -118.11305 33.7... \n", "1 1411559356 MULTIPOLYGON (((-70.88335 42.34049, -70.88158 ... \n", "2 945476893 MULTIPOLYGON (((-70.58029 42.63602, -70.57509 ... \n", "3 108072755 POLYGON ((-75.42830 39.78437, -75.42168 39.787... \n", "4 1895152877 POLYGON ((-88.70738 42.49359, -88.67080 42.494... " ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_metdiv_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "3d380b0b", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select out Chicago-Naperville-Evanston, IL Metropolitan Divisions by filtering by the NAME column." ] }, { "cell_type": "code", "execution_count": 41, "id": "6889344d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"Chicago-Naperville-Evanston, IL\"].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"Metropolitan Divisions: Chicago-Naperville-Evanston, IL\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "cc7972e9", "metadata": {}, "source": [ "The map created shows Metropolitan Divisions in Illinois and Indiana.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### New England City and Town Areas (NECTA)\n", "\n", "This file contains [New England City and Town Areas](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_7), which encompass metropolitan and micropolitan statistical areas and urban clusters in New England.\n", "\n", "The attribute table contains the following information:\n", "\n", "* CNECTAFP = Combined NECTA code\n", "* NECTAFP = NECTA code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = NECTAFP\n", "* NAME = NECTA name\n", "* NAMELSAD = NECTA name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for New England City and Town Area polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the New England City and Town Areas data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 42, "id": "0345e2c4", "metadata": {}, "outputs": [ { "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", "
CNECTAFPNECTAFPAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
079073300350M600US7330073300Greenfield Town, MAGreenfield Town, MA Micropolitan NECTAM657679079712695651POLYGON ((-72.85766 42.73761, -72.80911 42.736...
172572500350M600US7250072500Claremont, NHClaremont, NH Micropolitan NECTAM62075477662886013POLYGON ((-72.41538 43.38021, -72.41315 43.384...
2NaN73050350M600US7305073050Dover-Durham, NH-MEDover-Durham, NH-ME Metropolitan NECTAM5115377220238371631POLYGON ((-71.24697 43.27619, -71.23601 43.284...
3NaN78500350M600US7850078500Vineyard Haven, MAVineyard Haven, MA Micropolitan NECTAM6233141285675399599MULTIPOLYGON (((-70.83204 41.25950, -70.82983 ...
471574500350M600US7450074500Leominster-Gardner, MALeominster-Gardner, MA Metropolitan NECTAM5102815423865184023POLYGON ((-72.31363 42.39640, -72.31509 42.398...
\n", "
" ], "text/plain": [ " CNECTAFP NECTAFP AFFGEOID GEOID NAME \\\n", "0 790 73300 350M600US73300 73300 Greenfield Town, MA \n", "1 725 72500 350M600US72500 72500 Claremont, NH \n", "2 NaN 73050 350M600US73050 73050 Dover-Durham, NH-ME \n", "3 NaN 78500 350M600US78500 78500 Vineyard Haven, MA \n", "4 715 74500 350M600US74500 74500 Leominster-Gardner, MA \n", "\n", " NAMELSAD LSAD ALAND AWATER \\\n", "0 Greenfield Town, MA Micropolitan NECTA M6 576790797 12695651 \n", "1 Claremont, NH Micropolitan NECTA M6 207547766 2886013 \n", "2 Dover-Durham, NH-ME Metropolitan NECTA M5 1153772202 38371631 \n", "3 Vineyard Haven, MA Micropolitan NECTA M6 233141285 675399599 \n", "4 Leominster-Gardner, MA Metropolitan NECTA M5 1028154238 65184023 \n", "\n", " geometry \n", "0 POLYGON ((-72.85766 42.73761, -72.80911 42.736... \n", "1 POLYGON ((-72.41538 43.38021, -72.41315 43.384... \n", "2 POLYGON ((-71.24697 43.27619, -71.23601 43.284... \n", "3 MULTIPOLYGON (((-70.83204 41.25950, -70.82983 ... \n", "4 POLYGON ((-72.31363 42.39640, -72.31509 42.398... " ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_necta_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "cdbdf054", "metadata": {}, "source": [ "Next, plot all polygons from this parquet file and overlay all of the New England City and Town Areas on a basemap." ] }, { "cell_type": "code", "execution_count": 43, "id": "10c21538", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf.plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"New England City and Town Areas\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "bbd50bb4", "metadata": {}, "source": [ "The map created shows New England City and Town Areas.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### New England City and Town Area Division (NECTADIV)\n", "\n", "This file contains [New England City and Town Areas Divisions](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_7), which are smaller groupings of cities and towns in New England that contain a single core of 2.5 million inhabitants. Each division must have a total population of 100,000 or more.\n", "\n", "The attribute table contains the following information:\n", "\n", "* CNECTAFP = Combined NECTA code\n", "* NECTAFP = NECTA code\n", "* NCTADVFP = NECTA Division code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of NECTA code and NECT division code\n", "* NAME = NECTA Division name\n", "* NAMELSAD = NECTA Division name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for New England City and Town Area Division polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the New England City and Town Areas Divisions data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 44, "id": "acbfb7d1", "metadata": {}, "outputs": [ { "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", "
CNECTAFPNECTAFPNCTADVFPAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
07157165078254355M600US71650782547165078254Taunton-Middleborough-Norton, MATaunton-Middleborough-Norton, MA NECTA DivisionM777761376749344655POLYGON ((-71.25929 41.97422, -71.23516 41.983...
17157165073604355M600US71650736047165073604Haverhill-Newburyport-Amesbury Town, MA-NHHaverhill-Newburyport-Amesbury Town, MA-NH NEC...M793890843256403579POLYGON ((-71.31096 42.93573, -71.30006 42.969...
27157165074204355M600US71650742047165074204Lawrence-Methuen Town-North Andover, MA-NHLawrence-Methuen Town-North Andover, MA-NH NEC...M72078876049753119POLYGON ((-71.28426 42.76011, -71.26375 42.785...
37157165071634355M600US71650716347165071634Boston-Cambridge-Newton, MABoston-Cambridge-Newton, MA NECTA DivisionM72860356873425756189MULTIPOLYGON (((-70.95108 42.28973, -70.94864 ...
47157165072104355M600US71650721047165072104Brockton-Bridgewater Town-Easton, MABrockton-Bridgewater Town-Easton, MA NECTA Div...M73215433807532122POLYGON ((-71.16747 42.06163, -71.14226 42.071...
\n", "
" ], "text/plain": [ " CNECTAFP NECTAFP NCTADVFP AFFGEOID GEOID \\\n", "0 715 71650 78254 355M600US7165078254 7165078254 \n", "1 715 71650 73604 355M600US7165073604 7165073604 \n", "2 715 71650 74204 355M600US7165074204 7165074204 \n", "3 715 71650 71634 355M600US7165071634 7165071634 \n", "4 715 71650 72104 355M600US7165072104 7165072104 \n", "\n", " NAME \\\n", "0 Taunton-Middleborough-Norton, MA \n", "1 Haverhill-Newburyport-Amesbury Town, MA-NH \n", "2 Lawrence-Methuen Town-North Andover, MA-NH \n", "3 Boston-Cambridge-Newton, MA \n", "4 Brockton-Bridgewater Town-Easton, MA \n", "\n", " NAMELSAD LSAD ALAND \\\n", "0 Taunton-Middleborough-Norton, MA NECTA Division M7 777613767 \n", "1 Haverhill-Newburyport-Amesbury Town, MA-NH NEC... M7 938908432 \n", "2 Lawrence-Methuen Town-North Andover, MA-NH NEC... M7 207887604 \n", "3 Boston-Cambridge-Newton, MA NECTA Division M7 2860356873 \n", "4 Brockton-Bridgewater Town-Easton, MA NECTA Div... M7 321543380 \n", "\n", " AWATER geometry \n", "0 49344655 POLYGON ((-71.25929 41.97422, -71.23516 41.983... \n", "1 56403579 POLYGON ((-71.31096 42.93573, -71.30006 42.969... \n", "2 9753119 POLYGON ((-71.28426 42.76011, -71.26375 42.785... \n", "3 425756189 MULTIPOLYGON (((-70.95108 42.28973, -70.94864 ... \n", "4 7532122 POLYGON ((-71.16747 42.06163, -71.14226 42.071... " ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_nectadiv_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "8526c364", "metadata": {}, "source": [ "Next, plot all polygons from this parquet file and overlay all of the New England City and Town Area Divisions on a basemap." ] }, { "cell_type": "code", "execution_count": 45, "id": "b2d14356", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf.plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"New England City and Town Area Divisions\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "251efae3", "metadata": {}, "source": [ "The map created shows New England City and Town Area Divisions.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### Combined New England City and Town Areas (CNECTA)\n", "\n", "This file contains data on [Combined New England City and Town Areas](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_7), consisting of two or more adjacent NECTAs that have significant employment interchanges.\n", "\n", "The attribute table contains the following information:\n", "\n", "* CNECTAFP = Combined NECTA code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = CNECTA\n", "* NAME = Combined NECTA name\n", "* NAMELSAD = Combined NECTA name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Combined New England City and Town Area polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Combined New England City and Town Areas data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 46, "id": "2c39b796", "metadata": {}, "outputs": [ { "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", "
CNECTAFPAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
0710335M600US710710Augusta-Waterville, MEAugusta-Waterville, ME Combined NECTAM42155041281183932221POLYGON ((-70.04529 44.49481, -70.04230 44.494...
1715335M600US715715Boston-Worcester-Providence, MA-RI-NH-CT-MEBoston-Worcester-Providence, MA-RI-NH-CT-ME Co...M4214191437553004992276MULTIPOLYGON (((-70.58029 42.63602, -70.57509 ...
2720335M600US720720Bridgeport-New Haven-Stamford, CTBridgeport-New Haven-Stamford, CT Combined NECTAM43939856869374600689MULTIPOLYGON (((-72.76143 41.24233, -72.75973 ...
3725335M600US725725Lebanon-Claremont, NH-VTLebanon-Claremont, NH-VT Combined NECTAM4303242236758164272POLYGON ((-72.64469 43.79013, -72.62226 43.817...
4770335M600US770770Pittsfield-North Adams, MA-VTPittsfield-North Adams, MA-VT Combined NECTAM4152438884224505481POLYGON ((-73.40063 42.37903, -73.39156 42.403...
\n", "
" ], "text/plain": [ " CNECTAFP AFFGEOID GEOID NAME \\\n", "0 710 335M600US710 710 Augusta-Waterville, ME \n", "1 715 335M600US715 715 Boston-Worcester-Providence, MA-RI-NH-CT-ME \n", "2 720 335M600US720 720 Bridgeport-New Haven-Stamford, CT \n", "3 725 335M600US725 725 Lebanon-Claremont, NH-VT \n", "4 770 335M600US770 770 Pittsfield-North Adams, MA-VT \n", "\n", " NAMELSAD LSAD ALAND \\\n", "0 Augusta-Waterville, ME Combined NECTA M4 2155041281 \n", "1 Boston-Worcester-Providence, MA-RI-NH-CT-ME Co... M4 21419143755 \n", "2 Bridgeport-New Haven-Stamford, CT Combined NECTA M4 3939856869 \n", "3 Lebanon-Claremont, NH-VT Combined NECTA M4 3032422367 \n", "4 Pittsfield-North Adams, MA-VT Combined NECTA M4 1524388842 \n", "\n", " AWATER geometry \n", "0 183932221 POLYGON ((-70.04529 44.49481, -70.04230 44.494... \n", "1 3004992276 MULTIPOLYGON (((-70.58029 42.63602, -70.57509 ... \n", "2 374600689 MULTIPOLYGON (((-72.76143 41.24233, -72.75973 ... \n", "3 58164272 POLYGON ((-72.64469 43.79013, -72.62226 43.817... \n", "4 24505481 POLYGON ((-73.40063 42.37903, -73.39156 42.403... " ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_cnecta_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "1685ee39", "metadata": {}, "source": [ "Next, plot all polygons from this parquet file and overlay all of the Combined New England City and Town Areas on a basemap." ] }, { "cell_type": "code", "execution_count": 47, "id": "5fa981fa", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf.plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Combined New England City and Town Areas\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "87a35a52", "metadata": {}, "source": [ "The map created shows Combined New England City and Town Areas.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Places (PLACE)\n", "\n", "This file contains [Places](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_14) which are Incorporated Places (legal entities) and Census Designated Places (CDPs, statistical entities). An incorporated place usually is a city, town, village, or borough but can have other legal descriptions. CDPs are settled concentrations of population that are identifiable by name but are not legally incorporated.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* PLACEFP = Place FIPS code\n", "* PLACENS = Place GNIS code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS code and Place FIPS code\n", "* NAME = Place name\n", "* NAMELSAD = Place name and legal/statistical description\n", "* STUSPS = FIPS Postal code\n", "* STATE_NAME = State name\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Place polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Places data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 48, "id": "e2e16cda", "metadata": {}, "outputs": [ { "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", "
STATEFPPLACEFPPLACENSAFFGEOIDGEOIDNAMENAMELSADSTUSPSSTATE_NAMELSADALANDAWATERgeometry
0122857524037911600000US12285751228575HamptonHampton cityFLFlorida2527286570POLYGON ((-82.15433 29.86419, -82.14682 29.864...
11262524051311600000US12006251200625AlfordAlford townFLFlorida43273153449685POLYGON ((-85.40333 30.70450, -85.39543 30.704...
2122605024065761600000US12260501226050Glen RidgeGlen Ridge townFLFlorida4344266854824POLYGON ((-80.08267 26.67634, -80.07902 26.676...
3136900024054291600000US13690001369000SavannahSavannah cityGAGeorgia2527673065112329738MULTIPOLYGON (((-81.23851 32.06725, -81.21279 ...
4136728424046511600000US13672841367284RoswellRoswell cityGAGeorgia251054611273308483POLYGON ((-84.41903 34.06118, -84.41903 34.061...
\n", "
" ], "text/plain": [ " STATEFP PLACEFP PLACENS AFFGEOID GEOID NAME \\\n", "0 12 28575 2403791 1600000US1228575 1228575 Hampton \n", "1 12 625 2405131 1600000US1200625 1200625 Alford \n", "2 12 26050 2406576 1600000US1226050 1226050 Glen Ridge \n", "3 13 69000 2405429 1600000US1369000 1369000 Savannah \n", "4 13 67284 2404651 1600000US1367284 1367284 Roswell \n", "\n", " NAMELSAD STUSPS STATE_NAME LSAD ALAND AWATER \\\n", "0 Hampton city FL Florida 25 2728657 0 \n", "1 Alford town FL Florida 43 2731534 49685 \n", "2 Glen Ridge town FL Florida 43 442668 54824 \n", "3 Savannah city GA Georgia 25 276730651 12329738 \n", "4 Roswell city GA Georgia 25 105461127 3308483 \n", "\n", " geometry \n", "0 POLYGON ((-82.15433 29.86419, -82.14682 29.864... \n", "1 POLYGON ((-85.40333 30.70450, -85.39543 30.704... \n", "2 POLYGON ((-80.08267 26.67634, -80.07902 26.676... \n", "3 MULTIPOLYGON (((-81.23851 32.06725, -81.21279 ... \n", "4 POLYGON ((-84.41903 34.06118, -84.41903 34.061... " ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_place_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "6ba97d70", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select all the Places in Washington State by filtering by `\"WA\"` in the STUSPS column." ] }, { "cell_type": "code", "execution_count": 49, "id": "0204a153", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STUSPS == \"WA\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Places: Washington State\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "0a124d69", "metadata": {}, "source": [ "The map created shows Places in Washington State.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Regions (REGION)\n", "\n", "This file contains [Regions](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_10) of the US and encompasses several states per division.\n", "\n", "The attribute table contains the following information:\n", "\n", "* REGIONCE = Number assigned to each Region\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = REGIONCE\n", "* NAME = Name of region\n", "* NAMELSAD = Region name and legal/statistical description\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Region polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Regions data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 50, "id": "7bccb527", "metadata": {}, "outputs": [ { "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", "
REGIONCEAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
030200000US33SouthSouth Region682249827294436148750821211MULTIPOLYGON (((-89.34216 30.05917, -89.33606 ...
120200000US22MidwestMidwest Region681943998021072184282989466MULTIPOLYGON (((-82.73447 41.60351, -82.72425 ...
240200000US44WestWest Region684537345771989315439166576MULTIPOLYGON (((-147.46941 60.92206, -147.4682...
310200000US11NortheastNortheast Region6841935566154950259697277MULTIPOLYGON (((-67.32260 44.61160, -67.32174 ...
\n", "
" ], "text/plain": [ " REGIONCE AFFGEOID GEOID NAME NAMELSAD LSAD \\\n", "0 3 0200000US3 3 South South Region 68 \n", "1 2 0200000US2 2 Midwest Midwest Region 68 \n", "2 4 0200000US4 4 West West Region 68 \n", "3 1 0200000US1 1 Northeast Northeast Region 68 \n", "\n", " ALAND AWATER \\\n", "0 2249827294436 148750821211 \n", "1 1943998021072 184282989466 \n", "2 4537345771989 315439166576 \n", "3 419355661549 50259697277 \n", "\n", " geometry \n", "0 MULTIPOLYGON (((-89.34216 30.05917, -89.33606 ... \n", "1 MULTIPOLYGON (((-82.73447 41.60351, -82.72425 ... \n", "2 MULTIPOLYGON (((-147.46941 60.92206, -147.4682... \n", "3 MULTIPOLYGON (((-67.32260 44.61160, -67.32174 ... " ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_region_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "238c9abb", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select the entire South Region by filtering by the NAME column." ] }, { "cell_type": "code", "execution_count": 51, "id": "8f57198c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"South\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"South Region\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "1955567e", "metadata": {}, "source": [ "The map created shows the South Region.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### School Districts \n", "\n", "[School Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_23) is the third grouping of datasets within the census data by cartographic boundaries group. This dataset grouping includes district boundaries for Elementary School Districts, Secondary School Districts, and Unified School Districts.\n", "\n", "#### School Districts - Elementary (ELSD)\n", "\n", "This file contains [Elementary School Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_23), referring to districts with elementary schools.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* ELSDLEA = Elementary School District local education agency code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS code and ELSDLEA code\n", "* NAME = Elementary School District name\n", "* STUSPS = FIPS Postal code\n", "* STATE_NAME = State name\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Elementary School District polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Elementary School Districts data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 52, "id": "cf3e3cc4", "metadata": {}, "outputs": [ { "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", "
STATEFPELSDLEAAFFGEOIDGEOIDNAMESTUSPSSTATE_NAMELSADALANDAWATERgeometry
017425709500000US17425701742570Willow Springs School District 108ILIllinois00245659162685308POLYGON ((-87.91426 41.71660, -87.90923 41.719...
14044709500000US40044704004470Bishop Public SchoolOKOklahoma00189366310POLYGON ((-98.44840 34.59449, -98.43973 34.594...
21787909500000US17087901708790Cass School District 63ILIllinois0011006857329296POLYGON ((-88.00218 41.72823, -88.00230 41.729...
33455209500000US34055203405520Franklin Township School DistrictNJNew Jersey0060657041232602POLYGON ((-75.10323 40.71943, -75.06000 40.753...
417171609500000US17171601717160Gower School District 62ILIllinois0013484773437292POLYGON ((-87.96002 41.75215, -87.95929 41.752...
\n", "
" ], "text/plain": [ " STATEFP ELSDLEA AFFGEOID GEOID \\\n", "0 17 42570 9500000US1742570 1742570 \n", "1 40 4470 9500000US4004470 4004470 \n", "2 17 8790 9500000US1708790 1708790 \n", "3 34 5520 9500000US3405520 3405520 \n", "4 17 17160 9500000US1717160 1717160 \n", "\n", " NAME STUSPS STATE_NAME LSAD ALAND \\\n", "0 Willow Springs School District 108 IL Illinois 00 24565916 \n", "1 Bishop Public School OK Oklahoma 00 18936631 \n", "2 Cass School District 63 IL Illinois 00 11006857 \n", "3 Franklin Township School District NJ New Jersey 00 60657041 \n", "4 Gower School District 62 IL Illinois 00 13484773 \n", "\n", " AWATER geometry \n", "0 2685308 POLYGON ((-87.91426 41.71660, -87.90923 41.719... \n", "1 0 POLYGON ((-98.44840 34.59449, -98.43973 34.594... \n", "2 329296 POLYGON ((-88.00218 41.72823, -88.00230 41.729... \n", "3 232602 POLYGON ((-75.10323 40.71943, -75.06000 40.753... \n", "4 437292 POLYGON ((-87.96002 41.75215, -87.95929 41.752... " ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_elsd_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "572dc529", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select all the Elementary School Districts in Montana by filtering by `\"MT\"` in the STUSPS column." ] }, { "cell_type": "code", "execution_count": 53, "id": "2877414b", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STUSPS == \"MT\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Montana Elementary School Districts\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "c23c6bd7", "metadata": {}, "source": [ "The map created shows the Montana Elementary School Districts.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### School Districts - Secondary (SCSD)\n", "\n", "This file contains [Secondary School Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_23), referring to districts with secondary schools.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* SCDLEA = Secondary School District local education agency code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS code and SCSDLEA code\n", "* NAME = Secondary School District name\n", "* STUSPS = FIPS Postal code. STATE_NAME = State name\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = Coordinates for Secondary School District polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Secondary School Districts data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 54, "id": "bdb95310", "metadata": {}, "outputs": [ { "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", "
STATEFPSCSDLEAAFFGEOIDGEOIDNAMESTUSPSSTATE_NAMELSADALANDAWATERgeometry
006990049600000US06990040699004Sierra Unified School District (9-12)CACalifornia00295062917463592439POLYGON ((-119.40472 37.09651, -119.39820 37.0...
117990019600000US17990011799001Bluford Unit School District 318 (9-12) in Far...ILIllinois0099593597219159POLYGON ((-88.81637 38.38809, -88.81180 38.388...
217337209600000US17337201733720Ridgewood Community High School District 234ILIllinois0069486690POLYGON ((-87.84656 41.96914, -87.84654 41.971...
306216009600000US06216000621600Liberty Union High School DistrictCACalifornia0050499199361858554POLYGON ((-121.83236 37.93557, -121.83236 37.9...
406251509600000US06251500625150Modesto City High School DistrictCACalifornia004301365263637374POLYGON ((-121.24123 37.66425, -121.24003 37.6...
\n", "
" ], "text/plain": [ " STATEFP SCSDLEA AFFGEOID GEOID \\\n", "0 06 99004 9600000US0699004 0699004 \n", "1 17 99001 9600000US1799001 1799001 \n", "2 17 33720 9600000US1733720 1733720 \n", "3 06 21600 9600000US0621600 0621600 \n", "4 06 25150 9600000US0625150 0625150 \n", "\n", " NAME STUSPS STATE_NAME LSAD \\\n", "0 Sierra Unified School District (9-12) CA California 00 \n", "1 Bluford Unit School District 318 (9-12) in Far... IL Illinois 00 \n", "2 Ridgewood Community High School District 234 IL Illinois 00 \n", "3 Liberty Union High School District CA California 00 \n", "4 Modesto City High School District CA California 00 \n", "\n", " ALAND AWATER geometry \n", "0 2950629174 63592439 POLYGON ((-119.40472 37.09651, -119.39820 37.0... \n", "1 99593597 219159 POLYGON ((-88.81637 38.38809, -88.81180 38.388... \n", "2 6948669 0 POLYGON ((-87.84656 41.96914, -87.84654 41.971... \n", "3 504991993 61858554 POLYGON ((-121.83236 37.93557, -121.83236 37.9... \n", "4 430136526 3637374 POLYGON ((-121.24123 37.66425, -121.24003 37.6... " ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_scsd_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "0c23c7b1", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select all the Secondary School Districts in Arizona by filtering by `\"AZ\"` in the STUSPS column." ] }, { "cell_type": "code", "execution_count": 55, "id": "77bb0834", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STUSPS == \"AZ\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Arizona Secondary School Districts\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "0a723a9c", "metadata": {}, "source": [ "The map created shows the Arizona Secondary School Districts.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### School Districts - Unified (UNSD)\n", "\n", "This file contains [Unified School Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_23), referring to districts that provide education to children of all school ages. Unified school districts can have both secondary and elementary schools.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* UNSDLEA = Unified School District local education agency code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS code and UNSDLEA code\n", "* NAME = Unified School District name\n", "* STUSPS = FIPS Postal code\n", "* STATE_NAME = State name\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = Coordinates for Unified School District polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Unified School Districts data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 56, "id": "cc64d5bb", "metadata": {}, "outputs": [ { "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", "
STATEFPUNSDLEAAFFGEOIDGEOIDNAMESTUSPSSTATE_NAMELSADALANDAWATERgeometry
036182109700000US36182103618210Malverne Union Free School DistrictNYNew York005271104539214POLYGON ((-73.67603 40.67130, -73.67428 40.672...
129216609700000US29216602921660Northeast Nodaway County R-V School DistrictMOMissouri0029219932669164POLYGON ((-94.78484 40.37451, -94.77798 40.373...
22999309700000US29099302909930Blair Oaks R-II School DistrictMOMissouri001819828565337193POLYGON ((-92.25955 38.37702, -92.25574 38.381...
329115509700000US29115502911550Cole County R-V School DistrictMOMissouri003682952883182437POLYGON ((-92.46801 38.31442, -92.46697 38.327...
45124909700000US51024905102490Middlesex County Public SchoolsVAVirginia00337554148208310589MULTIPOLYGON (((-76.42081 37.59787, -76.41957 ...
\n", "
" ], "text/plain": [ " STATEFP UNSDLEA AFFGEOID GEOID \\\n", "0 36 18210 9700000US3618210 3618210 \n", "1 29 21660 9700000US2921660 2921660 \n", "2 29 9930 9700000US2909930 2909930 \n", "3 29 11550 9700000US2911550 2911550 \n", "4 51 2490 9700000US5102490 5102490 \n", "\n", " NAME STUSPS STATE_NAME LSAD \\\n", "0 Malverne Union Free School District NY New York 00 \n", "1 Northeast Nodaway County R-V School District MO Missouri 00 \n", "2 Blair Oaks R-II School District MO Missouri 00 \n", "3 Cole County R-V School District MO Missouri 00 \n", "4 Middlesex County Public Schools VA Virginia 00 \n", "\n", " ALAND AWATER geometry \n", "0 5271104 539214 POLYGON ((-73.67603 40.67130, -73.67428 40.672... \n", "1 292199326 69164 POLYGON ((-94.78484 40.37451, -94.77798 40.373... \n", "2 181982856 5337193 POLYGON ((-92.25955 38.37702, -92.25574 38.381... \n", "3 368295288 3182437 POLYGON ((-92.46801 38.31442, -92.46697 38.327... \n", "4 337554148 208310589 MULTIPOLYGON (((-76.42081 37.59787, -76.41957 ... " ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_unsd_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "3f34d70b", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, select the entire New York City Unified School District, which encompasses the five counties of NYC. Select the relevant data by filtering by the NAME column." ] }, { "cell_type": "code", "execution_count": 57, "id": "680d0c72", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME == \"New York City Department Of Education\"].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"New York City Unified School District\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "0e431844", "metadata": {}, "source": [ "The map created shows the New York City Unified School District.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### State Legislative Districts\n", "\n", "[State Legislative Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_24) is the fourth grouping of datasets within the census data by cartographic boundaries group.\n", "This dataset grouping includes State Legislative Districts for both Upper and Lower State Chambers. These are areas in which voters elect a person to represent them in state or equivalent entity legislatures. Most states have both upper and lower chambers, the exceptions being Nebraska which has a unicameral legislature, and Washington, DC, which has a single council. As a result, there is no lower house data for Nebraska and DC.\n", "\n", "#### State Legislative Districts - Lower Chamber (SLDL)\n", "\n", "\n", "\n", "This file contains [Lower Chamber State Legislative Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_24).\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* SLDLST = State Legislative District Lower Chamber code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS code and SLDLST\n", "* NAME = District Name\n", "* NAMELSAD = District name and legal/statistical description\n", "* STUSPS = FIPS Postal code\n", "* STATE_NAME = State name\n", "* LSAD = Legal/statistical classification\n", "* LSY = Legislative Session Year\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Lower Chamber polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Lower Chamber State Legislative Districts data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 58, "id": "0f2ba2ef", "metadata": {}, "outputs": [ { "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", "
STATEFPSLDLSTAFFGEOIDGEOIDNAMENAMELSADSTUSPSSTATE_NAMELSADLSYALANDAWATERgeometry
037067620L600US370673706767State House District 67NCNorth CarolinaLL2018137248184513054913POLYGON ((-80.67249 35.28457, -80.66859 35.284...
137023620L600US370233702323State House District 23NCNorth CarolinaLL201824981127014460107POLYGON ((-77.82844 35.86721, -77.82613 35.871...
239078620L600US390783907878State House District 78OHOhioLL2018360997594228657516POLYGON ((-83.01738 39.73643, -83.01428 39.738...
341026620L600US410264102626State House District 26OROregonLL20182090518981046849POLYGON ((-122.95072 45.44942, -122.94726 45.4...
441015620L600US410154101515State House District 15OROregonLL20185173430898286102POLYGON ((-123.26079 44.55749, -123.26025 44.5...
\n", "
" ], "text/plain": [ " STATEFP SLDLST AFFGEOID GEOID NAME NAMELSAD STUSPS \\\n", "0 37 067 620L600US37067 37067 67 State House District 67 NC \n", "1 37 023 620L600US37023 37023 23 State House District 23 NC \n", "2 39 078 620L600US39078 39078 78 State House District 78 OH \n", "3 41 026 620L600US41026 41026 26 State House District 26 OR \n", "4 41 015 620L600US41015 41015 15 State House District 15 OR \n", "\n", " STATE_NAME LSAD LSY ALAND AWATER \\\n", "0 North Carolina LL 2018 1372481845 13054913 \n", "1 North Carolina LL 2018 2498112701 4460107 \n", "2 Ohio LL 2018 3609975942 28657516 \n", "3 Oregon LL 2018 209051898 1046849 \n", "4 Oregon LL 2018 517343089 8286102 \n", "\n", " geometry \n", "0 POLYGON ((-80.67249 35.28457, -80.66859 35.284... \n", "1 POLYGON ((-77.82844 35.86721, -77.82613 35.871... \n", "2 POLYGON ((-83.01738 39.73643, -83.01428 39.738... \n", "3 POLYGON ((-122.95072 45.44942, -122.94726 45.4... \n", "4 POLYGON ((-123.26079 44.55749, -123.26025 44.5... " ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_sldl_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "5e7bce31", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, plot all the Lower Chamber State Legislative Districts in Texas by filtering by `\"TX\"` in the STUSPS column." ] }, { "cell_type": "code", "execution_count": 59, "id": "1f1efc89", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STUSPS == \"TX\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"State Legislative Districts: Texas, Lower Chamber\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "6290c0fb", "metadata": {}, "source": [ "The map created shows the Texas Lower Chamber State Legislative Districts.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "#### State Legislative Districts - Upper Chamber (SLDU)\n", "\n", "This file contains [Upper Chamber State Legislative Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_24).\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* SLDUST = State Legislative District Upper Chamber code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS code and SLDUST\n", "* NAME = District Name\n", "* NAMELSAD = District name and legal/statistical description\n", "* STUSPS = FIPS Postal code\n", "* STATE_NAME = State name\n", "* LSAD = Legal/statistical classification\n", "* LSY = Legislative Session Year\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Upper Chamber polygon\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Upper Chamber State Legislative Districts data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 60, "id": "6deca758", "metadata": {}, "outputs": [ { "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", "
STATEFPSLDUSTAFFGEOIDGEOIDNAMENAMELSADSTUSPSSTATE_NAMELSADLSYALANDAWATERgeometry
041004610U600US41004410044State Senate District 4OROregonLU201816139528745167874360POLYGON ((-123.81715 43.45959, -123.81666 43.5...
141015610U600US410154101515State Senate District 15OROregonLU2018238454422423501POLYGON ((-123.15350 45.53457, -123.15271 45.5...
242016610U600US420164201616State Senate District 16PAPennsylvaniaLU20187964582505947856POLYGON ((-75.88921 40.67834, -75.85481 40.693...
348015610U600US480154801515State Senate District 15TXTexasLU201882873451437403360POLYGON ((-95.57473 29.86719, -95.56919 29.867...
451016610U600US510165101616State Senate District 16VAVirginiaLU201858053595732576935POLYGON ((-77.59806 37.23679, -77.59600 37.238...
\n", "
" ], "text/plain": [ " STATEFP SLDUST AFFGEOID GEOID NAME NAMELSAD STUSPS \\\n", "0 41 004 610U600US41004 41004 4 State Senate District 4 OR \n", "1 41 015 610U600US41015 41015 15 State Senate District 15 OR \n", "2 42 016 610U600US42016 42016 16 State Senate District 16 PA \n", "3 48 015 610U600US48015 48015 15 State Senate District 15 TX \n", "4 51 016 610U600US51016 51016 16 State Senate District 16 VA \n", "\n", " STATE_NAME LSAD LSY ALAND AWATER \\\n", "0 Oregon LU 2018 16139528745 167874360 \n", "1 Oregon LU 2018 238454422 423501 \n", "2 Pennsylvania LU 2018 796458250 5947856 \n", "3 Texas LU 2018 828734514 37403360 \n", "4 Virginia LU 2018 580535957 32576935 \n", "\n", " geometry \n", "0 POLYGON ((-123.81715 43.45959, -123.81666 43.5... \n", "1 POLYGON ((-123.15350 45.53457, -123.15271 45.5... \n", "2 POLYGON ((-75.88921 40.67834, -75.85481 40.693... \n", "3 POLYGON ((-95.57473 29.86719, -95.56919 29.867... \n", "4 POLYGON ((-77.59806 37.23679, -77.59600 37.238... " ] }, "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_sldu_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "24a682ea", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, plot all the Upper Chamber State Legislative Districts in Michigan by filtering by `\"MI\"` in the STUSPS column." ] }, { "cell_type": "code", "execution_count": 61, "id": "75b59748", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.STUSPS == \"MI\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"State Legislative Districts: Michigan, Upper Chamber\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "7c65ccf4", "metadata": {}, "source": [ "The map created shows the Michigan Upper Chamber State Legislative Districts.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### States (STATE)\n", "\n", "This file contains the [US States and State Equivalent Entities](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_25). Within Census Bureau datasets, the District of Columbia, Puerto Rico, and the Island Areas (American Samoa, the Commonwealth of the Northern Mariana Islands, Guam, and the US Virgin Islands) are treated as statistical equivalents of states alongside the 50 US states.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* STATENS = State ANSI feature code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = STATEFP\n", "* STUSPS = FIPS postal code\n", "* NAME = State name\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for State polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the US States and State Equivalent Entities data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 62, "id": "efcce466", "metadata": {}, "outputs": [ { "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", "
STATEFPSTATENSAFFGEOIDGEOIDSTUSPSNAMELSADALANDAWATERgeometry
06618027050400000US6666GUGuam00543555847934337453MULTIPOLYGON (((144.64538 13.23627, 144.64716 ...
14817798010400000US4848TXTexas0067668058891418979352230MULTIPOLYGON (((-94.71830 29.72885, -94.71721 ...
25517798060400000US5555WIWisconsin0014029224668429343721650MULTIPOLYGON (((-86.95617 45.35549, -86.95463 ...
34412198350400000US4444RIRhode Island0026777592191323691129MULTIPOLYGON (((-71.28802 41.64558, -71.28647 ...
43617797960400000US3636NYNew York0012204952086119256750161MULTIPOLYGON (((-72.03683 41.24984, -72.03496 ...
\n", "
" ], "text/plain": [ " STATEFP STATENS AFFGEOID GEOID STUSPS NAME LSAD ALAND \\\n", "0 66 1802705 0400000US66 66 GU Guam 00 543555847 \n", "1 48 1779801 0400000US48 48 TX Texas 00 676680588914 \n", "2 55 1779806 0400000US55 55 WI Wisconsin 00 140292246684 \n", "3 44 1219835 0400000US44 44 RI Rhode Island 00 2677759219 \n", "4 36 1779796 0400000US36 36 NY New York 00 122049520861 \n", "\n", " AWATER geometry \n", "0 934337453 MULTIPOLYGON (((144.64538 13.23627, 144.64716 ... \n", "1 18979352230 MULTIPOLYGON (((-94.71830 29.72885, -94.71721 ... \n", "2 29343721650 MULTIPOLYGON (((-86.95617 45.35549, -86.95463 ... \n", "3 1323691129 MULTIPOLYGON (((-71.28802 41.64558, -71.28647 ... \n", "4 19256750161 MULTIPOLYGON (((-72.03683 41.24984, -72.03496 ... " ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_state_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "91558478", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, plot only the contiguous US, Puerto Rico, and the US Virgin Islands. To exclude parts of the dataset from plotting, use `~df.STATEFP.isin()` to exclude the STATEFP codes for Alaska, Hawaii, Guam, American Samoa, and the Commonwealth of the Northern Mariana Islands." ] }, { "cell_type": "code", "execution_count": 63, "id": "2ab8d3e1", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[~ddf.STATEFP.isin([\"02\", \"15\", \"60\", \"66\", \"69\"])].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"States: Contiguous US, Puerto Rico, & USVI\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "f703c692", "metadata": {}, "source": [ "The map created shows the Contiguous US, Puerto Rico, and the US Virgin Islands.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Subbarrios (SUBBARRIO)\n", "\n", "This file contains [Subbarrios](https://www.census.gov/programs-surveys/geography/about/glossary.html#pr), which are legally defined subdivisions of Minor Civil Division in Puerto Rico. They don\"t exist within every Minor Civil Division and don\"t always cover the entire Minor Civil Division where they do exist.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP = State FIPS code\n", "* COUNTYFP = County FIPS code\n", "* COUSUBFP = County Subdivision FIPS code\n", "* SUBMCDFP = Subbarrio FIPS code\n", "* SUBMCDNS = Subbarrio ANSI feature code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* GEOID = Concatenation of State FIPS code, County FIPS code, County Subdivision FIPS code and Subbarrio FIPS code\n", "* NAME = Subbarrio name\n", "* NAMELSAD = Subbarrio name and legal/statistical division\n", "* LSAD = Legal/statistical classification\n", "* ALAND = Current land area\n", "* AWATER = Current water area\n", "* geometry = coordinates for Subbarrio polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Subbarrios data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 64, "id": "0c1dce9b", "metadata": {}, "outputs": [ { "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", "
STATEFPCOUNTYFPCOUSUBFPSUBMCDFPSUBMCDNSAFFGEOIDGEOIDNAMENAMELSADLSADALANDAWATERgeometry
072035155376504024158420670000US720351553765040720351553765040Pueblo SurPueblo Sur subbarrio512708525517POLYGON ((-66.18201 18.11012, -66.18182 18.110...
172127840798477124160870670000US721278407984771721278407984771ValenciaValencia subbarrio511440730POLYGON ((-66.04345 18.41148, -66.04334 18.411...
272127796933477024154990670000US721277969334770721277969334770HipódromoHipódromo subbarrio512637880POLYGON ((-66.07415 18.44463, -66.07115 18.448...
372013034117232524159530670000US720130341172325720130341172325RosarioRosario subbarrio515833212520POLYGON ((-66.71531 18.47233, -66.71231 18.472...
472121735876480524158260670000US721217358764805721217358764805Pueblo NortePueblo Norte subbarrio511205490POLYGON ((-66.96232 18.07969, -66.96186 18.080...
\n", "
" ], "text/plain": [ " STATEFP COUNTYFP COUSUBFP SUBMCDFP SUBMCDNS AFFGEOID \\\n", "0 72 035 15537 65040 2415842 0670000US720351553765040 \n", "1 72 127 84079 84771 2416087 0670000US721278407984771 \n", "2 72 127 79693 34770 2415499 0670000US721277969334770 \n", "3 72 013 03411 72325 2415953 0670000US720130341172325 \n", "4 72 121 73587 64805 2415826 0670000US721217358764805 \n", "\n", " GEOID NAME NAMELSAD LSAD ALAND \\\n", "0 720351553765040 Pueblo Sur Pueblo Sur subbarrio 51 2708525 \n", "1 721278407984771 Valencia Valencia subbarrio 51 144073 \n", "2 721277969334770 Hipódromo Hipódromo subbarrio 51 263788 \n", "3 720130341172325 Rosario Rosario subbarrio 51 58332 \n", "4 721217358764805 Pueblo Norte Pueblo Norte subbarrio 51 120549 \n", "\n", " AWATER geometry \n", "0 517 POLYGON ((-66.18201 18.11012, -66.18182 18.110... \n", "1 0 POLYGON ((-66.04345 18.41148, -66.04334 18.411... \n", "2 0 POLYGON ((-66.07415 18.44463, -66.07115 18.448... \n", "3 12520 POLYGON ((-66.71531 18.47233, -66.71231 18.472... \n", "4 0 POLYGON ((-66.96232 18.07969, -66.96186 18.080... " ] }, "execution_count": 64, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_72_subbarrio_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "b5ca2686", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, plot all the Subbarrios in the San Juan Municipo (the county equivalent for Puerto Rico). Select the relevant data by filtering by the COUNTYFP column." ] }, { "cell_type": "code", "execution_count": 65, "id": "2ca3f29c", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.COUNTYFP == \"127\"].plot(figsize=(10, 10), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"Subbarrios: San Juan, Puerto Rico\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "2bda7eae", "metadata": {}, "source": [ "The map created shows the Subbarrios in San Juan Municipo.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### United States Outline\n", "\n", "This file contains the [United States Outline](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_30) shapefile. This contains all 50 US states plus the District of Columbia, Puerto Rico, and the Island Areas (American Samoa, the Commonwealth of the Northern Mariana Islands, Guam, and the US Virgin Islands). There is only one feature within this dataset.\n", "\n", "The attribute table for this dataset only contains the AFFGEOID, GEOID, NAME, and coordinates for the US polygon.\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the United States Outline data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 66, "id": "064bb555", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AFFGEOIDGEOIDNAMEgeometry
00100000USUSUnited StatesMULTIPOLYGON (((179.48246 51.98283, 179.48656 ...
\n", "
" ], "text/plain": [ " AFFGEOID GEOID NAME \\\n", "0 0100000US US United States \n", "\n", " geometry \n", "0 MULTIPOLYGON (((179.48246 51.98283, 179.48656 ... " ] }, "execution_count": 66, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_nation_5m\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "fccb8907", "metadata": {}, "source": [ "Next, plot the entire data from this parquet file and overlay it on a basemap. Since this dataset contains only one feature, there are no options to select or exclude specific parts based on attributes." ] }, { "cell_type": "code", "execution_count": 67, "id": "a3cb3236", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf.plot(figsize=(30, 60), alpha=0.5, edgecolor=\"k\")\n", "ax.set_title(\n", " \"United States and US Overseas Territories\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "85e4992f", "metadata": {}, "source": [ "The map created shows the United States and US Overseas Territories.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**\n", "\n", "### Voting Districts (VTD)\n", "\n", "This file contains all [US Voting Districts](https://www.census.gov/programs-surveys/geography/about/glossary.html#par_textimage_31), which are geographic features established by state, local and tribal governments to conduct elections.\n", "\n", "The attribute table contains the following information:\n", "\n", "* STATEFP20 = State FIPS code\n", "* COUNTYFP20 = County FIPS code\n", "* VTDST20 = Voting district code\n", "* AFFGEOID = American FactFinder summary level code + geovariant code + \"00US\" + GEOID\n", "* EOID = Concatenation of State FIPS code, County FIPS code, and Voting District code\n", "* VTDI20 = Voting district indicator\n", "* NAME20 = Voting district name\n", "* NAMELSAD20 = Voting district name and legal/statistical division\n", "* LSAD20 = Legal/statistical classification\n", "* ALAND20 = Current land area\n", "* AWATER20 = Current water area\n", "* geometry = coordinates for Voting District polygons\n", "\n", "Use the [read_parquet](https://geopandas.readthedocs.io/en/latest/docs/reference/api/geopandas.read_parquet.html) function of [Dask-GeoPandas](https://github.com/geopandas/dask-geopandas) to read the Voting Districts data from the parquet file of the Planetary Computer dataset:" ] }, { "cell_type": "code", "execution_count": 68, "id": "32919257", "metadata": {}, "outputs": [ { "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", "
STATEFP20COUNTYFP20VTDST20AFFGEOID20GEOID20VTDI20NAME20NAMELSAD20LSAD20ALAND20AWATER20geometry
02400306-0247000000US2400306-0242400306-024AANNE ARUNDEL PRECINCT 06-024ANNE ARUNDEL PRECINCT 06-02400275676721979454POLYGON ((-76.48621 38.92784, -76.48142 38.928...
12404701-0027000000US2404701-0022404701-002AWORCESTER PRECINCT 01-002WORCESTER PRECINCT 01-002001118610871934368MULTIPOLYGON (((-75.30048 38.09594, -75.29902 ...
20209006-1507000000US0209006-1500209006-150AFox PrecinctFox Precinct0022415677970POLYGON ((-148.11011 65.20532, -148.10451 65.2...
3261011010017000000US2610110100126101101001A1010332000001Voting District 1010332000001V1481592601006220POLYGON ((-86.25160 44.46544, -86.25091 44.469...
4260550550077000000US2605505500726055055007A0552380000001Voting District 0552380000001V199676980POLYGON ((-85.57537 44.75340, -85.57330 44.752...
\n", "
" ], "text/plain": [ " STATEFP20 COUNTYFP20 VTDST20 AFFGEOID20 GEOID20 VTDI20 \\\n", "0 24 003 06-024 7000000US2400306-024 2400306-024 A \n", "1 24 047 01-002 7000000US2404701-002 2404701-002 A \n", "2 02 090 06-150 7000000US0209006-150 0209006-150 A \n", "3 26 101 101001 7000000US26101101001 26101101001 A \n", "4 26 055 055007 7000000US26055055007 26055055007 A \n", "\n", " NAME20 NAMELSAD20 LSAD20 \\\n", "0 ANNE ARUNDEL PRECINCT 06-024 ANNE ARUNDEL PRECINCT 06-024 00 \n", "1 WORCESTER PRECINCT 01-002 WORCESTER PRECINCT 01-002 00 \n", "2 Fox Precinct Fox Precinct 00 \n", "3 1010332000001 Voting District 1010332000001 V1 \n", "4 0552380000001 Voting District 0552380000001 V1 \n", "\n", " ALAND20 AWATER20 geometry \n", "0 2756767 21979454 POLYGON ((-76.48621 38.92784, -76.48142 38.928... \n", "1 111861087 1934368 MULTIPOLYGON (((-75.30048 38.09594, -75.29902 ... \n", "2 2241567797 0 POLYGON ((-148.11011 65.20532, -148.10451 65.2... \n", "3 48159260 1006220 POLYGON ((-86.25160 44.46544, -86.25091 44.469... \n", "4 9967698 0 POLYGON ((-85.57537 44.75340, -85.57330 44.752... " ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "asset = census.get_item(\"2020-cb_2020_us_vtd_500k\").assets[\"data\"]\n", "ddf = geopandas.read_parquet(\n", " asset.href, storage_options=asset.extra_fields[\"table:storage_options\"]\n", ")\n", "ddf.head()" ] }, { "cell_type": "markdown", "id": "d9a1babf", "metadata": {}, "source": [ "Next, plot the data from this parquet file and overlay it on a basemap. For this example, plot all the Voting Districts in Salt Lake City, UT by filtering by Voting District Names that begin with `\"Salt Lake\"` in the NAME20 column." ] }, { "cell_type": "code", "execution_count": 69, "id": "20151b95", "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "ddf.crs = 4326\n", "ddf = ddf.to_crs(epsg=3857)\n", "\n", "ax = ddf[ddf.NAME20.str.startswith(\"Salt Lake\")].plot(\n", " figsize=(10, 10), alpha=0.5, edgecolor=\"k\"\n", ")\n", "ax.set_title(\n", " \"Salt Lake City Voting Districts\",\n", " fontdict={\"fontsize\": \"20\", \"fontweight\": \"2\"},\n", ")\n", "ctx.add_basemap(ax, source=ctx.providers.Esri.NatGeoWorldMap)\n", "ax.set_axis_off()" ] }, { "cell_type": "markdown", "id": "1db06fd2", "metadata": {}, "source": [ "The map created shows Salt Lake City Voting Districts.\n", "\n", "**[Jump to Top](#United-States-2020-Census-data)**" ] } ], "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.10" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 5 }