Spaces:
Running
Running
File size: 5,549 Bytes
9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 9a5d6f4 c89fcc1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import leafmap.foliumap as leafmap
import streamlit as st
st.set_page_config(layout="wide", page_title="Protected Areas Explorer", page_icon=":globe:")
# +
public = "https://minio.carlboettiger.info/shared-data/pad/public.pmtiles"
tribal = "https://minio.carlboettiger.info/shared-data/pad/tribal.pmtiles"
private = "https://minio.carlboettiger.info/shared-data/pad/private.pmtiles"
mixed = "https://minio.carlboettiger.info/shared-data/pad/mixed.pmtiles"
red = "#850101"
purple = "#BF40BF"
green = "#005a00"
blue = "#3388ff"
public_style = {
"version": 8,
"sources": {
"public": {
"type": "vector",
"url": "pmtiles://" + public,
"attribution": "US PAD v3"}},
"layers": [{
"id": "public",
"source": "public",
"source-layer": "public_protected",
"type": "fill",
"paint": {"fill-color": blue, "fill-opacity": 0.5}}]}
private_style = {
"version": 8,
"sources": {
"private": {
"type": "vector",
"url": "pmtiles://" + private,
"attribution": "US PAD v3",}},
"layers": [
{
"id": "private",
"source": "private",
"source-layer": "private_protected",
"type": "fill",
"paint": {"fill-color": red, "fill-opacity": 0.5}}]}
tribal_style = {
"version": 8,
"sources": {
"tribal": {
"type": "vector",
"url": "pmtiles://" + tribal,
"attribution": "US PAD v3"}},
"layers": [{
"id": "tribal",
"source": "tribal",
"source-layer": "tribal_protected",
"type": "fill",
"paint": {"fill-color": purple, "fill-opacity": 0.6}}]}
mixed_style = {
"version": 8,
"sources": {
"mixed": {
"type": "vector",
"url": "pmtiles://" + mixed,
"attribution": "US PAD v3"}},
"layers": [{
"id": "mixed",
"source": "mixed",
"source-layer": "mixed_protected",
"type": "fill",
"paint": {"fill-color": green, "fill-opacity": 0.6}}]}
# -
## Tooltip layer -- hack
combined_style = {
"version": 8,
"sources": {
"public": {
"type": "vector",
"url": "pmtiles://" + public,
"attribution": "PMTiles"},
"tribal": {
"type": "vector",
"url": "pmtiles://" + tribal,
"attribution": "PMTiles"},
"private": {
"type": "vector",
"url": "pmtiles://" + private,
"attribution": "PMTiles"},
"mixed": {
"type": "vector",
"url": "pmtiles://" + mixed,
"attribution": "PMTiles"}},
"layers": [{
"id": "mixed",
"source": "mixed",
"source-layer": "mixed_protected",
"type": "fill",
"paint": {"fill-color": green, "fill-opacity": 0.}},
{
"id": "tribal",
"source": "tribal",
"source-layer": "tribal_protected",
"type": "fill",
"paint": {"fill-color": purple, "fill-opacity": 0.}
},
{
"id": "public",
"source": "public",
"source-layer": "public_protected",
"type": "fill",
"paint": {"fill-color": blue, "fill-opacity": 0.}
},
{
"id": "private",
"source": "private",
"source-layer": "private_protected",
"type": "fill",
"paint": {"fill-color": red, "fill-opacity": 0.}}]}
# +
m = leafmap.Map(center=[35, -100], zoom=3)
m.add_basemap("CartoDB.DarkMatter")
m.add_tile_layer(
url="https://minio.carlboettiger.info/shared-data/mobi-tiles/grey/{z}/{x}/{y}.png",
name="Imperiled Species Richness (Greyscale)",
attribution="NatureServe",
opacity=0.99
)
m.add_pmtiles( public, name="Public", style=public_style, overlay=True, show=True, zoom_to_layer=False)
m.add_pmtiles(private, name="Private", style=private_style, overlay=True, show=True, zoom_to_layer=False)
m.add_pmtiles(tribal, name="Tribal", style=tribal_style, overlay=True, show=True, zoom_to_layer=False)
m.add_pmtiles(mixed, name="Mixed", style=mixed_style, overlay=True, show=True, zoom_to_layer=False)
m.add_pmtiles(tribal, name="tooltip", style=combined_style, overlay=True, show=True, zoom_to_layer=False)
m.to_streamlit(height=900)
# +
st.write("# MOBI Species Richness (Light theme)")
# style = leafmap.pmtiles_style(url) # Use default style
m = leafmap.Map(center=[35, -100], zoom=4)
m.add_basemap("Esri.WorldGrayCanvas")
m.add_tile_layer(
url="https://minio.carlboettiger.info/shared-data/mobi-tiles/red/{z}/{x}/{y}.png",
name="MOBI",
attribution="NatureServe",
opacity=0.9
)
m.add_pmtiles(
tribal, name="PMTiles", style=style, overlay=True, show=True, zoom_to_layer=False
)
m.to_streamlit(height=900)
|