femic.bcdc_fetch Module
The femic.bcdc_fetch module owns FEMIC’s first AOI-scoped geographic
acquisition path for BCDC layers that expose WFS-queryable OpenMaps services.
It sits one layer downstream of femic.bcdc_catalog: resolve first,
then fetch through WFS when the top match advertises
suggested_fetch_strategy=wfs_getfeature_bbox.
Use this page when you are debugging the actual WFS fetch path, Geomark AOI normalization, or the GeoJSON/GeoPackage write behavior rather than the catalogue search/ranking logic.
Start Here If…
Use this page first if you are trying to:
inspect how FEMIC turns a Geomark reference into an EPSG:3005 bbox;
debug the exact WFS
GetFeatureURL FEMIC builds for OpenMaps-backed layers;understand why a
bcdc-fetchcall wrote GeoJSON vs GeoPackage; orinspect why a resolved dataset was rejected as non-WFS-queryable and pushed back to
femic data bcdc-resolve --download-director manual follow-up.
Typical Usage
The common operator-facing entrypoint is:
femic data bcdc-fetch WHSE_FOREST_VEGETATION.F_OWN --bbox 1170000,450000,1180000,460000
The matching Python entrypoints are:
from pathlib import Path
from femic.bcdc_fetch import (
build_bbox_3005,
fetch_bcdc_wfs_data,
resolve_geomark_bbox_3005,
write_bcdc_fetch_manifest,
)
bbox = build_bbox_3005("1170000,450000,1180000,460000")
result = fetch_bcdc_wfs_data(
"WHSE_FOREST_VEGETATION.F_OWN",
destination_root=Path("downloads/bcdc"),
bbox_epsg3005=bbox,
)
write_bcdc_fetch_manifest(result, Path("runtime/logs/f_own_fetch_manifest.json"))
Key Entry Surfaces
build_bbox_3005()Parse and validate explicit AOI bboxes from the CLI.resolve_geomark_bbox_3005()Normalize a Geomark reference into an EPSG:3005 bbox for v1 WFS fetches.fetch_bcdc_wfs_data()Resolve a query, require a WFS-queryable service resource, request GeoJSON via WFSGetFeature, and save local vector output.write_bcdc_fetch_manifest()Persist one WFS fetch result as JSON for later review or promotion.
Cross-References
AOI-scoped WFS acquisition helpers for BC Data Catalogue resources.
- exception femic.bcdc_fetch.BcdcFetchError[source]
Bases:
RuntimeErrorRaised when WFS-backed BCDC acquisition cannot proceed.
- class femic.bcdc_fetch.BcdcFetchResult(query, limit, generated_utc, package_id, package_name, package_title, dataset_page_url, resource_id, resource_name, resource_url, wfs_typename, matched_by, suggested_fetch_strategy, aoi_source, bbox_epsg3005, geomark_id, geomark_url, request_url, saved_path, output_format, feature_count, warnings=())[source]
Bases:
objectOne AOI-scoped WFS fetch result for a resolved query.
- Parameters:
query (str)
limit (int)
generated_utc (str)
package_id (str)
package_name (str)
package_title (str)
dataset_page_url (str)
resource_id (str)
resource_name (str)
resource_url (str)
wfs_typename (str)
matched_by (str)
suggested_fetch_strategy (str | None)
aoi_source (str)
bbox_epsg3005 (tuple[float, float, float, float])
geomark_id (str | None)
geomark_url (str | None)
request_url (str)
saved_path (Path)
output_format (str)
feature_count (int)
warnings (tuple[str, ...])
- aoi_source: str
- bbox_epsg3005: tuple[float, float, float, float]
- dataset_page_url: str
- feature_count: int
- generated_utc: str
- geomark_id: str | None
- geomark_url: str | None
- limit: int
- matched_by: str
- output_format: str
- package_id: str
- package_name: str
- package_title: str
- query: str
- request_url: str
- resource_id: str
- resource_name: str
- resource_url: str
- saved_path: Path
- suggested_fetch_strategy: str | None
- to_dict()[source]
- Return type:
dict[str, object]
- warnings: tuple[str, ...] = ()
- wfs_typename: str
- class femic.bcdc_fetch.GeomarkBBox(geomark_id, geomark_url, bbox_epsg3005)[source]
Bases:
objectNormalized Geomark AOI as an EPSG:3005 bounding box.
- Parameters:
geomark_id (str)
geomark_url (str)
bbox_epsg3005 (tuple[float, float, float, float])
- bbox_epsg3005: tuple[float, float, float, float]
- geomark_id: str
- geomark_url: str
- to_dict()[source]
- Return type:
dict[str, object]
- femic.bcdc_fetch.build_bbox_3005(value)[source]
Parse a CLI bbox string into an EPSG:3005 bbox tuple.
- Parameters:
value (str)
- Return type:
tuple[float, float, float, float]
- femic.bcdc_fetch.fetch_bcdc_wfs_data(query, *, destination_root, bbox_epsg3005, output_format='gpkg', limit=5, geomark=None, query_slug=None)[source]
Fetch AOI-scoped WFS data for the top-ranked WFS-capable BCDC resource.
- Parameters:
query (str)
destination_root (Path)
bbox_epsg3005 (tuple[float, float, float, float])
output_format (str)
limit (int)
geomark (GeomarkBBox | None)
query_slug (str | None)
- Return type:
BcdcFetchResult
- femic.bcdc_fetch.resolve_geomark_bbox_3005(geomark_ref)[source]
Resolve a Geomark reference into a normalized EPSG:3005 bounding box.
- Parameters:
geomark_ref (str)
- Return type:
GeomarkBBox
- femic.bcdc_fetch.write_bcdc_fetch_manifest(result, path)[source]
Write one BCDC WFS fetch result to JSON.
- Parameters:
result (BcdcFetchResult)
path (Path)
- Return type:
Path