How to analyze metadata

zensvi.metadata: A module to analyze metadata from Mapillary

This sub-package for metadata analysis is built upon the basic metadata provided by Mapillary (such as capture time, camera parameters, and spatial coordinates) and further augments it by computing additional features. The package provides solutions for comprehensive metadata analysis at three levels:

  1. image-level

  2. grid-level

  3. street-level analyses

Preparation

# If zen-svi is not installed
%pip install --upgrade zensvi 

import zensvi

print(zensvi.__version__)
# Import the required libraries
from zensvi.metadata import MLYMetadata
import os

Image-level metadata analysis

List of metadata fields:

  • year: Year of the image

  • month: Month of the image

  • day: Day of the image

  • hour: Hour of the image

  • day_of_week: Day of the week of the image

  • daytime_nighttime: Daytime or nighttime of the image

  • season: Season of the image

  • relative_angle: Relative angle of the image with respect to the street

  • h3_id: H3 ID of the image from level 0 to 15

  • speed_kmh: Speed of the vehicle when the image was captured

# Preparation of the input data
path_input = "input_csv_file" #input CSV file downloaded with the images from MLY
path_output="./metadata" 
if not os.path.exists(path_output):
    os.makedirs(path_output)
# Image-level metadata analysis
mly_metadata = MLYMetadata(path_input)
mly_metadata.compute_metadata(
    unit="image", # unit of the metadata
    indicator_list="all", # list of indicators to compute. You can specify a list of indicators in space-separated format, e.g., "year month day" or "all" to compute all indicators
    path_output=path_output # path to the output file
)

Street-level and grid-level metadata analysis

List of metadata fields:

  • coverage: Coverage of street view images. For street-level metadata, it is the coverage of the street in terms of length covered by user-defined buffers from street view images. For grid-level metadata, it is the coverage of the grid in terms of area covered by user-defined buffers from street view images.

  • count: Count of the street view images. For street-level metadata, it is the count of the street view images close to the street. For grid-level metadata, it is the count of the street view images in the grid.

  • days_elapsed: Number of days elapsed between the oldest and most recent street view images.

  • most_recent_date: Most recent date of the street view images.

  • oldest_date: Oldest date of the street view images.

  • number_of_years: Number of unique years of the street view images.

  • number_of_months: Number of unique months of the street view images.

  • number_of_days: Number of unique days of the street view images.

  • number_of_hours: Number of unique hours of the street view images.

  • number_of_days_of_week: Number of unique days of the week of the street view images.

  • number_of_daytime: Number of daytime street view images. This is computed based on the sunrise and sunset times of the location.

  • number_of_nighttime: Number of nighttime street view images. This is computed based on the sunrise and sunset times of the location.

  • number_of_spring: Number of spring street view images. This is computed based on the season of the location.

  • number_of_summer: Number of summer street view images. This is computed based on the season of the location.

  • number_of_autumn: Number of autumn street view images. This is computed based on the season of the location.

  • number_of_winter: Number of winter street view images. This is computed based on the season of the location.

  • average_compass_angle: Average compass angle of the street view images.

  • average_relative_angle: Average relative angle of the street view images.

  • average_is_pano: Average ratio of panoramic street view images.

  • number_of_users: Number of unique users of the street view images.

  • number_of_sequences: Number of unique sequences of the street view images.

  • number_of_organizations: Number of unique organizations of the street view images.

  • average_speed_kmh: Average speed of camera when the street view images were captured.

Street-level metadata analysis

# Preparation of the input data
path_input = "input_csv_file" #input CSV file downloaded with the images from MLY
path_output="./metadata" 
if not os.path.exists(path_output):
    os.makedirs(path_output)
#Street Level Metadata
mly_metadata = MLYMetadata(path_input)
mly_metadata.compute_metadata(
    unit="street",  # unit of the metadata
    indicator_list="all",  # list of indicators to compute. You can specify a list of indicators in space-separated format, e.g., "coverage count days_elapsed" or "all" to compute all indicators
    coverage_buffer=50,  # buffer size in meters for computing coverage
    path_output=path_output,  # path to the output file
)

Grid-level metadata analysis

# Preparation of the input data
path_input = "input_csv_file" #input CSV file downloaded with the images from MLY
path_output="./metadata" 
if not os.path.exists(path_output):
    os.makedirs(path_output)
#Grid Level Metadata
mly_metadata = MLYMetadata(path_input)
mly_metadata.compute_metadata(
    unit="grid",  # unit of the metadata
    grid_resolution=7,  # resolution of the grid in terms of H3 resolution (0-15) to aggregate the metadata
    indicator_list="all",  # list of indicators to compute. You can specify a list of indicators in space-separated format, e.g., "coverage count days_elapsed" or "all" to compute all indicators
    coverage_buffer=50,  # buffer size in meters for computing coverage
    path_output=path_output,  # path to the output file
)