in src/mapillary/interface.py [0:0]
def map_features_in_shape(shape: dict, **filters: dict):
"""
Extracts all map features within a shape/polygon
Format::
>>> _ = {
... "type": "FeatureCollection",
... "features": [
... {
... "type": "Feature",
... "properties": {},
... "geometry": {
... "type": "Polygon",
... "coordinates": [
... [
... [
... 7.2564697265625,
... 43.69716905314008
... ],
... ...
... ]
... ]
... }
... }
... ]
... }
:param shape: A shape that describes features, formatted as a geojson
:type shape: dict
:param filters: Different filters that may be applied to the output, defaults to {}
:type filters: dict (kwargs)
:param filters.zoom: The zoom level of the tiles to obtain, defaults to 14
:type filters.zoom: int
:param filters.max_captured_at: The max date. Format from 'YYYY', to 'YYYY-MM-DDTHH:MM:SS'
:type filters.max_captured_at: str
:param filters.min_captured_at: The min date. Format from 'YYYY', to 'YYYY-MM-DDTHH:MM:SS'
:type filters.min_captured_at: str
:param filters.image_type: The tile image_type to be obtained, either as 'flat', 'pano'
(panoramic), or 'all'. See https://www.mapillary.com/developer/api-documentation/ under
'image_type Tiles' for more information
:type filters.image_type: str
:param filters.compass_angle: The compass angle of the image
:type filters.compass_angle: int
:param filters.sequence_id: ID of the sequence this image belongs to
:type filters.sequence_id: str
:param filters.organization_id: ID of the organization this image belongs to. It can be absent
:type filters.organization_id: str
:return: A GeoJSON object
:rtype: mapillary.models.geojson.GeoJSON
Usage::
>>> import mapillary as mly
>>> import json
>>> mly.interface.set_access_token('MLY|XXX')
>>> data = mly.interface.map_features_in_shape(json.load(open('polygon.geojson', mode='r')))
>>> open('output_geojson.geojson', mode='w').write(data.encode())
"""
if isinstance(shape, str):
if "http" in shape:
shape = json.loads(requests.get(shape).content.decode("utf-8"))
return image.shape_features_controller(shape=shape, is_image=False, filters=filters)