Getting Started
Installation
To install GeoIDs.jl, use the Julia package manager:
import Pkg
Pkg.add(url="https://github.com/technocrat/GeoIDs.jl.git")Setup
Before using GeoIDs.jl, you need to:
- Set up PostgreSQL with PostGIS - Follow our PostgreSQL Setup Guide
- Configure database connection - See Database Configuration
- Initialize the database schema - Use Database Setup instructions
For quick setup with default settings, run:
using GeoIDs
# Initialize the database with default settings
initialize_database()You can configure the database connection using environment variables:
# Set database connection parameters
ENV["GEOIDS_DB_NAME"] = "tiger" # Default
ENV["GEOIDS_DB_HOST"] = "localhost" # Default
ENV["GEOIDS_DB_PORT"] = "5432" # Default
# Load the package
using GeoIDsBasic Usage
Creating GEOID Sets
Create a new GEOID set by first fetching some GEOIDs:
# Get all Florida counties
florida_counties = get_geoids_by_state("FL")
# Create a named set
create_geoid_set("florida_counties", "All counties in Florida", florida_counties)Retrieving GEOID Sets
# Get a GEOID set
fl_geoids = get_geoid_set("florida_counties")
# Count the number of counties
println("Florida has $(length(fl_geoids)) counties")Spatial Filtering
Get counties based on spatial criteria:
# Get southern Florida counties (below 27° latitude)
south_fl = get_geoids_by_spatial_filter(:latitude, Dict(
"min_lat" => 25.0,
"max_lat" => 27.0
))
# Create a set with these counties
create_geoid_set("south_florida", "Southern Florida counties", south_fl)GEOID Set Operations
# Create a new set as the difference between two sets
central_fl = difference_geoid_sets(
"florida_counties",
"south_florida",
"central_florida",
"Florida counties excluding southern counties"
)
# Create a union of multiple sets
east_coast = union_geoid_sets(
["florida_counties", "georgia_coastal"],
"southeast_coast",
"Southeast coastal counties"
)Modifying Sets
Add or remove counties from an existing set:
# Add counties to a set
add_to_geoid_set("south_florida", ["12021"]) # Add Collier County
# Remove counties from a set
remove_from_geoid_set("south_florida", ["12025"]) # Remove Dade CountyListing and Version Management
# List all GEOID sets
sets = list_geoid_sets()
println("Available sets: $(sets.set_name)")
# View version history of a set
versions = list_geoid_set_versions("south_florida")
println("Version history: $(versions)")
# Rollback to a previous version
rollback_geoid_set("south_florida", 1)Next Steps
For more details on using GeoIDs.jl, explore these guides:
- PostgreSQL Setup - Installing and configuring PostgreSQL with PostGIS
- Database Configuration - Configuring database connection settings
- Database Setup - Initializing the database schema and county data
- GEOID Sets - Working with GEOID sets in detail
- Spatial Filtering - Advanced spatial querying capabilities
- Set Operations - Combining and manipulating GEOID sets
- Versioning - Tracking changes to GEOID sets over time