critwire · Learn · Learn's data

Learn · Schemas: browser · lab · star

Lab schema: the PostGIS tables

The tables the PostgreSQL labs run on: schema learn_curriculum in a database on your own computer, built by one file, learn_curriculum.sql. Set up your tools shows how to load it.

It holds the same keyed tables as the browser's schema, in PostgreSQL's types (text for VARCHAR, float8 for DOUBLE; a dataset's key is a uuid), plus the shapes the GIS modules join records to: country outlines, admin-1 areas (states and provinces) for nine countries, biomes and ecoregions, and the habitat map (Jung et al. 2020, v004): its classes, each country's estimated area per class, each record's class, and two clips of the 100 m map, all of Costa Rica and all of Tasmania, stored as raster tiles. Every shape is a geometry in WGS 84 (SRID 4326) with a GiST index; each clip is a raster stored in the database, one band of class codes in the same system. The habitat areas and classes are estimates from a map, not measurements. A record's point is a generated column, computed from its longitude and latitude, so it can never disagree with them.

The diagram

Read it as the browser's diagram: PK primary key, FK foreign key, UK unique key; || exactly one, |o zero or one, o{ zero or more, |{ one or more, with the crow's foot on the table that holds the foreign key.

critwire Learn lab database, PostGIS schema learn_curriculum
The schema v2 tables in PostgreSQL types, plus the shapes: country outlines, admin-1 areas, biomes, ecoregions and the habitat map: its classes, each country's estimated area per class, each record's class, and two clips stored as raster tiles. Open the diagram alone to zoom in.

The relationships, in words

The view species_taxonomy

As in the browser: one row per species with its genus, family, order and class, walked up taxa. A view stores no rows, so it isn't drawn.

Tables the lessons make

Some lessons create tables of their own in the lab: a grid, a staging table, a star. They aren't part of the loaded lab, so they aren't drawn, and the check excuses exactly these names:

The data dictionary

The tables that differ from the browser's: new ones, and ones with other columns. The others have the browser's columns, in PostgreSQL types; their entries are on the browser's page:

occurrences

ColumnTypeKeyMeaningSource
idbigintPKGBIF's record idGBIF occurrence download, sampled (cited in the credits)
species_idintegerFKthe animal recordedGBIF occurrence download, sampled (cited in the credits)
dataset_keyuuidFKthe dataset to creditGBIF occurrence download, sampled (cited in the credits)
licensetextCC0 1.0 or CC BY 4.0, the stricter of record and datasetGBIF record and dataset licenses
basis_of_recordtextHUMAN_OBSERVATION, PRESERVED_SPECIMEN, ...GBIF occurrence download, sampled (cited in the credits)
longitudefloat8degrees east, WGS 84GBIF occurrence download, sampled (cited in the credits)
latitudefloat8degrees north, WGS 84GBIF occurrence download, sampled (cited in the credits)
coordinate_uncertainty_mfloat8metres, at least 0 and finite; NULL when not givenGBIF occurrence download, sampled (cited in the credits)
country_code_gbiftextGBIF's code as delivered; ZZ unknown, XZ high seasGBIF occurrence download, sampled (cited in the credits)
country_codetextFKthat code when it is a countries row, else NULLcountry_code_gbif, when a countries row
yearintegerabove 0; NULL when the record has noneGBIF occurrence download, sampled (cited in the credits)
monthinteger1 to 12; NULL when the record has noneGBIF occurrence download, sampled (cited in the credits)
geomgeometryPoint, generated from longitude and latitudegenerated from longitude, latitude

country_shapes

ColumnTypeKeyMeaningSource
country_codetextPK, FKthe countryNatural Earth admin-0 1:50m (public domain)
geomgeometryMultiPolygon, Natural Earth admin-0 1:50mNatural Earth admin-0 1:50m (public domain)

admin1_shapes

ColumnTypeKeyMeaningSource
adm1_codetextPKNatural Earth's code, such as AUS-2660Natural Earth admin-1 1:50m (public domain)
country_codetextFKthe country it is part ofNatural Earth admin-1 1:50m (public domain)
nametextTasmaniaNatural Earth admin-1 1:50m (public domain)
geomgeometryMultiPolygon, Natural Earth admin-1 1:50mNatural Earth admin-1 1:50m (public domain)

biomes

ColumnTypeKeyMeaningSource
biome_idintegerPKRESOLVE biome number, 1 to 14RESOLVE Ecoregions 2017 (CC BY 4.0)
nametextTropical & Subtropical Moist Broadleaf ForestsRESOLVE Ecoregions 2017 (CC BY 4.0)

ecoregions

ColumnTypeKeyMeaningSource
eco_idintegerPKRESOLVE ecoregion idRESOLVE Ecoregions 2017 (CC BY 4.0)
biome_idintegerFKits biome; NULL for Rock and IceRESOLVE Ecoregions 2017 (CC BY 4.0)
nametextTasmanian temperate forestsRESOLVE Ecoregions 2017 (CC BY 4.0)
realmtextAustralasia; NULL for Rock and IceRESOLVE Ecoregions 2017 (CC BY 4.0)
geomgeometryMultiPolygon, simplified to 0.05 degreesRESOLVE Ecoregions 2017 (CC BY 4.0)

habitat_classes

ColumnTypeKeyMeaningSource
codeintegerPKJung v004 class, such as 105Jung et al. 2020, v004 legend (CC BY 4.0)
level1_codeintegerFKits level-1 class, such as 100; NULL for level 1Jung et al. 2020, v004 legend (CC BY 4.0)
nametextForest – Subtropical/tropical dryJung et al. 2020, v004 legend (CC BY 4.0)

country_habitats

ColumnTypeKeyMeaningSource
country_codetextPK, FKthe countryJung et al. 2020, v004 (CC BY 4.0), 1 km fractions over Natural Earth's outlines (estimated)
habitat_codeintegerPK, FKthe habitat classJung et al. 2020, v004 (CC BY 4.0), 1 km fractions over Natural Earth's outlines (estimated)
est_area_km2numericestimated from the map, never measured; at least 0Jung et al. 2020, v004 (CC BY 4.0), 1 km fractions over Natural Earth's outlines (estimated)

occurrence_habitats

ColumnTypeKeyMeaningSource
occurrence_idbigintPK, FKthe recordJung et al. 2020, v004 (CC BY 4.0), 1 km class at each sample record
habitat_codeintegerFKclass of its 1 km cell; NULL if noneJung et al. 2020, v004 (CC BY 4.0), 1 km class at each sample record

habitat_clips

ColumnTypeKeyMeaningSource
cliptextPKcr or tasJung et al. 2020, v004 (CC BY 4.0), 100 m classes, whole country, in 256-cell tiles
tileintegerPKthe tile's number in its clipthe ingest's tiling: row-major from the clip's upper-left tile
rastrastera 256-cell tile of the habitat map, stored in the databaseJung et al. 2020, v004 (CC BY 4.0), 100 m classes, whole country, in 256-cell tiles