def load_metadata(filename: str) -> pd.DataFrame:
"""
Read the metadata.csv at filename, convert it to a pandas dataframe,
and perform some cleaning and conversions to the data.
"""
df = pd.read_csv(filename, encoding="ISO-8859-1") # government not using utf8...
orig_cols = [
"Photo ID",
"Film Length and Width",
"Focal Length",
"Center Latitude dec",
"Center Longitude dec",
"Flying Height in Feet",
"SW Corner Long dec",
"SW Corner Lat dec",
"NE Corner Long dec",
"NE Corner Lat dec",
]
new_cols = ["id", "film", "focal", "lat", "lon", "alt", "xmin", "ymin", "xmax", "ymax"]
df = df[orig_cols]
df.columns = new_cols
df["film"] = df["film"].apply(clean_film_size) # eg 120.1mm x 120.1mm -> 120.1
df["focal"] = df["focal"].apply(clean_focal_len) # eg 123.4mm -> 123.4
df["alt"] = df["alt"].apply(ft_m) # convert to meters
df["file"] = df["id"].apply(filename_from_photoid) # filename
return df