geeViz.edwLib

USFS Enterprise Data Warehouse (EDW) REST API client.

Provides search, metadata inspection, and spatial feature queries against the ArcGIS REST services at https://apps.fs.usda.gov/arcx/rest/services/EDW.

Quick start:

import geeViz.edwLib as edw

# Search for fire-related services
services = edw.search_services("fire")

# Get layer info
info = edw.get_service_info("EDW_MTBS_01")

# Query features as GeoJSON
geojson = edw.query_features("EDW_MTBS_01", 15,
    where="FIRE_NAME LIKE '%CAMERON PEAK%'",
    out_fields="FIRE_NAME,ACRES,YEAR")

# Load into Earth Engine
import ee
fc = ee.FeatureCollection(geojson)

Functions

get_layer_info(service_name, layer_id)

Get detailed metadata for a specific layer: fields, geometry type, capabilities.

get_service_info(service_name)

Get metadata for an EDW MapServer service: description, layers, spatial ref.

query_features(service_name, layer_id[, ...])

Query features from an EDW layer, optionally filtered by spatial intersection.

query_features_with_pagination(service_name, ...)

Query features with automatic pagination to get more than 2000 results.

search_services([query, theme])

Search EDW services by keyword and/or theme.

geeViz.edwLib.search_services(query: str = '', theme: str = '') list[dict[str, str]][source]

Search EDW services by keyword and/or theme.

Uses three matching strategies (results are deduplicated): 1. Substring match on service name (e.g. “mtbs” → EDW_MTBS_01) 2. Keyword alias expansion (e.g. “riparian” → inland_waters theme + stream services) 3. Theme filter (e.g. theme=”inland_waters”)

Parameters:
  • query – Search keyword (case-insensitive). Matches against service names, theme descriptions, and keyword aliases.

  • theme – Filter by theme category. Valid themes: biota, boundaries, environment, geoscientific, inland_waters, planning_cadastre, structure, transportation. Pass “” to skip theme filtering.

Returns a list of dicts with keys: name, type, url, theme, description. If both query and theme are empty, returns all services.

geeViz.edwLib.get_service_info(service_name: str) dict[str, Any][source]

Get metadata for an EDW MapServer service: description, layers, spatial ref.

Parameters:

service_name – Short service name, e.g. “EDW_MTBS_01”.

Returns:

name, description, spatialReference, layers (id, name, geometryType, defaultVisibility, minScale, maxScale).

Return type:

Dict with keys

geeViz.edwLib.get_layer_info(service_name: str, layer_id: int) dict[str, Any][source]

Get detailed metadata for a specific layer: fields, geometry type, capabilities.

Parameters:
  • service_name – Short service name, e.g. “EDW_MTBS_01”.

  • layer_id – Layer ID within the service.

Returns:

name, geometryType, description, fields, extent, maxRecordCount, supportedQueryFormats.

Return type:

Dict with keys

geeViz.edwLib.query_features(service_name: str, layer_id: int, geometry: dict | str | None = None, geometry_type: str = 'esriGeometryEnvelope', spatial_rel: str = 'esriSpatialRelIntersects', where: str = '1=1', out_fields: str = '*', max_features: int = 1000, out_sr: int = 4326, return_count_only: bool = False) dict[source]

Query features from an EDW layer, optionally filtered by spatial intersection.

Parameters:
  • service_name – Short service name, e.g. “EDW_MTBS_01”.

  • layer_id – Layer ID within the service.

  • geometry – Geometry for spatial filter. Can be: - A GeoJSON geometry dict (Point, Polygon, Envelope-style bbox) - An Esri JSON geometry string/dict - A bbox string “xmin,ymin,xmax,ymax” - None for no spatial filter

  • geometry_type – Esri geometry type. Common values: esriGeometryPoint, esriGeometryEnvelope, esriGeometryPolygon

  • spatial_rel – Spatial relationship. Default: esriSpatialRelIntersects.

  • where – SQL WHERE clause. Default: “1=1” (all features).

  • out_fields – Comma-separated field names or “*” for all.

  • max_features – Maximum features to return (capped at server max).

  • out_sr – Output spatial reference WKID. Default: 4326 (WGS84).

  • return_count_only – If True, return only the count of matching features.

Returns:

N} if return_count_only.

Return type:

GeoJSON FeatureCollection dict, or {“count”

geeViz.edwLib.query_features_with_pagination(service_name: str, layer_id: int, geometry: dict | str | None = None, geometry_type: str = 'esriGeometryEnvelope', spatial_rel: str = 'esriSpatialRelIntersects', where: str = '1=1', out_fields: str = '*', max_features: int = 5000, out_sr: int = 4326) dict[source]

Query features with automatic pagination to get more than 2000 results.

Same args as query_features, but max_features can exceed the server limit. Returns a combined GeoJSON FeatureCollection.