Skip to content

Instantly share code, notes, and snippets.

@emileten
Created June 23, 2023 09:14
Show Gist options
  • Save emileten/02f2c8027670996949bd709608481361 to your computer and use it in GitHub Desktop.
Save emileten/02f2c8027670996949bd709608481361 to your computer and use it in GitHub Desktop.
create CCI mosaic
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create a tititler pgstac mosaic\n",
"\n",
"\n",
"### Python requirements\n",
"\n",
"```\n",
"pip install httpx folium pypgstac geojson_pydantic==0.5.0\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'database_online': True}\n"
]
}
],
"source": [
"import json\n",
"import httpx\n",
"import requests\n",
"from folium import Map, TileLayer, GeoJson\n",
"\n",
"from geojson_pydantic import Feature, Polygon\n",
"\n",
"endpoint = \"https://0x78e0jyvl.execute-api.us-west-2.amazonaws.com\"\n",
"\n",
"print(requests.get(f\"{endpoint}/healthz\").json())"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"### Create the mosaic by registering a STAC search"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'searchid': '3f4af3705f7801257a6bc856d662440a', 'links': [{'rel': 'metadata', 'type': 'application/json', 'href': 'https://0x78e0jyvl.execute-api.us-west-2.amazonaws.com/mosaic/3f4af3705f7801257a6bc856d662440a/info'}, {'rel': 'tilejson', 'type': 'application/json', 'href': 'https://0x78e0jyvl.execute-api.us-west-2.amazonaws.com/mosaic/3f4af3705f7801257a6bc856d662440a/tilejson.json'}]}\n"
]
}
],
"source": [
"search_request = {\n",
" # Filter collection\n",
" \"collections\": [\"ESACCI_Biomass_L4_AGB_V4_100m\"],\n",
" \"datetime\":\"2020-01-01T00:00:00Z\",\n",
" \"filter-lang\": \"cql-json\",\n",
"}\n",
"\n",
"response = httpx.post(\n",
" f\"{endpoint}/mosaic/register\", json=search_request,\n",
").json()\n",
"print(response)\n",
"\n",
"searchid = response[\"searchid\"]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
},
"vscode": {
"interpreter": {
"hash": "2590a9e34ee6c8bdce5141410f2a072bbabd2a859a8a48acdaa85720923a90ef"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment