Skip to main content

CLI for the San Diego Regional Data Warehouse (SANDAG/SanGIS)

Project description

sdgis — San Diego Regional Data Warehouse CLI

A command-line tool for exploring, querying, and downloading 360+ GIS datasets from the San Diego Regional Data Warehouse maintained by SANDAG and SanGIS.

Why use this?

The SANDAG data warehouse is one of the most comprehensive public GIS repositories for San Diego County — but it's locked behind a web portal and ArcGIS REST APIs that are painful to work with directly. This CLI makes that data scriptable.

Use it if you want to:

  • Research or analyze San Diego — parcels, zoning, census tracts, bike infrastructure, fire stations, hydrology, affordable housing, business licenses, broadband coverage, and much more
  • Feed data to an AI agent — all commands output clean JSON to stdout, status goes to stderr, making it easy to pipe into LLM workflows
  • Script data pipelines — pull live feature data with SQL-style filters, bounding boxes, and pagination; pipe directly to jq, ogr2ogr, or files
  • Explore what's available — semantic search across 360 datasets lets you find relevant data without knowing exact dataset names

Installation

pipx install sdgis-cli

Or with pip:

pip install sdgis-cli

# For semantic search (recommended):
pip install sdgis-cli[embed]

Setup (first time)

Build the local search index. Downloads the dataset catalog and computes embeddings (~22MB model, takes ~30s):

sdgis index

Quick Start

# Semantic search — find relevant datasets without knowing exact names
sdgis search "bike infrastructure"
sdgis search "water and flooding"
sdgis search "affordable housing near transit"

# Understand a dataset before querying it (great for agents)
sdgis describe Bikeways

# Count features (with optional filter)
sdgis count Bikeways
sdgis count ABC_Licenses --where "LICENSE_TYPE='21'"

# Query features
sdgis query Bikeways --limit 5
sdgis query Bikeways --where "RD_NAME='Coast Blvd'" --fields "RD_NAME,CLASS"
sdgis query ABC_Licenses --bbox "-117.2,32.7,-117.1,32.8" --limit 50

# Output as JSON or CSV
sdgis query Bikeways --limit 100 -f json
sdgis query Bikeways --limit 100 -f csv > bikeways.csv
sdgis query Bikeways --limit 100 -f geojson > bikeways.geojson

# Fetch ALL features with automatic pagination
sdgis query-all Bikeways -f geojson > all_bikeways.geojson

# Download pre-built exports
sdgis download Bikeways -f shapefile

Commands

Command Description
index Build local SQLite index with semantic embeddings
search <query> Semantic / FTS / fuzzy search across all datasets
describe <dataset> Schema + feature count + sample rows as JSON (agent-friendly)
list List all available datasets
info <dataset> Show schema, fields, metadata, and links
fields <dataset> List all fields with types and domains
head <dataset> Quick preview: 3 rows + schema summary
count <dataset> Count total features (supports WHERE clause)
query <dataset> Query features with filters, pagination, bounding box
query-all <dataset> Fetch all features with automatic pagination
sql <dataset> <where> Shorthand for WHERE clause queries
download <dataset> Download pre-built GeoJSON / CSV / Shapefile / FGDB
url <dataset> Generate REST, portal, or download URLs
categories List the 18 dataset categories

For AI Agents

Every command that returns data outputs clean JSON to stdout with no ANSI codes. Status messages go to stderr. This makes it easy to use with any LLM tool framework.

Typical agent workflow:

# 1. Find relevant datasets
sdgis search "stormwater infrastructure" --json-output

# 2. Understand a dataset's schema and sample data in one call
sdgis describe Hydrological_Basins

# 3. Count matching features before pulling all data
sdgis count Hydrological_Basins --where "AREA_SQMI > 10" --json-output

# 4. Pull the data
sdgis query Hydrological_Basins --where "AREA_SQMI > 10" -f geojson

Dataset Categories

Agriculture, Business, Census, Community, District, Ecology & Parks, Elevation, Fire, Health & Public Safety, Hydrology & Geology, Jurisdiction, Landbase, Land Use, Miscellaneous, Place, Transportation, Utilities, Zoning

Output Formats

  • table — Rich formatted terminal table (default, human-readable)
  • json — Raw ArcGIS JSON response
  • geojson — Standard GeoJSON FeatureCollection
  • csv — Comma-separated values (attributes only)

Spatial Queries

Filter by bounding box (WGS84 lon/lat):

sdgis query ABC_Licenses --bbox "-117.2,32.7,-117.1,32.8" --limit 100 -f geojson

Piping & Scripting

# Count features in every transportation dataset
sdgis search transportation --json-output | \
  jq -r '.[].name' | \
  while read ds; do
    echo -n "$ds: "
    sdgis count "$ds" --json-output 2>/dev/null
  done

# Convert to GeoPackage with ogr2ogr
sdgis query-all Bikeways -f geojson | ogr2ogr -f "GPKG" bikeways.gpkg /vsistdin/

About the Data Warehouse

SanGIS and SANDAG have partnered to provide the San Diego region with a single authoritative source of GIS data through the San Diego Regional Data Warehouse. It contains hundreds of layers across 18 categories, collected from multiple sources including the City of San Diego, the County of San Diego, the State of California, and the federal government — all free for public use.

Datasets cover everything from addresses to zoning: roads/freeways, property and city boundaries, census areas, community planning areas, lakes, streams, business zones, and much more. Data is available as hosted feature services (for interactive viewing and metadata review) and as downloads in FileGDB, Shapefile, CSV, GeoJSON, and JSON formats.

Note: Per California Assembly Bill AB1785, SanGIS no longer publishes parcel owner name and address information in publicly accessible online locations. For parcel owner data or technical issues, contact webmaster@sangis.org.

Data is provided for convenience with no warranty as to accuracy. Users should review the SanGIS Legal Notice and SANDAG Privacy Policy prior to use.

Data Source

All data comes from the San Diego Regional Data Warehouse operated by SANDAG (San Diego Association of Governments) and SanGIS.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdgis_cli-1.0.6.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdgis_cli-1.0.6-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file sdgis_cli-1.0.6.tar.gz.

File metadata

  • Download URL: sdgis_cli-1.0.6.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for sdgis_cli-1.0.6.tar.gz
Algorithm Hash digest
SHA256 74ec7dcd13cf8173b92ba8fa811c9a7093487c8be69ffb1411c90b3adf2d052b
MD5 964e02442577a24d48f40ae6dbbffdf5
BLAKE2b-256 5e35c90a977ef3c2b79837afd7980d00fc401242c76b52b0717af2df7912d33c

See more details on using hashes here.

File details

Details for the file sdgis_cli-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: sdgis_cli-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for sdgis_cli-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 278ab022d312733312a944083dd6c9cd745aa75cd130f8bd5b42752f5b9e393a
MD5 24228df1c6ed17e7100da76ca8dc606c
BLAKE2b-256 f6e03b6f61a529280657b04f7f9707e009cdd4bab278411d97aaed9104aa8fba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page