Skip to content

A Cloudflare Worker that does full-text search on Statistics Canada's geographies.

License

Notifications You must be signed in to change notification settings

dataforcanada/statcan-geography

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

About

statcan-geography is a Cloudflare worker that allows searching of Statistics Canada's geographies and makes use of SQLite's full-text search (FTS5) extension.

You can preview this Cloudflare worker by going to https://statcan-geography.dataforcanada.org/. After searching, you can click on the DGUID, and it will open up a map page, zooming to the geography.

Currently the search is just for the following geographic levels:

  • Country: This includes the geographic boundary for Canada for the 2021 Census.
  • Geographical Regions of Canada (GRCs): This includes the GRCs for the 2021 Census.
  • Provinces or Territories (PRs): This includes the PRs for the 2021 Census.
  • Economic Regions (ERs): This includes the ERs for the 2021 Census.
  • Census Agricultural Regions (CARs): This includes the CARs for the 2021 Census.
  • Census Divisions (CDs): This includes the CDs for the 2021 Census.
  • Census Consolidated Subdivisions (CCSs): This includes the CCSs for the 2021 Census.
  • Census Metropolitan Areas or Census Agglomerations (CMACAs): This includes the CMACAs for the 2021 Census.
  • Census Subdivisions (CSDs): This includes the CSDs for the 2021 Census.
  • Federal Electoral Districts (FEDs): This includes the FEDs for the 2021 Census, which are based on the 2013 Repreesentation Order.
  • Designated Places (DPLs): This includes the DPLs for the 2021 Census.
  • Population Centres (POPCTRs): This includes the POPCTRs for the 2021 Census.
  • Place Names (PNs): This includes the PNs for the 2021 Census.

Steps to Deploy

# 1. Clone the repository
git clone https://github.com/dataforcanada/statcan-geography.git
# 2. Navigate to the project directory
cd statcan-geography
# 3. Install the JavaScript dependencies
npx npm install
# 3. Make sure you are logged in with wrangler
npx wrangler login
# 3. Create a Cloudflare D1 database, add the database_id to wrangler.toml
npx wrangler d1 create geographies_search
# 4. Create an R2 bucket, this will host the GeoJSON geometries for Statistics Canada's geographies. Change the bucket_name value in wrangler.tom if it's different than above
npx wrangler r2 bucket create geographies-search
# 6. Import the geographies SQL into D1. If you want to generate it yourself head into the notebooks folder for instructions. You will need to run the notebook to generate the GeoJSON files
npx wrangler d1 execute geographies_search --remote --file=db/geographies.sql
# 7. If you want to generate the dist/output.css
npx @tailwindcss/cli -i ./src/input.css -o ./dist/output.css --minify
# 8. Deploy the Cloudflare worker
npx wrangler deploy

License

This repo is distributed under an MIT license.

Back to top

About

A Cloudflare Worker that does full-text search on Statistics Canada's geographies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published