Skip to content

panoramax

Panoramax related functionality.

PanoramaxClient

Client for fetching Panoramax image metadata via bounding boxes.

Queries the federated catalogue by default, which indexes every Panoramax instance taking part in the federation, so one query covers them all. Pass a single instance to restrict the search to it, or to reach an instance that is not federated.

Records are validated against PanoramaxImage and malformed ones are skipped individually. No authentication is required.

Usage example

from streetscapes.sources.panoramax import PanoramaxClient

client = PanoramaxClient()

bbox: (west, south, east, north)

bbox = (4.899, 52.372, 4.901, 52.374)

Fetch as pandas DataFrame

df = client.fetch_metadata_bbox(bbox)

fetch directly as GeoDataFrame

gdf = client.fetch_metadata_bbox_gpd(bbox)

a single instance rather than the whole federation

osm = PanoramaxClient("https://panoramax.openstreetmap.fr")

__init__(instance=FEDERATED_CATALOGUE, retries=3, timeout=60)

Instantiate the client.

Parameters:

Name Type Description Default
instance

str, optional Base URL of the Panoramax API to query. Defaults to the federated catalogue.

required
retries

int, optional Number of request retries on failure (default is 3).

required
timeout

int, optional Seconds to wait for a response (default is 60).

required

db_fields property

Get schema's fields.

download_image(url, output_dir, image_id, uid=None, skip_existing=True)

Download image from a URL to output_path.

Parameters:

Name Type Description Default
url str

The download URL.

required
output_dir str | Path

Destination directory.

required
image_id int | str | None

Panoramax image ID.

required
uid UUID | None

Image UUID (from the SHA-256 hash).

None
skip_existing bool

Don't re-download existing images.

True

Returns:

Type Description
ImageMeta

Image metadata.

fetch_image_url(image_id)

Fetch the image URL from the Panoramax API by image ID.

fetch_metadata_bbox(bbox, limit=1000, pano_only=False, daytime_only=False)

Fetch metadata for a bounding box and convert to a pandas DataFrame.

Every record is validated against PanoramaxImage before being included; records that fail validation are skipped and reported.

Note:

The search endpoint returns no paging cursor and caps the number of results at MAX_LIMIT, so a bounding box holding more pictures than that cannot be covered completely in one call.

Parameters:

Name Type Description Default
bbox

tuple[float, float, float, float] Bounding box as (west, south, east, north).

required
limit

int Maximum number of images to fetch (default 1000).

required
pano_only

bool Only fetch panoramic images (default False). A single instance cannot filter on this itself, so there the limit applies before the other images are dropped, and fewer may be returned.

required
daytime_only

bool Only keep images captured with the sun at least 2 degrees high. The API cannot filter on this, so the limit applies before the other images are dropped, and fewer may be returned.

required

Returns:

Type Description
DataFrame

pd.DataFrame DataFrame with Panoramax metadata.

fetch_metadata_bbox_gpd(bbox, limit=1000, pano_only=False, daytime_only=False)

Fetch metadata for a bounding box and convert to a GeoDataFrame.

Geometry columns are parsed from WKT and the CRS is set to EPSG:4326.

Parameters:

Name Type Description Default
bbox

tuple[float, float, float, float] Bounding box as (west, south, east, north).

required
limit

int Maximum number of images to fetch (default 1000).

required
pano_only

bool Only fetch panoramic images (default False).

required
daytime_only

bool Only keep images captured in daylight (default False).

required

Returns:

Type Description
GeoDataFrame

gpd.GeoDataFrame GeoDataFrame with Panoramax metadata and geometry columns.

filters_pano property

Tell whether the search endpoint can filter on panoramas itself.

The federated catalogue accepts a filter on the field of view, but single instances reject it as unsupported.

search_url property

Get the URL of this instance's search endpoint.

PanoramaxError

Bases: RuntimeError

Raised when the Panoramax API cannot be reached.

PanoramaxImage

Bases: BaseModel

Panoramax image record, validated against the database schema.

Panoramax serves STAC items, which nest most of what is needed under properties, assets and links, so raw API records are flattened (see _from_api) before the fields below are validated.

Field names and types mirror the panoramax table schema, except for image which is only known after the image itself has been downloaded, and altitude, which Panoramax does not report at all.

to_row()

Get the record as a row for the panoramax table.

validate_records(records)

Validate raw API records, dropping (and reporting) the invalid ones.

Parameters:

Name Type Description Default
records list[dict]

Raw STAC items as returned by the Panoramax API.

required

Returns:

Type Description
list[PanoramaxImage]

The records that passed validation.