Datasets:

License:
cboettig commited on
Commit
04d1634
·
1 Parent(s): c774ba0
Files changed (1) hide show
  1. map.py +64 -0
map.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+
14
+ import leafmap.foliumap as leafmap
15
+
16
+ # +
17
+ url = "https://huggingface.co/datasets/boettiger-lab/pad-us-3/resolve/main/pad-mobi.pmtiles"
18
+
19
+ private_color = "#DE881E" # orange #"#850101" # red
20
+ tribal_color = "#BF40BF" # purple
21
+ mixed_color = "#005a00" # green
22
+ public_color = "#3388ff" # blue
23
+
24
+ bucket = {
25
+ "fill-color":
26
+ ['case',
27
+ ['==', ['get', 'bucket'], 'public'],
28
+ public_color,
29
+ ['==', ['get', 'bucket'], 'private'],
30
+ private_color,
31
+ ['==', ['get', 'bucket'], 'tribal'],
32
+ tribal_color,
33
+ mixed_color # default (bucket == mixed)
34
+ ],
35
+ "fill-opacity": 0.5}
36
+ style = {
37
+ "version": 8,
38
+ "sources": {
39
+ "source1": {
40
+ "type": "vector",
41
+ "url": "pmtiles://" + url,
42
+ "attribution": "US PAD v3"}},
43
+ "layers": [{
44
+ "id": "pad-mobi",
45
+ "source": "source1",
46
+ "source-layer": "pad-mobi",
47
+ "type": "fill",
48
+ "paint": bucket}]}
49
+
50
+ m = leafmap.Map(center=[35, -100], zoom=4)
51
+ m.add_basemap("Esri.WorldGrayCanvas")
52
+ m.add_pmtiles(url, name="pad", style=style, overlay=True, show=True, zoom_to_layer=False)
53
+ m
54
+ # -
55
+
56
+ total = 139
57
+ n = 10
58
+ [i for i in r)]
59
+
60
+
61
+ import numpy as np
62
+ for i in range(0,total,n):
63
+ end = np.min([i + n,total])
64
+ print(i,end)