Datasets:

License:
cboettig commited on
Commit
da43bcd
·
1 Parent(s): 5e07ced
Files changed (3) hide show
  1. README.md +13 -1
  2. map.html +227 -0
  3. map.py +48 -0
README.md CHANGED
@@ -1,3 +1,15 @@
1
  ---
2
- license: cc-by-nc-4.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: pddl
3
  ---
4
+
5
+ # Irrecoverable Carbon
6
+
7
+ Cloud optimized geotiffs (COGs) of the Conservation International Irrecoverable Carbon layers.
8
+
9
+ - Description in original publication: https://doi.org/10.1038/s41893-021-00803-6
10
+ - Raw data accessed from https://doi.org/10.5281/zenodo.4091028
11
+
12
+ [Example leaflet map](https://data.source.coop/cboettig/carbon/map.html)
13
+
14
+
15
+
map.html ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+
5
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
6
+
7
+ <script>
8
+ L_NO_TOUCH = false;
9
+ L_DISABLE_3D = false;
10
+ </script>
11
+
12
+ <style>html, body {width: 100%;height: 100%;margin: 0;padding: 0;}</style>
13
+ <style>#map {position:absolute;top:0;bottom:0;right:0;left:0;}</style>
14
+ <script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.js"></script>
15
+ <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
16
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.bundle.min.js"></script>
17
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.js"></script>
18
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.3/dist/leaflet.css"/>
19
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/css/bootstrap.min.css"/>
20
+ <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/>
21
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.2.0/css/all.min.css"/>
22
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Leaflet.awesome-markers/2.0.2/leaflet.awesome-markers.css"/>
23
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/python-visualization/folium/folium/templates/leaflet.awesome.rotate.min.css"/>
24
+
25
+ <meta name="viewport" content="width=device-width,
26
+ initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
27
+ <style>
28
+ #map_a38d673f0ca359284ff75234a5c268cd {
29
+ position: relative;
30
+ width: 100.0%;
31
+ height: 100.0%;
32
+ left: 0.0%;
33
+ top: 0.0%;
34
+ }
35
+ .leaflet-container { font-size: 1rem; }
36
+ </style>
37
+
38
+ <script src="https://cdn.jsdelivr.net/npm/leaflet.fullscreen@3.0.0/Control.FullScreen.min.js"></script>
39
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet.fullscreen@3.0.0/Control.FullScreen.css"/>
40
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.js"></script>
41
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/1.0.2/leaflet.draw.css"/>
42
+ <script src="https://cdn.jsdelivr.net/gh/ljagis/leaflet-measure@2.1.7/dist/leaflet-measure.min.js"></script>
43
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ljagis/leaflet-measure@2.1.7/dist/leaflet-measure.min.css"/>
44
+ <script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>
45
+ <link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css"/>
46
+ </head>
47
+ <body>
48
+
49
+
50
+ <div class="folium-map" id="map_a38d673f0ca359284ff75234a5c268cd" ></div>
51
+
52
+ </body>
53
+ <script>
54
+
55
+
56
+ var map_a38d673f0ca359284ff75234a5c268cd = L.map(
57
+ "map_a38d673f0ca359284ff75234a5c268cd",
58
+ {
59
+ center: [35.0, -100.0],
60
+ crs: L.CRS.EPSG3857,
61
+ zoom: 3,
62
+ zoomControl: true,
63
+ preferCanvas: false,
64
+ drawExport: false,
65
+ layersControl: true,
66
+ }
67
+ );
68
+ L.control.scale().addTo(map_a38d673f0ca359284ff75234a5c268cd);
69
+
70
+
71
+
72
+
73
+
74
+ var tile_layer_a0f43a1f4ce0b17ace3206fa0fa4c8b7 = L.tileLayer(
75
+ "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
76
+ {"attribution": "\u0026copy; \u003ca href=\"https://www.openstreetmap.org/copyright\"\u003eOpenStreetMap\u003c/a\u003e contributors", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 19, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false}
77
+ );
78
+
79
+
80
+ tile_layer_a0f43a1f4ce0b17ace3206fa0fa4c8b7.addTo(map_a38d673f0ca359284ff75234a5c268cd);
81
+
82
+
83
+ L.control.fullscreen(
84
+ {"forceSeparateButton": false, "position": "topleft", "title": "Full Screen", "titleCancel": "Exit Full Screen"}
85
+ ).addTo(map_a38d673f0ca359284ff75234a5c268cd);
86
+
87
+
88
+ var options = {
89
+ position: "topleft",
90
+ draw: {},
91
+ edit: {},
92
+ }
93
+ // FeatureGroup is to store editable layers.
94
+ var drawnItems_draw_control_808af41363548a2d2b92a7aa5eca421a = new L.featureGroup().addTo(
95
+ map_a38d673f0ca359284ff75234a5c268cd
96
+ );
97
+ options.edit.featureGroup = drawnItems_draw_control_808af41363548a2d2b92a7aa5eca421a;
98
+ var draw_control_808af41363548a2d2b92a7aa5eca421a = new L.Control.Draw(
99
+ options
100
+ ).addTo( map_a38d673f0ca359284ff75234a5c268cd );
101
+ map_a38d673f0ca359284ff75234a5c268cd.on(L.Draw.Event.CREATED, function(e) {
102
+ var layer = e.layer,
103
+ type = e.layerType;
104
+ var coords = JSON.stringify(layer.toGeoJSON());
105
+ layer.on('click', function() {
106
+ alert(coords);
107
+ console.log(coords);
108
+ });
109
+ drawnItems_draw_control_808af41363548a2d2b92a7aa5eca421a.addLayer(layer);
110
+ });
111
+ map_a38d673f0ca359284ff75234a5c268cd.on('draw:created', function(e) {
112
+ drawnItems_draw_control_808af41363548a2d2b92a7aa5eca421a.addLayer(e.layer);
113
+ });
114
+
115
+
116
+
117
+ var measure_control_0c1c542019b321e96d86057798ae17cd = new L.Control.Measure(
118
+ {"position": "bottomleft", "primaryAreaUnit": "sqmeters", "primaryLengthUnit": "meters", "secondaryAreaUnit": "acres", "secondaryLengthUnit": "miles"});
119
+ map_a38d673f0ca359284ff75234a5c268cd.addControl(measure_control_0c1c542019b321e96d86057798ae17cd);
120
+
121
+ // Workaround for using this plugin with Leaflet>=1.8.0
122
+ // https://github.com/ljagis/leaflet-measure/issues/171
123
+ L.Control.Measure.include({
124
+ _setCaptureMarkerIcon: function () {
125
+ // disable autopan
126
+ this._captureMarker.options.autoPanOnFocus = false;
127
+ // default function
128
+ this._captureMarker.setIcon(
129
+ L.divIcon({
130
+ iconSize: this._map.getSize().multiplyBy(2)
131
+ })
132
+ );
133
+ },
134
+ });
135
+
136
+
137
+
138
+
139
+ var geocoderOpts_geocoder_f4b44377845319e1748a4a93f7a8a3c9 = {"collapsed": true, "defaultMarkGeocode": true, "position": "topleft", "provider": "nominatim", "providerOptions": {}, "zoom": 11};
140
+
141
+ // note: geocoder name should start with lowercase
142
+ var geocoderName_geocoder_f4b44377845319e1748a4a93f7a8a3c9 = geocoderOpts_geocoder_f4b44377845319e1748a4a93f7a8a3c9["provider"];
143
+
144
+ var customGeocoder_geocoder_f4b44377845319e1748a4a93f7a8a3c9 = L.Control.Geocoder[ geocoderName_geocoder_f4b44377845319e1748a4a93f7a8a3c9 ](
145
+ geocoderOpts_geocoder_f4b44377845319e1748a4a93f7a8a3c9['providerOptions']
146
+ );
147
+ geocoderOpts_geocoder_f4b44377845319e1748a4a93f7a8a3c9["geocoder"] = customGeocoder_geocoder_f4b44377845319e1748a4a93f7a8a3c9;
148
+
149
+ L.Control.geocoder(
150
+ geocoderOpts_geocoder_f4b44377845319e1748a4a93f7a8a3c9
151
+ ).on('markgeocode', function(e) {
152
+ var zoom = geocoderOpts_geocoder_f4b44377845319e1748a4a93f7a8a3c9['zoom'] || map_a38d673f0ca359284ff75234a5c268cd.getZoom();
153
+ map_a38d673f0ca359284ff75234a5c268cd.setView(e.geocode.center, zoom);
154
+ }).addTo(map_a38d673f0ca359284ff75234a5c268cd);
155
+
156
+
157
+
158
+ map_a38d673f0ca359284ff75234a5c268cd.fitBounds(
159
+ [[35, -100], [35, -100]],
160
+ {"maxZoom": 3}
161
+ );
162
+
163
+
164
+ var tile_layer_09f082ba129b7c369be9eb5354b7a840 = L.tileLayer(
165
+ "https://titiler.xyz/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?transparent_bg=True\u0026url=https%3A%2F%2Fdata.source.coop%2Fcboettig%2Fcarbon%2Fcogs%2Firrecoverable_c_total_2018.tif\u0026colormap_name=reds\u0026bidx=1\u0026rescale=0.0%2C161.0",
166
+ {"attribution": ".", "detectRetina": false, "maxNativeZoom": 30, "maxZoom": 30, "minZoom": 0, "noWrap": false, "opacity": 0.8, "subdomains": "abc", "tms": false}
167
+ );
168
+
169
+
170
+ tile_layer_09f082ba129b7c369be9eb5354b7a840.addTo(map_a38d673f0ca359284ff75234a5c268cd);
171
+
172
+
173
+ map_a38d673f0ca359284ff75234a5c268cd.fitBounds(
174
+ [[-60.00068614227767, -179.99999999999994], [84.00039183113232, 180.00000000000006]],
175
+ {}
176
+ );
177
+
178
+
179
+ var tile_layer_687b2f3cc47d6a32950f67507028fcfc = L.tileLayer(
180
+ "https://titiler.xyz/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?transparent_bg=True\u0026url=https%3A%2F%2Fdata.source.coop%2Fcboettig%2Fcarbon%2Fcogs%2Fvulnerable_c_total_2018.tif\u0026colormap_name=purples\u0026bidx=1\u0026rescale=0.0%2C218.0",
181
+ {"attribution": ".", "detectRetina": false, "maxNativeZoom": 30, "maxZoom": 30, "minZoom": 0, "noWrap": false, "opacity": 0.8, "subdomains": "abc", "tms": false}
182
+ );
183
+
184
+
185
+ tile_layer_687b2f3cc47d6a32950f67507028fcfc.addTo(map_a38d673f0ca359284ff75234a5c268cd);
186
+
187
+
188
+ map_a38d673f0ca359284ff75234a5c268cd.fitBounds(
189
+ [[-60.00068614227767, -180.0], [84.00039183113232, 180.0]],
190
+ {}
191
+ );
192
+
193
+
194
+ var tile_layer_952663c645c5fb6f6915c17e9af14a2e = L.tileLayer(
195
+ "https://titiler.xyz/cog/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?transparent_bg=True\u0026url=https%3A%2F%2Fdata.source.coop%2Fcboettig%2Fcarbon%2Fcogs%2Fmanageable_c_total_2018.tif\u0026colormap_name=greens\u0026bidx=1\u0026rescale=0.0%2C296.0",
196
+ {"attribution": ".", "detectRetina": false, "maxNativeZoom": 30, "maxZoom": 30, "minZoom": 0, "noWrap": false, "opacity": 0.8, "subdomains": "abc", "tms": false}
197
+ );
198
+
199
+
200
+ tile_layer_952663c645c5fb6f6915c17e9af14a2e.addTo(map_a38d673f0ca359284ff75234a5c268cd);
201
+
202
+
203
+ map_a38d673f0ca359284ff75234a5c268cd.fitBounds(
204
+ [[-60.0006861422776, -179.99999999999994], [84.00039183113239, 180.00000000000006]],
205
+ {}
206
+ );
207
+
208
+
209
+ var layer_control_4cd4aee3c1134b6f935f7fe3dd767b0a_layers = {
210
+ base_layers : {
211
+ "openstreetmap" : tile_layer_a0f43a1f4ce0b17ace3206fa0fa4c8b7,
212
+ },
213
+ overlays : {
214
+ "irrecoverable carbon" : tile_layer_09f082ba129b7c369be9eb5354b7a840,
215
+ "vulnerable carbon" : tile_layer_687b2f3cc47d6a32950f67507028fcfc,
216
+ "manageable carbon" : tile_layer_952663c645c5fb6f6915c17e9af14a2e,
217
+ },
218
+ };
219
+ let layer_control_4cd4aee3c1134b6f935f7fe3dd767b0a = L.control.layers(
220
+ layer_control_4cd4aee3c1134b6f935f7fe3dd767b0a_layers.base_layers,
221
+ layer_control_4cd4aee3c1134b6f935f7fe3dd767b0a_layers.overlays,
222
+ {"autoZIndex": true, "collapsed": true, "position": "topright"}
223
+ ).addTo(map_a38d673f0ca359284ff75234a5c268cd);
224
+
225
+
226
+ </script>
227
+ </html>
map.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # +
18
+ from pathlib import Path
19
+
20
+ files = [path for path in Path('.').glob('**/*.tif')]
21
+ done = [path for path in Path('.').glob('cogs/*.tif')]
22
+
23
+ # -
24
+
25
+ B = [x.name for x in done]
26
+ A = [x.name.lower() for x in files]
27
+ C=[i for i in A if i not in B]
28
+ C
29
+
30
+ # +
31
+
32
+ for x in inputs:
33
+ dest = "cogs/" + x.name.lower()
34
+ leafmap.image_to_cog(str(x), dest)
35
+
36
+
37
+
38
+ # +
39
+ m = leafmap.Map(center=[35, -100], zoom=3)
40
+ #m.add_basemap("Esri.WorldGrayCanvas")
41
+ #m.add_cog_layer("https://data.source.coop/cboettig/mobi/species-richness-all/SpeciesRichness_All.tif", palette="Reds", name="Richness", nodata=0, transparent_bg=True, opacity = 0.9)
42
+ m.add_cog_layer("https://data.source.coop/cboettig/carbon/cogs/irrecoverable_c_total_2018.tif", palette="reds", name="irrecoverable carbon", transparent_bg=True, opacity = 0.8)
43
+ m.add_cog_layer("https://data.source.coop/cboettig/carbon/cogs/vulnerable_c_total_2018.tif", palette="purples", name="vulnerable carbon", transparent_bg=True, opacity = 0.8)
44
+ m.add_cog_layer("https://data.source.coop/cboettig/carbon/cogs/manageable_c_total_2018.tif", palette="greens", name="manageable carbon", transparent_bg=True, opacity = 0.8)
45
+
46
+ m.to_html("map.html")
47
+
48
+ m