Jonathan Marokhovsky commited on
Commit
bb5a9d0
1 Parent(s): 826c1e4

Trying to use a different pmtile to see if that's the issue.

Browse files
Files changed (2) hide show
  1. pages/01_app.py +0 -42
  2. pages/01_eurocrops.py +144 -0
pages/01_app.py DELETED
@@ -1,42 +0,0 @@
1
- import leafmap
2
- import solara
3
-
4
-
5
- # variables
6
- zoom = solara.reactive(2)
7
- center = solara.reactive((20, 0))
8
-
9
- # Euromap info
10
- eurocrops_pmtiles = "https://s3.us-west-2.amazonaws.com/us-west-2.opendata.source.coop/cholmes/eurocrops/eurocrops-all.pmtiles"
11
-
12
-
13
- class Map(leafmap.Map):
14
- def __init__(self, **kwargs) -> None:
15
- super().__init__(**kwargs)
16
- self.add_stac_gui() ## TODO: make sure I need this
17
- self.add_pmtiles(
18
- eurocrops_pmtiles,
19
- name="Euro Crops",
20
- overlay=True,
21
- show=True,
22
- zoom_to_layer=False,
23
- )
24
-
25
-
26
- @solara.component
27
- def Page():
28
- with solara.Column(style={"min-width": "500px"}):
29
- # solara components support reactive variables
30
- # solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
31
- # using 3rd party widget library require wiring up the events manually
32
- # using zoom.value and zoom.set
33
- Map.element( # type: ignore
34
- zoom=zoom.value,
35
- on_zoom=zoom.set,
36
- center=center.value,
37
- on_center=center.set,
38
- scroll_wheel_zoom=True,
39
- toolbar_ctrl=False,
40
- data_ctrl=False,
41
- height="780px",
42
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pages/01_eurocrops.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import leafmap
2
+ from leafmap import pmtiles_style
3
+ import solara
4
+ import ipyleaflet
5
+
6
+ # THings to come:
7
+ # TODO: Calculate some metrics given the area.
8
+ # TODO: add a raster to the toy
9
+ # TODO: Dynamically check the center of the map and change what's displayed depending on that.
10
+
11
+ # variables
12
+ zoom = solara.reactive(2)
13
+ center = solara.reactive((20, 0))
14
+
15
+ # Euromap info
16
+ eurocrops_pmtiles = "https://s3.us-west-2.amazonaws.com/us-west-2.opendata.source.coop/cholmes/eurocrops/eurocrops-all.pmtiles"
17
+
18
+ original_style = {
19
+ "version": 8,
20
+ "sources": {
21
+ "source": {
22
+ "type": "vector",
23
+ "url": "pmtiles://https://s3.us-west-2.amazonaws.com/us-west-2.opendata.source.coop/cholmes/eurocrops/eurocrops-all.pmtiles",
24
+ "attribution": "PMTiles",
25
+ }
26
+ },
27
+ "layers": [
28
+ {
29
+ "id": "eurocrops_point",
30
+ "source": "source",
31
+ "source-layer": "eurocrops",
32
+ "type": "circle",
33
+ "paint": {"circle-color": "#8dd3c7", "circle-radius": 5},
34
+ "filter": ["==", ["geometry-type"], "Point"],
35
+ },
36
+ {
37
+ "id": "eurocrops_stroke",
38
+ "source": "source",
39
+ "source-layer": "eurocrops",
40
+ "type": "line",
41
+ "paint": {"line-color": "#8dd3c7", "line-width": 1},
42
+ "filter": ["==", ["geometry-type"], "LineString"],
43
+ },
44
+ {
45
+ "id": "eurocrops_fill",
46
+ "source": "source",
47
+ "source-layer": "eurocrops",
48
+ "type": "fill",
49
+ "paint": {"fill-color": "#8dd3c7", "fill-opacity": 0.5},
50
+ "filter": ["==", ["geometry-type"], "Polygon"],
51
+ },
52
+ ],
53
+ }
54
+ style = original_style
55
+ del style["version"]
56
+ del style["sources"]
57
+
58
+ q_url = "https://storage.googleapis.com/ahp-research/overture/pmtiles/overture.pmtiles"
59
+
60
+ q_style = {
61
+ "layers": [
62
+ {
63
+ "id": "admins",
64
+ "source": "example_source",
65
+ "source-layer": "admins",
66
+ "type": "fill",
67
+ "paint": {"fill-color": "#BDD3C7", "fill-opacity": 0.1},
68
+ },
69
+ {
70
+ "id": "buildings",
71
+ "source": "example_source",
72
+ "source-layer": "buildings",
73
+ "type": "fill",
74
+ "paint": {"fill-color": "#FFFFB3", "fill-opacity": 0.5},
75
+ },
76
+ {
77
+ "id": "places",
78
+ "source": "example_source",
79
+ "source-layer": "places",
80
+ "type": "fill",
81
+ "paint": {"fill-color": "#BEBADA", "fill-opacity": 0.5},
82
+ },
83
+ {
84
+ "id": "roads",
85
+ "source": "example_source",
86
+ "source-layer": "roads",
87
+ "type": "line",
88
+ "paint": {"line-color": "#FB8072"},
89
+ },
90
+ ],
91
+ }
92
+
93
+ # self.add_pmtiles(url, name='PMTiles', style=style)
94
+
95
+
96
+ class Map(leafmap.Map):
97
+ def __init__(self, **kwargs) -> None:
98
+ super().__init__(**kwargs)
99
+ self.add_basemap("CartoDB.DarkMatter")
100
+ # self.add_pmtiles(
101
+ # eurocrops_pmtiles,
102
+ # style=style,
103
+ # name="Euro Crops",
104
+ # overlay=True,
105
+ # show=True,
106
+ # zoom_to_layer=True,
107
+ # )
108
+ # print(pmtiles_style(eurocrops_pmtiles))
109
+ # print(style)
110
+ self.add_pmtiles(
111
+ q_url,
112
+ # style=pmtiles_style(q_url),
113
+ style=q_style,
114
+ name="Quisheng Layer",
115
+ overlay=True,
116
+ show=True,
117
+ zoom_to_layer=True,
118
+ )
119
+ # self.add_my_pmtiles()
120
+ # self.add_stac_gui() ## TODO: make sure I need this
121
+
122
+ def add_my_pmtiles(self, **kwargs):
123
+ layer = ipyleaflet.PMTilesLayer(url=eurocrops_pmtiles, style=style)
124
+ self.add(layer)
125
+
126
+
127
+ @solara.component
128
+ def Page():
129
+ with solara.Column(style={"min-width": "500px"}):
130
+ # solara components support reactive variables
131
+ # solara.SliderInt(label="Zoom level", value=zoom, min=1, max=20)
132
+ # using 3rd party widget library require wiring up the events manually
133
+ # using zoom.value and zoom.set
134
+ Map.element( # type: ignore
135
+ # m = Map.element( # type: ignore
136
+ zoom=zoom.value,
137
+ on_zoom=zoom.set,
138
+ center=center.value,
139
+ on_center=center.set,
140
+ scroll_wheel_zoom=True,
141
+ toolbar_ctrl=False,
142
+ data_ctrl=False,
143
+ height="780px",
144
+ )