File size: 15,057 Bytes
dd06071
fb3804f
 
 
c3971fb
 
fb3804f
c3971fb
 
 
fb3804f
dd06071
 
fb3804f
dd06071
c3971fb
 
 
 
 
 
 
 
dd06071
fb3804f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd06071
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d53ca7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd06071
593d846
3fac395
5dc4444
 
 
 
 
dd06071
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3fac395
56784d5
 
dd06071
 
fb3804f
dd06071
 
 
 
 
3fac395
56784d5
 
dd06071
 
 
 
 
 
 
3fac395
56784d5
 
dd06071
 
 
 
 
 
 
 
 
3fac395
56784d5
 
dd06071
 
 
3fac395
dd06071
 
 
 
56784d5
 
 
 
dd06071
 
3fac395
 
 
 
56784d5
 
 
 
593d846
 
56784d5
3fac395
 
 
56784d5
3fac395
 
 
 
 
5dc4444
3fac395
5dc4444
 
 
 
 
 
 
e5c3ed4
3fac395
 
e1041f5
5dc4444
 
3fac395
5dc4444
 
3fac395
56784d5
 
3fac395
 
fb3804f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dd06071
e1041f5
56784d5
593d846
3fac395
fb3804f
 
dd06071
 
 
fb3804f
dd06071
 
 
fb3804f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e1041f5
 
fb3804f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e1041f5
 
 
dd06071
 
e1041f5
56784d5
593d846
3fac395
fb3804f
 
dd06071
 
fb3804f
 
3fac395
dd06071
 
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# urls for main layer 
# ca_parquet = "https://huggingface.co/datasets/boettiger-lab/ca-30x30/resolve/da85dd9ca1c774d4ddf821555e3c3c9e13c9b857/ca-30x30.parquet"
# ca_pmtiles = "https://huggingface.co/datasets/boettiger-lab/ca-30x30/resolve/896db6c9a37488ee7c53ee56df67b3ccfd44d150/ca-30x30.pmtiles"

ca_parquet = 'https://minio.carlboettiger.info/public-ca30x30/ca-30x30-cbn.parquet'
ca_pmtiles = 'https://minio.carlboettiger.info/public-ca30x30/ca-30x30-cbn.pmtiles'

# computed by taking the sum of all the acres in this file:
# https://minio.carlboettiger.info/public-ca30x30/CBN-data/Progress_data_new_protection/Land_Status_Zone_Ecoregion_Counties/all_regions_reGAP_county_eco.parquet
ca_area_acres = 101523750.68856516 

style_choice = "GAP Status Code"

from utils import get_url
# urls for additional data layers 
# url_sr = "https://huggingface.co/datasets/boettiger-lab/ca-30x30/resolve/main/species-richness-ca/{z}/{x}/{y}.png"
# url_rsr = "https://huggingface.co/datasets/boettiger-lab/ca-30x30/resolve/main/range-size-rarity/{z}/{x}/{y}.png"
# url_irr_carbon = "https://huggingface.co/datasets/boettiger-lab/ca-30x30/resolve/main/ca_irrecoverable_c_2018_cog.tif"
# url_man_carbon = "https://huggingface.co/datasets/boettiger-lab/ca-30x30/resolve/main/ca_manageable_c_2018_cog.tif"
# url_justice40 = "https://data.source.coop/cboettig/justice40/disadvantaged-communities.pmtiles"
# url_calfire = 'https://minio.carlboettiger.info/public-fire/calfire-2023.pmtiles'
# url_rxburn = 'https://minio.carlboettiger.info/public-fire/calfire-rxburn-2023.pmtiles'
# url_svi = 'https://minio.carlboettiger.info/public-data/social-vulnerability/2022/SVI2022_US_tract.pmtiles'


#vector data 
url_ACE_rarerank_statewide = get_url('ACE_biodiversity/ACE_rarerank_statewide','ACE_rarerank_statewide.pmtiles')
url_ACE_rarerank_ecoregion = get_url('ACE_biodiversity/ACE_rarerank_ecoregion','ACE_rarerank_ecoregion.pmtiles')
url_ACE_biorank_statewide = get_url('ACE_biodiversity/ACE_biorank_statewide','ACE_biorank_statewide.pmtiles')
url_ACE_biorank_ecoregion = get_url('ACE_biodiversity/ACE_biorank_ecoregion','ACE_biorank_ecoregion.pmtiles')

url_ACE_amph_richness = get_url('ACE_biodiversity/ACE_amphibian_richness','ACE_amphibian_richness.pmtiles')
url_ACE_reptile_richness = get_url('ACE_biodiversity/ACE_reptile_richness','ACE_reptile_richness.pmtiles')
url_ACE_bird_richness = get_url('ACE_biodiversity/ACE_bird_richness','ACE_bird_richness.pmtiles')
url_ACE_mammal_richness = get_url('ACE_biodiversity/ACE_mammal_richness','ACE_mammal_richness.pmtiles')
url_ACE_rare_amphibian_richness = get_url('ACE_biodiversity/ACE_rare_amphibian_richness','ACE_rare_amphibian_richness.pmtiles')
url_ACE_rare_reptile_richness = get_url('ACE_biodiversity/ACE_rare_reptile_richness','ACE_rare_reptile_richness.pmtiles')
url_ACE_rare_bird_richness = get_url('ACE_biodiversity/ACE_rare_bird_richness','ACE_rare_bird_richness.pmtiles')
url_ACE_rare_mammal_richness = get_url('ACE_biodiversity/ACE_rare_mammal_richness','ACE_rare_mammal_richness.pmtiles')
url_ACE_endemic_amphibian_richness = get_url('ACE_biodiversity/ACE_endemic_amphibian_richness','ACE_endemic_amphibian_richness.pmtiles')
url_ACE_endemic_reptile_richness = get_url('ACE_biodiversity/ACE_endemic_reptile_richness','ACE_endemic_reptile_richness.pmtiles')
url_ACE_endemic_bird_richness = get_url('ACE_biodiversity/ACE_endemic_bird_richness','ACE_endemic_bird_richness.pmtiles')
url_ACE_endemic_mammal_richness = get_url('ACE_biodiversity/ACE_endemic_mammal_richness','ACE_endemic_mammal_richness.pmtiles')

url_wetlands = get_url('Freshwater_resources/Wetlands','CA_wetlands.pmtiles')
url_fire = get_url('Climate_risks/Historical_fire_perimeters','calfire_2023.pmtiles')
url_farmland = get_url('NBS_agriculture/Farmland','Farmland_2018.pmtiles')
url_grazing = get_url('NBS_agriculture/Lands_suitable_grazing','Grazing_land_2018.pmtiles')
url_DAC = get_url('Progress_data_new_protection/DAC','DAC_2022.pmtiles')
url_low_income = get_url('Progress_data_new_protection/Low_income_communities','low_income_CalEnviroScreen4.pmtiles')

# raster data
url_climate_zones = get_url('Climate_zones', 'climate_zones_10_processed_COG.tif')
url_habitat = get_url('Habitat', 'CWHR13_2022_processed_COG.tif')
url_plant_richness = get_url('Biodiversity_unique/Plant_richness', 'species_D_processed_COG.tif')
url_endemic_plant_richness = get_url('Biodiversity_unique/Rarityweighted_endemic_plant_richness', 'endemicspecies_E_processed_COG.tif')
url_resilient_conn_network = get_url('Connectivity_resilience/Resilient_connected_network_allcategories', 
                                 'rcn_wIntactBioCat_caOnly_2020-10-27_processed_COG.tif')



# colors for plotting 
private_access_color = "#DE881E" # orange 
public_access_color = "#3388ff" # blue
tribal_color = "#BF40BF" # purple
mixed_color = "#005a00" # green
year2023_color = "#26542C" # green
year2024_color = "#F3AB3D" # orange 
federal_color = "#529642" # green
state_color = "#A1B03D" # light green
local_color = "#365591" # blue
special_color = "#0096FF" # blue
private_color = "#7A3F1A" # brown
joint_color = "#DAB0AE" # light pink
county_color = "#DE3163" # magenta
city_color = "#ADD8E6" #light blue
hoa_color = "#A89BBC" # purple
nonprofit_color =  "#D77031" #orange
justice40_color =  "#00008B" #purple
svi_color = "#1bc7c3" #cyan
white =  "#FFFFFF" 


# github logo 
github_logo = 'M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z'
github_html = f"""
    <span class='medium-font-sidebar'>
        <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' class='bi bi-github ' 
            style='height:1em;width:1em;fill:currentColor;vertical-align:-0.125em;margin-right:4px;'  
            aria-hidden='true' role='img'>
            <path d='{github_logo}'></path>
        </svg>
        <span>Source Code:</span>
        <a href='https://github.com/boettiger-lab/ca-30x30' target='_blank'>https://github.com/boettiger-lab/ca-30x30</a>
    </span>
"""


# gap codes 3 and 4 are off by default. 
default_boxes = {
    0: False,
    # 3: False,
    # 4: False,
    # "other-conserved":False,
    # "unknown":False,
    # "non-conserved":False
}

# Maplibre styles. (should these be functions?)
manager = {
    'property': 'manager_type',
    'type': 'categorical',
    'stops': [
        ['Federal', federal_color],
        ['State', state_color],
        ['Non Profit', nonprofit_color],
        ['Special District', special_color],
        ['Unknown', "#bbbbbb"],
        ['County', county_color],
        ['City', city_color],
        ['Joint', joint_color],
        ['Tribal', tribal_color],
        ['Private', private_color],
        ['HOA', hoa_color],
    ],
    'default': white
}


easement = {
    'property': 'easement',
    'type': 'categorical',
    'stops': [
        ['True', private_access_color],
        ['False', public_access_color],
    ],
    'default': white
}

year = {
    'property': 'established',
    'type': 'categorical',
    'stops': [
        ['pre-2024', year2023_color],
        ['2024', year2024_color],
    ],
    'default': white
}

access = {
    'property': 'access_type',
    'type': 'categorical',
    'stops': [
        ['Open Access', public_access_color],
        ['No Public Access', private_access_color],
        ['Unknown Access', "#bbbbbb"],
        ['Restricted Access', tribal_color],
    ],
    'default': white
}

gap = {
    'property': 'gap_code',
    'type': 'categorical',
    'stops': [
        [1, "#26633d"],
        [2, "#879647"],
        [3, "#bdcf72"],
        [4, "#6d6e6d"]
    ],
    'default': white
}

status = {
    'property': 'status',
    'type': 'categorical',
    'stops': [
        ['30x30-conserved', "#56711f"],
        ['other-conserved', "#b6ce7a"],
        ['unknown', "#e5efdb"],
        ['non-conserved', "#e1e1e1"]
        # ['non-conserved', white]

    ],
}



ecoregion = {
    'property': 'ecoregion',
    'type': 'categorical',
    'stops': [
        ['Southeastern Great Basin', "#2ca02c"],
        ['Mojave Desert', "#98df8a"],
        ['Sonoran Desert', "#9467bd"],
        ['Sierra Nevada', "#17becf"],
        ['Southern California Mountains and Valleys', "#d62728"],
        ['Mono', "#ff9896"],
        ['Central California Coast', "#9edae5"],
        ['Klamath Mountains', "#f7b6d2"],
        ['Northern California Coast', "#c7c7c7"],
        ['Northern California Coast Ranges', "#aec7e8"],
        ['Northwestern Basin and Range', "#8c564b"],
        ['Colorado Desert', "#e377c2"],
        ['Central Valley Coast Ranges', "#7f7f7f"],
        ['Southern California Coast', "#c5b0d5"],
        ['Sierra Nevada Foothills', "#1f77b4"],
        ['Southern Cascades', "#ff7f0e"],
        ['Modoc Plateau', "#c49c94"],
        ['Great Valley (South)', "#bcbd22"],
        ['Northern California Interior Coast Ranges', "#ffbb78"],
        ['Great Valley (North)', "#dbdb8d"],
    ],
    'default': white
}


climate_zone = {
    'property': 'climate_zone',
    'type': 'categorical',
    'stops': [
        [1.0, "#2ca02c"],
        [2.0, "#98df8a"],
        [3.0, "#9467bd"],
        [4.0, "#17becf"],
        [5.0, "#d62728"],
        [6.0, "#ff9896"],
        [7.0, "#dbdb8d"],
        [8.0, "#bcbd22"],
        [9.0, "#c5b0d5"],
        [10.0, "#e377c2"],
    ],
    'default': white
}

ecoregion = {
    'property': 'ecoregion',
    'type': 'categorical',
    'stops': [
        ['Southeastern Great Basin', "#2ca02c"],
        ['Mojave Desert', "#98df8a"],
        ['Sonoran Desert', "#9467bd"],
        ['Sierra Nevada', "#17becf"],
        ['Southern California Mountains and Valleys', "#d62728"],
        ['Mono', "#ff9896"],
        ['Central California Coast', "#9edae5"],
        ['Klamath Mountains', "#f7b6d2"],
        ['Northern California Coast', "#c7c7c7"],
        ['Northern California Coast Ranges', "#aec7e8"],
        ['Northwestern Basin and Range', "#8c564b"],
        ['Colorado Desert', "#e377c2"],
        ['Central Valley Coast Ranges', "#7f7f7f"],
        ['Southern California Coast', "#c5b0d5"],
        ['Sierra Nevada Foothills', "#1f77b4"],
        ['Southern Cascades', "#ff7f0e"],
        ['Modoc Plateau', "#c49c94"],
        ['Great Valley (South)', "#bcbd22"],
        ['Northern California Interior Coast Ranges', "#ffbb78"],
        ['Great Valley (North)', "#dbdb8d"],
    ],
    'default': white
}

habitat_type = {
    'property': 'habitat_type',
    'type': 'categorical',
    'stops': [
        ['Agriculture', "#2ca02c"],
        ['Conifer Forest', "#98df8a"],
        ['Conifer Woodland', "#9467bd"],
        ['Desert Shrub', "#bcbd22"],
        ['Desert Woodland', "#d62728"],
        ['Hardwood Forest', "#ff9896"],
        ['Hardwood Woodland', "#8c564b"],
        ['Herbaceous', "#f7b6d2"],
        ['Barren/Other', "#c7c7c7"],
        ['Shrub', "#aec7e8"],
        ['Wetland', "#9edae5"],
        ['Water', "#17becf"],
        ['Urban', "#ffbb78"],
    ],
    'default': white
}

networks = {
    'property': 'resilient_connected_network',
    'type': 'categorical',
    'stops': [
        [110, "#54a0f7"],
        [103, "#72b3fd"],
        [1010, "#6b9ad3"],
        [1100, "#a2b0d5"],
        [1110, "#bfd1ff"],
        [10000, "#a87001"],
        [10010, "#d09514"],
        [20000, "#ffa807"],
        [20010, "#fed087"],
        [30000, "#88cc6a"],
        [30010, "#257202"],
        [40000, "#e377c2"],
        [0, "#ffffff"],
    ],
    'default': white
}


style_options = {
    "30x30 Status": status,
    "GAP Code": gap,
    "Year": year,
    "Ecoregion": ecoregion,
    "Climate Zone": climate_zone,
    "Habitat Type": habitat_type,
    "Manager Type": manager,
    "Easement": easement,
    "Access Type": access,
    "Networks": networks,

}

# justice40_fill = {
#     'property': 'Disadvan',
#     'type': 'categorical',
#     'stops': [
#         [0, white], 
#         [1, justice40_color]
#     ]
# }

# justice40_style = {
#     "version": 8,
#     "sources": {
#         "source1": {
#             "type": "vector",
#             "url": "pmtiles://" + url_justice40,
#             "attribution": "Justice40"
#         }
#     },
#     "layers": [
#         {
#             "id": "layer1",
#             "source": "source1",
#             "source-layer": "DisadvantagedCommunitiesCEJST",
#             "filter": ["match", ["get", "StateName"], "California", True, False],
#             "type": "fill",
#             "paint": {
#                 "fill-color": justice40_fill,
#             }
#         }
#     ]
# }
# # fire_style = {"version": 8,
#     "sources": {
#         "source1": {
#             "type": "vector",
#             "url": "pmtiles://" + url_calfire,
#             "attribution": "CAL FIRE"
#         }
#     },
#     "layers": [
#         {
#             "id": "fire",
#             "source": "source1",
#             "source-layer": 'calfire2023',
#             "filter": [">=", ["get", "YEAR_"], 2013],

#             "type": "fill",
#             "paint": {
#                 "fill-color": "#D22B2B",
#             }
#         }
#     ]
# }
# rx_style = {
#     "version": 8,
#     "sources": {
#         "source2": {
#             "type": "vector",
#             "url": "pmtiles://" + url_rxburn,
#             "attribution": "CAL FIRE"
#         }
#     },
#     "layers": [
#         {
#             "id": "rxburn",
#             "source": "source2",
#             "source-layer": 'calfirerxburn2023',
#             "filter": [">=", ["get", "YEAR_"], 2013],
#             "type": "fill",
#             "paint": {
#                 "fill-color": "#702963",
#             }
#         }
#     ]
# }


# svi_style = {
#         "layers": [
#             {
#                 "id": "svi",
#                 "source": "svi",
#                 "source-layer": "svi",
#                 "filter": ["match", ["get", "ST_ABBR"], "CA", True, False],
#                 "type": "fill",
#                 "paint": {
#                     "fill-color": [
#                         "interpolate", ["linear"], ["get", "RPL_THEMES"],
#                         0, white,
#                         1, svi_color
#                     ]
#                 }
#             }
#         ]
#     }


    

select_column = {
    "30x30 Status":  "status",
    "GAP Code": "gap_code",
    "Year": "established",
    "Ecoregion":  "ecoregion",
    "Climate Zone":  "climate_zone",
    "Habitat Type":  "habitat_type",
    "Manager Type": "manager_type",
    "Easement": "easement",
    "Access Type": "access_type",
    "Networks": "resilient_connected_network",

}