Created
November 21, 2022 23:54
-
-
Save vincentsarago/82cbdb4c45fb94570c48751b46f17e6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"id": "b6633f73", | |
"metadata": {}, | |
"source": [ | |
"### Use Custom Algorithm" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "55915667", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import time\n", | |
"import httpx\n", | |
"\n", | |
"from folium import Map, TileLayer" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "5c65b3d5", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"src_path = \"https://data.geo.admin.ch/ch.swisstopo.swissalti3d/swissalti3d_2019_2573-1085/swissalti3d_2019_2573-1085_0.5_2056_5728.tif\"\n", | |
"endpoint = \"http://127.0.0.1:8081\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "85e4c1e0", | |
"metadata": { | |
"scrolled": true | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{'bounds': [7.090624928537461, 45.916058441028206, 7.1035698381384185, 45.925093000254144], 'minzoom': 15, 'maxzoom': 18, 'band_metadata': [['b1', {'STATISTICS_COVARIANCES': '10685.98787505646', 'STATISTICS_EXCLUDEDVALUES': '-9999', 'STATISTICS_MAXIMUM': '2015.0944824219', 'STATISTICS_MEAN': '1754.471184271', 'STATISTICS_MINIMUM': '1615.8128662109', 'STATISTICS_SKIPFACTORX': '1', 'STATISTICS_SKIPFACTORY': '1', 'STATISTICS_STDDEV': '103.37305197708'}]], 'band_descriptions': [['b1', '']], 'dtype': 'float32', 'nodata_type': 'Nodata', 'colorinterp': ['gray'], 'count': 1, 'height': 2000, 'width': 2000, 'driver': 'GTiff', 'nodata_value': -9999.0, 'overviews': [2, 4, 8]}\n" | |
] | |
} | |
], | |
"source": [ | |
"# Fetch info\n", | |
"print(httpx.get(f\"{endpoint}/cog/info\", params={\"url\": src_path}).json())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "26ef9eef", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{'hillshade': {'name': 'hillshade', 'inputs': {'nbands': {'title': 'Input Nbands', 'default': 1, 'type': 'integer'}}, 'outputs': {'nbands': {'title': 'Output Nbands', 'default': 1, 'type': 'integer'}, 'dtype': {'title': 'Output Dtype', 'default': 'uint8', 'type': 'string'}, 'min': {'title': 'Output Min', 'type': 'array', 'items': {}}, 'max': {'title': 'Output Max', 'type': 'array', 'items': {}}}, 'params': {'azimuth': {'title': 'Azimuth', 'default': 90, 'type': 'integer'}, 'angle_altitude': {'title': 'Angle Altitude', 'default': 90, 'type': 'number'}, 'buffer': {'title': 'Buffer', 'default': 3, 'type': 'integer'}}}, 'contours': {'name': 'contours', 'inputs': {'nbands': {'title': 'Input Nbands', 'default': 1, 'type': 'integer'}}, 'outputs': {'nbands': {'title': 'Output Nbands', 'default': 3, 'type': 'integer'}, 'dtype': {'title': 'Output Dtype', 'default': 'uint8', 'type': 'string'}, 'min': {'title': 'Output Min', 'type': 'array', 'items': {}}, 'max': {'title': 'Output Max', 'type': 'array', 'items': {}}}, 'params': {'increment': {'title': 'Increment', 'default': 35, 'type': 'integer'}, 'thickness': {'title': 'Thickness', 'default': 1, 'type': 'integer'}, 'minz': {'title': 'Minz', 'default': -12000, 'type': 'integer'}, 'maxz': {'title': 'Maxz', 'default': 8000, 'type': 'integer'}}}, 'normalizedIndex': {'name': 'normalizedIndex', 'inputs': {'nbands': {'title': 'Input Nbands', 'default': 2, 'type': 'integer'}}, 'outputs': {'nbands': {'title': 'Output Nbands', 'default': 1, 'type': 'integer'}, 'dtype': {'title': 'Output Dtype', 'default': 'float32', 'type': 'string'}, 'min': {'title': 'Output Min', 'default': [-1.0], 'type': 'array', 'items': {'type': 'number'}}, 'max': {'title': 'Output Max', 'default': [1.0], 'type': 'array', 'items': {'type': 'number'}}}, 'params': {}}, 'terrarium': {'name': 'terrarium', 'inputs': {'nbands': {'title': 'Input Nbands', 'default': 1, 'type': 'integer'}}, 'outputs': {'nbands': {'title': 'Output Nbands', 'default': 3, 'type': 'integer'}, 'dtype': {'title': 'Output Dtype', 'default': 'uint8', 'type': 'string'}, 'min': {'title': 'Output Min', 'type': 'array', 'items': {}}, 'max': {'title': 'Output Max', 'type': 'array', 'items': {}}}, 'params': {}}, 'terrainrgb': {'name': 'terrainrgb', 'inputs': {'nbands': {'title': 'Input Nbands', 'default': 1, 'type': 'integer'}}, 'outputs': {'nbands': {'title': 'Output Nbands', 'default': 3, 'type': 'integer'}, 'dtype': {'title': 'Output Dtype', 'default': 'uint8', 'type': 'string'}, 'min': {'title': 'Output Min', 'type': 'array', 'items': {}}, 'max': {'title': 'Output Max', 'type': 'array', 'items': {}}}, 'params': {'interval': {'title': 'Interval', 'default': 1, 'type': 'integer'}, 'baseval': {'title': 'Baseval', 'default': -10000, 'type': 'integer'}}}}\n" | |
] | |
} | |
], | |
"source": [ | |
"# Fetch algorithms\n", | |
"print(httpx.get(f\"{endpoint}/algorithms\").json())" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 10, | |
"id": "4cc8c900", | |
"metadata": { | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"{'tilejson': '2.2.0', 'version': '1.0.0', 'scheme': 'xyz', 'tiles': ['http://127.0.0.1:8081/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https%3A%2F%2Fdata.geo.admin.ch%2Fch.swisstopo.swissalti3d%2Fswissalti3d_2019_2573-1085%2Fswissalti3d_2019_2573-1085_0.5_2056_5728.tif&algo=hillshade&buffer=3'], 'minzoom': 15, 'maxzoom': 18, 'bounds': [7.090624928537461, 45.916058441028206, 7.1035698381384185, 45.925093000254144], 'center': [7.09709738333794, 45.920575720641175, 15]}\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/html": [ | |
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"<!DOCTYPE html>\n", | |
"<head> \n", | |
" <meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n", | |
" \n", | |
" <script>\n", | |
" L_NO_TOUCH = false;\n", | |
" L_DISABLE_3D = false;\n", | |
" </script>\n", | |
" \n", | |
" <style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>\n", | |
" <style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>\n", | |
" <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>\n", | |
" <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>\n", | |
" <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>\n", | |
" <script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>\n", | |
" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>\n", | |
" \n", | |
" <meta name="viewport" content="width=device-width,\n", | |
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n", | |
" <style>\n", | |
" #map_60bb2fb958a63ea97391f6bc04641907 {\n", | |
" position: relative;\n", | |
" width: 100.0%;\n", | |
" height: 100.0%;\n", | |
" left: 0.0%;\n", | |
" top: 0.0%;\n", | |
" }\n", | |
" </style>\n", | |
" \n", | |
"</head>\n", | |
"<body> \n", | |
" \n", | |
" <div class="folium-map" id="map_60bb2fb958a63ea97391f6bc04641907" ></div>\n", | |
" \n", | |
"</body>\n", | |
"<script> \n", | |
" \n", | |
" var map_60bb2fb958a63ea97391f6bc04641907 = L.map(\n", | |
" "map_60bb2fb958a63ea97391f6bc04641907",\n", | |
" {\n", | |
" center: [45.920575720641175, 7.09709738333794],\n", | |
" crs: L.CRS.EPSG3857,\n", | |
" zoom: 15,\n", | |
" zoomControl: true,\n", | |
" preferCanvas: false,\n", | |
" }\n", | |
" );\n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
" \n", | |
" var tile_layer_71fd85e29fc4d2bfc7f93861b033a041 = L.tileLayer(\n", | |
" "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",\n", | |
" {"attribution": "Data by \\u0026copy; \\u003ca href=\\"http://openstreetmap.org\\"\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\"http://www.openstreetmap.org/copyright\\"\\u003eODbL\\u003c/a\\u003e.", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_60bb2fb958a63ea97391f6bc04641907);\n", | |
" \n", | |
" \n", | |
" var tile_layer_0dcd945997f83ebc0047c3120f69316a = L.tileLayer(\n", | |
" "http://127.0.0.1:8081/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https%3A%2F%2Fdata.geo.admin.ch%2Fch.swisstopo.swissalti3d%2Fswissalti3d_2019_2573-1085%2Fswissalti3d_2019_2573-1085_0.5_2056_5728.tif\\u0026algo=hillshade\\u0026buffer=3",\n", | |
" {"attribution": "Yo!!", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_60bb2fb958a63ea97391f6bc04641907);\n", | |
" \n", | |
"</script>\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>" | |
], | |
"text/plain": [ | |
"<folium.folium.Map at 0x120ad6010>" | |
] | |
}, | |
"execution_count": 10, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"r = httpx.get(\n", | |
" f\"{endpoint}/cog/tilejson.json\",\n", | |
" params = {\n", | |
" \"url\": src_path,\n", | |
" \"algo\": \"hillshade\",\n", | |
" \"buffer\": 3,\n", | |
" }\n", | |
").json()\n", | |
"\n", | |
"bounds = r[\"bounds\"]\n", | |
"m = Map(\n", | |
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n", | |
" zoom_start=r[\"minzoom\"]\n", | |
")\n", | |
"\n", | |
"aod_layer = TileLayer(\n", | |
" tiles=r[\"tiles\"][0],\n", | |
" opacity=1,\n", | |
" attr=\"Yo!!\"\n", | |
")\n", | |
"aod_layer.add_to(m)\n", | |
"m" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 12, | |
"id": "54d674e9", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"<!DOCTYPE html>\n", | |
"<head> \n", | |
" <meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n", | |
" \n", | |
" <script>\n", | |
" L_NO_TOUCH = false;\n", | |
" L_DISABLE_3D = false;\n", | |
" </script>\n", | |
" \n", | |
" <style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>\n", | |
" <style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>\n", | |
" <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>\n", | |
" <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>\n", | |
" <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>\n", | |
" <script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>\n", | |
" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>\n", | |
" \n", | |
" <meta name="viewport" content="width=device-width,\n", | |
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n", | |
" <style>\n", | |
" #map_0839c59c320dcf37ad1203a9adf287fd {\n", | |
" position: relative;\n", | |
" width: 100.0%;\n", | |
" height: 100.0%;\n", | |
" left: 0.0%;\n", | |
" top: 0.0%;\n", | |
" }\n", | |
" </style>\n", | |
" \n", | |
"</head>\n", | |
"<body> \n", | |
" \n", | |
" <div class="folium-map" id="map_0839c59c320dcf37ad1203a9adf287fd" ></div>\n", | |
" \n", | |
"</body>\n", | |
"<script> \n", | |
" \n", | |
" var map_0839c59c320dcf37ad1203a9adf287fd = L.map(\n", | |
" "map_0839c59c320dcf37ad1203a9adf287fd",\n", | |
" {\n", | |
" center: [45.920575720641175, 7.09709738333794],\n", | |
" crs: L.CRS.EPSG3857,\n", | |
" zoom: 15,\n", | |
" zoomControl: true,\n", | |
" preferCanvas: false,\n", | |
" }\n", | |
" );\n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
" \n", | |
" var tile_layer_5b290c0de4861f9795e4dfc855e2d583 = L.tileLayer(\n", | |
" "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",\n", | |
" {"attribution": "Data by \\u0026copy; \\u003ca href=\\"http://openstreetmap.org\\"\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\"http://www.openstreetmap.org/copyright\\"\\u003eODbL\\u003c/a\\u003e.", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_0839c59c320dcf37ad1203a9adf287fd);\n", | |
" \n", | |
" \n", | |
" var tile_layer_6f192c7d6583b3b8a1b714995d113d25 = L.tileLayer(\n", | |
" "http://127.0.0.1:8081/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https%3A%2F%2Fdata.geo.admin.ch%2Fch.swisstopo.swissalti3d%2Fswissalti3d_2019_2573-1085%2Fswissalti3d_2019_2573-1085_0.5_2056_5728.tif\\u0026algo=contours\\u0026algo_params=%7B%22increment%22%3A+20%2C+%22thickness%22%3A+2%2C+%22minz%22%3A+1600%2C+%22maxz%22%3A+2000%7D",\n", | |
" {"attribution": "Yo!!", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_0839c59c320dcf37ad1203a9adf287fd);\n", | |
" \n", | |
"</script>\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>" | |
], | |
"text/plain": [ | |
"<folium.folium.Map at 0x120991e10>" | |
] | |
}, | |
"execution_count": 12, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import json\n", | |
"\n", | |
"r = httpx.get(\n", | |
" f\"{endpoint}/cog/tilejson.json\",\n", | |
" params = {\n", | |
" \"url\": src_path,\n", | |
" \"algo\": \"contours\",\n", | |
" \"algo_params\": json.dumps(\n", | |
" {\n", | |
" \"increment\": 20,\n", | |
" \"thickness\": 2,\n", | |
" \"minz\": 1600,\n", | |
" \"maxz\": 2000\n", | |
" }\n", | |
" ),\n", | |
" }\n", | |
").json()\n", | |
"\n", | |
"bounds = r[\"bounds\"]\n", | |
"m = Map(\n", | |
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n", | |
" zoom_start=r[\"minzoom\"]\n", | |
")\n", | |
"\n", | |
"aod_layer = TileLayer(\n", | |
" tiles=r[\"tiles\"][0],\n", | |
" opacity=1,\n", | |
" attr=\"Yo!!\"\n", | |
")\n", | |
"aod_layer.add_to(m)\n", | |
"m" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"id": "1c80efe0", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"src_path = \"https://njogis-imagery.s3.us-west-2.amazonaws.com/2020/cog/K7A3.tif\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"id": "ced4b27d", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"<!DOCTYPE html>\n", | |
"<head> \n", | |
" <meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n", | |
" \n", | |
" <script>\n", | |
" L_NO_TOUCH = false;\n", | |
" L_DISABLE_3D = false;\n", | |
" </script>\n", | |
" \n", | |
" <style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>\n", | |
" <style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>\n", | |
" <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>\n", | |
" <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>\n", | |
" <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>\n", | |
" <script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>\n", | |
" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>\n", | |
" \n", | |
" <meta name="viewport" content="width=device-width,\n", | |
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n", | |
" <style>\n", | |
" #map_c4e5ade692e2f9cf8ee1111344444aa7 {\n", | |
" position: relative;\n", | |
" width: 100.0%;\n", | |
" height: 100.0%;\n", | |
" left: 0.0%;\n", | |
" top: 0.0%;\n", | |
" }\n", | |
" </style>\n", | |
" \n", | |
"</head>\n", | |
"<body> \n", | |
" \n", | |
" <div class="folium-map" id="map_c4e5ade692e2f9cf8ee1111344444aa7" ></div>\n", | |
" \n", | |
"</body>\n", | |
"<script> \n", | |
" \n", | |
" var map_c4e5ade692e2f9cf8ee1111344444aa7 = L.map(\n", | |
" "map_c4e5ade692e2f9cf8ee1111344444aa7",\n", | |
" {\n", | |
" center: [40.706435250494835, -74.10185996000682],\n", | |
" crs: L.CRS.EPSG3857,\n", | |
" zoom: 14,\n", | |
" zoomControl: true,\n", | |
" preferCanvas: false,\n", | |
" }\n", | |
" );\n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
" \n", | |
" var tile_layer_096b947565f2c428293343aa103932c2 = L.tileLayer(\n", | |
" "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",\n", | |
" {"attribution": "Data by \\u0026copy; \\u003ca href=\\"http://openstreetmap.org\\"\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\"http://www.openstreetmap.org/copyright\\"\\u003eODbL\\u003c/a\\u003e.", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_c4e5ade692e2f9cf8ee1111344444aa7);\n", | |
" \n", | |
" \n", | |
" var tile_layer_1f83a6b0b138c0b83a122b0021c9300b = L.tileLayer(\n", | |
" "http://127.0.0.1:8081/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https%3A%2F%2Fnjogis-imagery.s3.us-west-2.amazonaws.com%2F2020%2Fcog%2FK7A3.tif\\u0026bidx=4\\u0026bidx=1\\u0026bidx=2",\n", | |
" {"attribution": "Yo!!", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_c4e5ade692e2f9cf8ee1111344444aa7);\n", | |
" \n", | |
"</script>\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>" | |
], | |
"text/plain": [ | |
"<folium.folium.Map at 0x120540610>" | |
] | |
}, | |
"execution_count": 17, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"r = httpx.get(\n", | |
" f\"{endpoint}/cog/tilejson.json\",\n", | |
" params = {\n", | |
" \"url\": src_path,\n", | |
" # Data is stored as RGB-NIR\n", | |
" \"bidx\": [4, 1, 2],\n", | |
" }\n", | |
").json()\n", | |
"\n", | |
"bounds = r[\"bounds\"]\n", | |
"m = Map(\n", | |
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n", | |
" zoom_start=r[\"minzoom\"]\n", | |
")\n", | |
"\n", | |
"aod_layer = TileLayer(\n", | |
" tiles=r[\"tiles\"][0],\n", | |
" opacity=1,\n", | |
" attr=\"Yo!!\"\n", | |
")\n", | |
"aod_layer.add_to(m)\n", | |
"m" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 19, | |
"id": "3f2ba1c4", | |
"metadata": { | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div style=\"width:100%;\"><div style=\"position:relative;width:100%;height:0;padding-bottom:60%;\"><span style=\"color:#565656\">Make this Notebook Trusted to load map: File -> Trust Notebook</span><iframe srcdoc=\"<!DOCTYPE html>\n", | |
"<head> \n", | |
" <meta http-equiv="content-type" content="text/html; charset=UTF-8" />\n", | |
" \n", | |
" <script>\n", | |
" L_NO_TOUCH = false;\n", | |
" L_DISABLE_3D = false;\n", | |
" </script>\n", | |
" \n", | |
" <style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>\n", | |
" <style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>\n", | |
" <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.js"></script>\n", | |
" <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>\n", | |
" <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>\n", | |
" <script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"/>\n", | |
" <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"/>\n", | |
" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>\n", | |
" <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>\n", | |
" \n", | |
" <meta name="viewport" content="width=device-width,\n", | |
" initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />\n", | |
" <style>\n", | |
" #map_9befed005ad664b0ab26cdc8ccd750b7 {\n", | |
" position: relative;\n", | |
" width: 100.0%;\n", | |
" height: 100.0%;\n", | |
" left: 0.0%;\n", | |
" top: 0.0%;\n", | |
" }\n", | |
" </style>\n", | |
" \n", | |
"</head>\n", | |
"<body> \n", | |
" \n", | |
" <div class="folium-map" id="map_9befed005ad664b0ab26cdc8ccd750b7" ></div>\n", | |
" \n", | |
"</body>\n", | |
"<script> \n", | |
" \n", | |
" var map_9befed005ad664b0ab26cdc8ccd750b7 = L.map(\n", | |
" "map_9befed005ad664b0ab26cdc8ccd750b7",\n", | |
" {\n", | |
" center: [40.706435250494835, -74.10185996000682],\n", | |
" crs: L.CRS.EPSG3857,\n", | |
" zoom: 14,\n", | |
" zoomControl: true,\n", | |
" preferCanvas: false,\n", | |
" }\n", | |
" );\n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
" \n", | |
" var tile_layer_7cc283344003b9e78c63b0d5eb903e01 = L.tileLayer(\n", | |
" "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",\n", | |
" {"attribution": "Data by \\u0026copy; \\u003ca href=\\"http://openstreetmap.org\\"\\u003eOpenStreetMap\\u003c/a\\u003e, under \\u003ca href=\\"http://www.openstreetmap.org/copyright\\"\\u003eODbL\\u003c/a\\u003e.", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_9befed005ad664b0ab26cdc8ccd750b7);\n", | |
" \n", | |
" \n", | |
" var tile_layer_b89e65c1a3ce9f934c5635d009683e6e = L.tileLayer(\n", | |
" "http://127.0.0.1:8081/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?url=https%3A%2F%2Fnjogis-imagery.s3.us-west-2.amazonaws.com%2F2020%2Fcog%2FK7A3.tif\\u0026bidx=1\\u0026bidx=4\\u0026algo=normalizedIndex\\u0026rescale=0%2C1\\u0026colormap_name=greens",\n", | |
" {"attribution": "Yo!!", "detectRetina": false, "maxNativeZoom": 18, "maxZoom": 18, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}\n", | |
" ).addTo(map_9befed005ad664b0ab26cdc8ccd750b7);\n", | |
" \n", | |
"</script>\" style=\"position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;\" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe></div></div>" | |
], | |
"text/plain": [ | |
"<folium.folium.Map at 0x127632330>" | |
] | |
}, | |
"execution_count": 19, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"r = httpx.get(\n", | |
" f\"{endpoint}/cog/tilejson.json\",\n", | |
" params = {\n", | |
" \"url\": src_path,\n", | |
" # Data is stored as RGB-NIR\n", | |
" \"bidx\": [1, 4],\n", | |
" \"algo\": \"normalizedIndex\",\n", | |
" \"rescale\": \"0,1\",\n", | |
" \"colormap_name\": \"greens\"\n", | |
" }\n", | |
").json()\n", | |
"\n", | |
"bounds = r[\"bounds\"]\n", | |
"m = Map(\n", | |
" location=((bounds[1] + bounds[3]) / 2,(bounds[0] + bounds[2]) / 2),\n", | |
" zoom_start=r[\"minzoom\"]\n", | |
")\n", | |
"\n", | |
"aod_layer = TileLayer(\n", | |
" tiles=r[\"tiles\"][0],\n", | |
" opacity=1,\n", | |
" attr=\"Yo!!\"\n", | |
")\n", | |
"aod_layer.add_to(m)\n", | |
"m" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "0398886c", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3 with Fil", | |
"language": "python", | |
"name": "filprofile" | |
}, | |
"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.9.13" | |
}, | |
"vscode": { | |
"interpreter": { | |
"hash": "8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1" | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment