GeoIDs.jl GitHub

Setup Module#

The Setup module provides functionality for initializing the database schema and acquiring Census TIGER/Line shapefiles.

Database Initialization#

Main function to completely initialize the database:

GeoIDs.Setup.ensure_database_exists

source
ensure_database_exists()

Check if the configured database exists and create it if it doesn't. Returns true if the database was created, false if it already existed.

Schema Setup#

Functions for setting up the database schema:

GeoIDs.Setup.setup_census_schema

source
setup_census_schema(conn)

Create the census schema if it doesn't exist.

Arguments

  • conn: LibPQ connection object

Census Data Management#

Functions for managing Census geographic data:

GeoIDs.Setup.download_county_shapefile

source
download_county_shapefile(output_dir="./data", year=2023)

Use the local county shapefile that's already downloaded in the GeoIDs.jl/data directory.

Arguments

  • output_dir: Directory where the shapefile is or should be copied to

  • year: Census year (default: 2023)

Returns

  • Path to the shapefile zip file

GeoIDs.Setup.extract_shapefile

source
extract_shapefile(zip_path, output_dir="./data")

Extract the shapefile zip to the specified directory. If the .shp file already exists, it won't extract again.

Arguments

  • zip_path: Path to the zip file

  • output_dir: Directory to extract files to

Returns

  • Path to the extracted shapefile (.shp)

GeoIDs.Setup.load_counties_to_db

source
load_counties_to_db(shapefile_path, conn)

Load the county shapefile into the database.

Arguments

  • shapefile_path: Path to the shapefile (.shp)

  • conn: LibPQ connection object

Note: The download_county_shapefile function now uses a local shapefile from the GeoIDs.jl/data directory instead of downloading it from the internet.

Module Index#