# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.8.2 64-bit (''py38'': venv)'
#     name: python3
# ---

# +
import json
import requests
from folium import Map, TileLayer, GeoJson

endpoint = ""
# -

# ### Create Mosaic for the whole collection

# +
# create Mosaic
body = {
    "collections": ["facebook-population-density"],
}

response = requests.post(
    f"{endpoint}/mosaic/register",
    json=body,
).json()
print(r)

# +
m = Map(
    location=(0, 0),
    zoom_start=5
)

# Fetch Tilejson (we HAVE TO add the asset name)
tj_resp = requests.get(
    response['url'],
    params={
        # Info to add to the tilejson response
        "minzoom": 4,
        "maxzoom": 12,
        # query parameter to add to the tile URL
        "assets": "cog",
        "rescale": "0,100",
        "colormap_name": "viridis",
    }
).json()
print(tj_resp)

aod_layer = TileLayer(
    tiles=tj_resp["tiles"][0],
    attr="Mosaic",
    min_zoom=4,
    max_zoom=12,
    max_native_zoom=12,    
)
aod_layer.add_to(m)
m
# -



StarcoderdataJupyterScriptsDedupFiltered