Appendix

Software/Packages and Install Instructions

The code samples in this documentation were validated and run on the following software versions and with these packages. Note that only direct package imports are listed below (package dependencies are not included). If you are having issues running any of the code samples in this documentation, double check your package versions against those listed here. For help installing these packages, please see the Installing Packages section below.

Software Versions

  • Python Version: 3.12.9

  • R Version: 4.4.0

Python Packages

Package

Version

geopandas

0.14.4

matplotlib

3.10.1

numpy

1.26.4

pandas

2.2.3

requests

2.32.3

shapely

2.0.7

us

3.2.0

R Packages

Package

Version

ggplot2

3.5.2

httr

1.4.7

jsonlite

1.9.1

sf

1.0.19

tigris

2.2.1

tidyverse

2.0.0

Installing Packages

You can view and download the package requirements for Python and R here:

Python

To install the packages used in this documentation in Python, you can download the Python requirements and use either pip or conda. The instructions below for conda create a new environment, while the instructions for pip simply install the packages globally. To create a virtual environment in pip, see these instructions on creating a virtual environment (instructions vary by operating system).

Note

The code in these document does not rely on Jupyter or Jupyter Notebooks. If you would like to run these samples in a Jupyter Notebook or an Python Interactive session, you will also need to install the necessary package(s). For more information, see installing Jupyter.

Using Conda:

conda create -n code-samples --file requirements.txt
conda activate code-samples

Using Pip:

pip install -r requirements.txt

R

To install the packages used in this documentation in R, you can download the R requirements. You can install the packages required through the instructions below.

Note

The style of package installation below does not install specific versions. If you want to install specific versions of R packages, you can first download the R package remotes and use the function install-version to install specific versions of the R packages.

source("requirements.R")

LODES Schema Files

Detailed information on the LODES file structure can be found in the LODES Technical Documentation. Selected schema tables are provided below for ease (and for attachment of labels, if desired).

Job Types

Download as CSV

job_type

label

JT00

All Jobs

JT01

Primary Jobs

JT02

All Private Jobs

JT03

Private Primary Jobs

JT04

All Federal Jobs

JT05

Federal Primary Jobs

Labor Market Segments

Download as CSV

workforce_segment

label

S000

Total number of jobs

SA01

Number of jobs of workers age 29 or younger

SA02

Number of jobs for workers age 30 to 54

SA03

Number of jobs for workers age 55 or older

SE01

Number of jobs with earnings $1250/month or less

SE02

Number of jobs with earnings $1251/month to $3333/month

SE03

Number of jobs with earnings greater than $3333/month

SI01

Number of jobs in Goods Producing industry sectors

SI02

Number of jobs in Trade, Transportation, and Utilities industry sectors

SI03

Number of jobs in All Other Services industry sectors

Worker/Job Characteristics

Download as CSV

characteristic

label

C000

Total number of jobs

CA01

Number of jobs for workers age 29 or younger

CA02

Number of jobs for workers age 30 to 54

CA03

Number of jobs for workers age 55 or older

CE01

Number of jobs with earnings $1250/month or less

CE02

Number of jobs with earnings $1251/month to $3333/month

CE03

Number of jobs with earnings greater than $3333/month

CNS01

Number of jobs in NAICS sector 11 (Agriculture, Forestry, Fishing and Hunting)

CNS02

Number of jobs in NAICS sector 21 (Mining, Quarrying, and Oil and Gas Extraction)

CNS03

Number of jobs in NAICS sector 22 (Utilities)

CNS04

Number of jobs in NAICS sector 23 (Construction)

CNS05

Number of jobs in NAICS sector 31-33 (Manufacturing)

CNS06

Number of jobs in NAICS sector 42 (Wholesale Trade)

CNS07

Number of jobs in NAICS sector 44-45 (Retail Trade)

CNS08

Number of jobs in NAICS sector 48-49 (Transportation and Warehousing)

CNS09

Number of jobs in NAICS sector 51 (Information)

CNS10

Number of jobs in NAICS sector 51 (Information)

CNS11

Number of jobs in NAICS sector 53 (Real Estate and Rental and Leasing)

CNS12

Number of jobs in NAICS sector 54 (Professional, Scientific, and Technical Services)

CNS13

Number of jobs in NAICS sector 55 (Management of Companies and Enterprises)

CNS14

Number of jobs in NAICS sector 56 (Administrative and Support and Waste Management and Remediation Services)

CNS15

Number of jobs in NAICS sector 61 (Educational Services)

CNS16

Number of jobs in NAICS sector 62 (Health Care and Social Assistance)

CNS17

Number of jobs in NAICS sector 71 (Arts, Entertainment, and Recreation)

CNS18

Number of jobs in NAICS sector 72 (Accommodation and Food Services)

CNS19

Number of jobs in NAICS sector 81 (Other Services [except Public Administration])

CNS20

Number of jobs in NAICS sector 92 (Public Administration)

CR01

Number of jobs for workers with Race: White, Alone

CR02

Number of jobs for workers with Race: Black or African American Alone

CR03

Number of jobs for workers with Race: American Indian or Alaska Native Alone

CR04

Number of jobs for workers with Race: Asian Alone

CR05

Number of jobs for workers with Race: Native Hawaiian or Other Pacific Islander Alone

CR07

Number of jobs for workers with Race: Two or More Race Groups

CT01

Number of jobs for workers with Ethnicity: Not Hispanic or Latino

CT02

Number of jobs for workers with Ethnicity: Hispanic or Latino

CD01

Number of jobs for workers with Educational Attainment: Less than high school

CD02

Number of jobs for workers with Educational Attainment: High school or equivalent, no college

CD03

Number of jobs for workers with Educational Attainment: Some college or Associate degree

CD04

Number of jobs for workers with Educational Attainment: Bachelor’s degree or advanced degree

CS01

Number of jobs for workers with Sex: Male

CS02

Number of jobs for workers with Sex: Female

CFA01

Number of jobs for workers at firms with Firm Age: 0-1 Years

CFA02

Number of jobs for workers at firms with Firm Age: 2-3 Years

CFA03

Number of jobs for workers at firms with Firm Age: 4-5 Years

CFA04

Number of jobs for workers at firms with Firm Age: 6-10 Years

CFA05

Number of jobs for workers at firms with Firm Age: 11+ Years

CFS01

Number of jobs for workers at firms with Firm Size: 0-19 Employees

CFS02

Number of jobs for workers at firms with Firm Size: 20-49 Employees

CFS03

Number of jobs for workers at firms with Firm Size: 50-249 Employees

CFS04

Number of jobs for workers at firms with Firm Size: 250-499 Employees

CFS05

Number of jobs for workers at firms with Firm Size: 500+ Employees

Bonus Code Samples

Visualizing Blocks around a Point in New Jersey

The code to generate the image in Case Study: Finding all the Jobs Within 5 KM of a Point is provided below in Python. In this code, the geographic crosswalk is used to to find the blocks within a 5 kilometer buffer of the specified point. Then, the buffer, original point, and blocks are plotted on the same image. Note that the package contextily is not included in the dependencies for this project, so it will need to be installed to generate this image.

import geopandas as gpd
from shapely.geometry import Point
import matplotlib.pyplot as plt
import contextily as ctx

# Input coordinates (latitude, longitude)
center_lat = 40.736679
center_lon = -74.175975

# Create GeoDataFrame of the target point
center_point = gpd.GeoDataFrame(
    geometry=[Point(center_lon, center_lat)], crs="EPSG:4326"
)

# Project to meters (Web Mercator) for buffering and basemap
center_point_proj = center_point.to_crs(epsg=3857)

# Create 5 km buffer (5000 meters)
buffer = center_point_proj.buffer(5000).iloc[0]

crosswalk = read_crosswalk("nj", cols=["cty", "blklondd", "blklatdd"])

# Convert to GeoDataFrame
crosswalk = gpd.GeoDataFrame(
    crosswalk,
    geometry=gpd.points_from_xy(crosswalk.blklondd, crosswalk.blklatdd),
    crs="EPSG:4326",
)

# Project blocks to same CRS as buffer (meters)
blocks_proj = crosswalk.to_crs(epsg=3857)

# Select blocks within buffer
blocks_within = blocks_proj[blocks_proj.geometry.within(buffer)]
fig, ax = plt.subplots(figsize=(10, 10))

# Plot buffer outline
gpd.GeoSeries(buffer).plot(ax=ax, edgecolor="red", facecolor="none", linewidth=2)

# Plot blocks within the 5 km radius
blocks_within.plot(ax=ax, color="blue", markersize=3)

# Plot center point
center_point_proj.plot(ax=ax, color="red", markersize=50, marker="*")

# Add basemap
ctx.add_basemap(ax, source=ctx.providers.OpenStreetMap.Mapnik)
All Census Blocks with 5 KM of Point