zensvi.metadata.KVMetadata

class zensvi.metadata.KVMetadata(path_input: str | pathlib.Path, log_path: str | pathlib.Path | None = None)

Bases: zensvi.metadata.base_metadata.BaseMetadata

Compute metadata for a KartaView (KV) dataset.

Normalizes the columns of a KartaView kv_pids.csv (produced by KVDownloader) to the schema expected by BaseMetadata:

  • shotDate ("%Y-%m-%d %H:%M:%S%.f", UTC) -> captured_at (ms since Unix epoch)

  • heading -> compass_angle

  • sequenceId -> sequence_id

  • userId -> creator_id

  • orgCode -> organization_id

  • id, lat, lon, is_pano are used as-is.

Parameters:
  • path_input (Union[str, Path]) – path to the input CSV file (e.g. kv_pids.csv).

  • log_path (Union[str, Path], optional) – Path to the log file. Defaults to None.

compute_metadata(unit: str = 'image', grid_resolution: int = 7, coverage_buffer: int = 50, indicator_list: str = 'all', path_output: str | pathlib.Path | None = None, max_distance: int = 50) pandas.DataFrame

Compute metadata for the dataset.

Parameters:
  • unit (str) – The unit of analysis. Defaults to “image”.

  • grid_resolution (int) – The resolution of the H3 grid. Defaults to 7.

  • indicator_list (str) – List of indicators to compute metadata for. Use space- separated string of indicators or “all”. Options for image-level metadata: “year”, “month”, “day”, “hour”, “day_of_week”, “relative_angle”, “h3_id”, “speed_kmh”. Options for grid-level metadata: “coverage”, “count”, “days_elapsed”, “most_recent_date”, “oldest_date”, “number_of_years”, “number_of_months”, “number_of_days”, “number_of_hours”, “number_of_days_of_week”, “number_of_daytime”, “number_of_nighttime”, “number_of_spring”, “number_of_summer”, “number_of_autumn”, “number_of_winter”, “average_compass_angle”, “average_relative_angle”, “average_is_pano”, “number_of_users”, “number_of_sequences”, “number_of_organizations”, “average_speed_kmh”. Defaults to “all”.

  • path_output (Union[str, Path]) – Path to save the output metadata. Defaults to None.

  • max_distance (int) – The maximum distance to search for the nearest street segment. Defaults to 50.

Returns:

A DataFrame containing the computed metadata.

Return type:

pd.DataFrame