FRED#

fetchez.fred#

Fetches Remote Elevation Datalist (FRED)

Handles the indexing, storage, and spatial querying of remote datasets that lack a public API but provide file lists (e.g., NCEI Thredds, USACE).

copyright:
  1. 2010 - 2026 Regents of the University of Colorado

license:

MIT, see LICENSE for more details.

class fetchez.fred.FRED(name='FRED', local=False)[source]#

Bases: object

FRED (Fetches Remote Elevation Datalist) manages a local GeoJSON-based index of remote files. It allows spatial queries to determine which files to download.

Parameters:
  • name (str, default: 'FRED')

  • local (bool, default: False)

SCHEMA = ['Name', 'ID', 'Date', 'Agency', 'MetadataLink', 'MetadataDate', 'DataLink', 'IndexLink', 'Link', 'DataType', 'DataSource', 'Resolution', 'HorizontalDatum', 'VerticalDatum', 'LastUpdate', 'Etcetra', 'Info']#
__init__(name='FRED', local=False)[source]#
Parameters:
  • name (str, default: 'FRED')

  • local (bool, default: False)

save()[source]#

Save the current features to the GeoJSON file.

add_survey(geom, **kwargs)[source]#

Add a single survey entry to the FRED database.

Parameters:
  • geom (Dict) – GeoJSON geometry dictionary (e.g., {‘type’: ‘Polygon’, ‘coordinates’: …})

  • **kwargs – Attributes matching the schema.

search(region=None, where=[], layer=None)[source]#

Search for data in the reference vector file.

Parameters:
  • region (Optional[Tuple[float, float, float, float]], default: None) – Tuple (xmin, xmax, ymin, ymax) from spatial.parse_region

  • where (List[str], default: []) – List of simple SQL-style filters (e.g. “Agency = ‘NOAA’”) (Currently supports simple equality checks for simplicity without SQL parser)

  • layer (Optional[str], default: None) – Filter by ‘DataSource’ field (e.g., ‘ncei_thredds’)

Returns:

List[Dict] – List of dictionaries containing the properties of matching features.

ingest(source_file, field_map=None, wipe=False)[source]#

Ingest a file listing (CSV or JSON) into the FRED index.

Parameters:
  • source_file (str) – Path to the CSV or JSON file.

  • field_map (Optional[Dict[str, str]], default: None) – Dictionary mapping Input_Header -> FRED_Field. Example: {‘file_url’: ‘DataLink’, ‘file_name’: ‘Name’}

  • wipe (bool, default: False) – If True, clears existing index before ingesting.