Skip to main content
This page lives in the Users section and is also referenced from Developers. If you arrived from there, your sidebar has switched to Users.

Open Data Portals

CDT can connect to external open data portals and display their datasets as vector layers in the map viewer. Portals are registered in the platform's database, and the frontend fetches and renders datasets directly from the external APIs.

Overview

An OpenDataPortal record stores the connection details for a single portal (name, API URL, data management system type, geographic scope). When a user browses datasets in the map viewer, CDT queries the relevant portals based on the current map location and presents datasets as toggleable layers.

How It Works in CDT

Portal registry

Portals are stored in the database and exposed via the hooks in @collabdt/core/hooks/openDataPortals/. The map viewer queries portals filtered by municipality and country subdivision (ISO 3166-2 code) to surface the most relevant datasets for the visible area.

const { openDataPortals } = useOpenDataPortalsByMunicipalityAndCountrySubdivision(
currentMunicipality,
currentCountrySubdivision
)

Dataset adapters

Each DataManagementSystem has a corresponding adapter that knows how to fetch and normalise data from that system's API:

SystemValueAdapter
CKANCkanckanDatasets
ArcGISArcgisarcGISDatasets
OpendatasoftOpendatasoftopendatasoftDatasets
LocallocalDatasets
SocrataSocrata

The adapters normalise external API responses into a common Dataset type with getFeatures() and getFields() methods. The map viewer calls these to build a GeoJSON Source and render a Layer.

Groups

Portals are tagged with a DatasetGroup:

GroupMeaning
OrganizationalCDT organization's own hosted datasets
MunicipalCity/municipality-level portals
ProvincialProvince- or territory-level portals (a portal's countrySubdivision)
NationalNational/federal portals

Key Files

FileRole
@collabdt/core/hooks/openDataPortals/openDataPortals.tsHook exports
@collabdt/core/hooks/openDataPortals/createOpenDataPortalHooks.tsSWR hook implementations
@collabdt/core/types/dbTypes.tsOpenDataPortal, DatasetGroup, DataManagementSystem types
@collabdt/core/components/viewers/map/src/MapLayers/src/OpenDataLayers/Map layer that renders portal datasets

Gotchas

  • Portal apiUrl and portalUrl are optional — some portals in the registry may not have API access configured, which will cause dataset fetches to fail silently.
  • External API rate limits and CORS policies apply. CDT fetches dataset data client-side, so the user's browser must be able to reach the external portal API directly.
  • countrySubdivision uses ISO 3166-2 format (e.g., CA-ON, US-NY). Mismatched formats will cause portal lookup by subdivision to return empty results.

Further Reading