Spaces:
Sleeping
Sleeping
parquet file of areas added in 2024, via buffer trick
Browse files- explore.ipynb +96 -22
- new2024.parquet +3 -0
explore.ipynb
CHANGED
@@ -120,7 +120,42 @@
|
|
120 |
},
|
121 |
{
|
122 |
"cell_type": "code",
|
123 |
-
"execution_count":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
"id": "3ed21429-a75e-4b52-b6eb-d41c8f051883",
|
125 |
"metadata": {},
|
126 |
"outputs": [
|
@@ -137,6 +172,21 @@
|
|
137 |
},
|
138 |
"metadata": {},
|
139 |
"output_type": "display_data"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
],
|
142 |
"source": [
|
@@ -157,6 +207,7 @@
|
|
157 |
"m = leafmap.Map(style=\"positron\")\n",
|
158 |
"m.add_gdf(intersects.execute(),layer_type=\"fill\", name = \"intes\", paint=paint)\n",
|
159 |
"m.add_layer_control()\n",
|
|
|
160 |
"m"
|
161 |
]
|
162 |
},
|
@@ -174,37 +225,60 @@
|
|
174 |
"id": "1e538620-19f5-42eb-8233-e280b5c5b920",
|
175 |
"metadata": {},
|
176 |
"outputs": [],
|
177 |
-
"source": [
|
178 |
-
"import ibis\n",
|
179 |
-
"from ibis import _\n",
|
180 |
-
"tbl = (\n",
|
181 |
-
" conn.read_parquet(\"https://data.source.coop/cboettig/ca30x30/ca_areas.parquet\")\n",
|
182 |
-
" .cast({\"SHAPE\": \"geometry\"})\n",
|
183 |
-
" .filter(_.UNIT_NAME == \"Angeles National Forest\", _.reGAP < 3) \n",
|
184 |
-
")\n",
|
185 |
-
"\n",
|
186 |
-
"tbl_2023 = tbl.filter(_.Release_Year == 2023)\n",
|
187 |
-
"tbl_2024 = tbl.filter(_.Release_Year == 2024)\n",
|
188 |
-
"\n",
|
189 |
-
"tbl_2023.execute().to_file(\"la_2023.geojson\")\n",
|
190 |
-
"tbl_2024.execute().to_file(\"la_2024.geojson\")\n"
|
191 |
-
]
|
192 |
},
|
193 |
{
|
194 |
"cell_type": "code",
|
195 |
-
"execution_count":
|
196 |
"id": "21dbc7c4-20e2-4422-ac21-cd50badcae58",
|
197 |
"metadata": {},
|
198 |
-
"outputs": [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
"source": [
|
|
|
200 |
"import duckdb\n",
|
201 |
"db = duckdb.connect()\n",
|
202 |
"db.install_extension(\"spatial\")\n",
|
203 |
"db.load_extension(\"spatial\")\n",
|
204 |
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
"db.sql('''\n",
|
206 |
-
"CREATE OR REPLACE TABLE t1 AS SELECT OBJECTID AS gid, geom, FROM st_read(\"la_2024.geojson\");\n",
|
207 |
-
"CREATE OR REPLACE TABLE t2 AS SELECT OBJECTID AS gid, geom, FROM st_read(\"la_2023.geojson\");\n",
|
208 |
"''')\n",
|
209 |
"db.sql('''\n",
|
210 |
"COPY (\n",
|
@@ -216,7 +290,7 @@
|
|
216 |
") \n",
|
217 |
"select st_difference(b.geom,coalesce(t.geom, 'GEOMETRYCOLLECTION EMPTY'::geometry)) as geom\n",
|
218 |
"from t1 b left join temp t on b.gid = t.gid\n",
|
219 |
-
") TO '
|
220 |
"''')"
|
221 |
]
|
222 |
},
|
@@ -230,7 +304,7 @@
|
|
230 |
"import ibis\n",
|
231 |
"from ibis import _\n",
|
232 |
"con = ibis.duckdb.connect()\n",
|
233 |
-
"diff = con.read_geo(\"
|
234 |
]
|
235 |
},
|
236 |
{
|
|
|
120 |
},
|
121 |
{
|
122 |
"cell_type": "code",
|
123 |
+
"execution_count": 27,
|
124 |
+
"id": "adab4c4f-d2cb-48b2-b32e-5c7beb5fdbc3",
|
125 |
+
"metadata": {},
|
126 |
+
"outputs": [
|
127 |
+
{
|
128 |
+
"data": {
|
129 |
+
"application/vnd.jupyter.widget-view+json": {
|
130 |
+
"model_id": "a5694cb8358f4591a512a2304462bd87",
|
131 |
+
"version_major": 2,
|
132 |
+
"version_minor": 0
|
133 |
+
},
|
134 |
+
"text/plain": [
|
135 |
+
"FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))"
|
136 |
+
]
|
137 |
+
},
|
138 |
+
"metadata": {},
|
139 |
+
"output_type": "display_data"
|
140 |
+
}
|
141 |
+
],
|
142 |
+
"source": [
|
143 |
+
"new = intersects.execute()"
|
144 |
+
]
|
145 |
+
},
|
146 |
+
{
|
147 |
+
"cell_type": "code",
|
148 |
+
"execution_count": 28,
|
149 |
+
"id": "03b46dbe-bda1-45db-8b7d-7caa1e2e3a76",
|
150 |
+
"metadata": {},
|
151 |
+
"outputs": [],
|
152 |
+
"source": [
|
153 |
+
"new.to_parquet(\"new2024.parquet\")"
|
154 |
+
]
|
155 |
+
},
|
156 |
+
{
|
157 |
+
"cell_type": "code",
|
158 |
+
"execution_count": 26,
|
159 |
"id": "3ed21429-a75e-4b52-b6eb-d41c8f051883",
|
160 |
"metadata": {},
|
161 |
"outputs": [
|
|
|
172 |
},
|
173 |
"metadata": {},
|
174 |
"output_type": "display_data"
|
175 |
+
},
|
176 |
+
{
|
177 |
+
"data": {
|
178 |
+
"application/vnd.jupyter.widget-view+json": {
|
179 |
+
"model_id": "c9df74d0099c4ba7929e45ae3fce1eb5",
|
180 |
+
"version_major": 2,
|
181 |
+
"version_minor": 1
|
182 |
+
},
|
183 |
+
"text/plain": [
|
184 |
+
"Map(height='600px', map_options={'bearing': 0, 'center': (0, 20), 'pitch': 0, 'style': 'https://basemaps.carto…"
|
185 |
+
]
|
186 |
+
},
|
187 |
+
"execution_count": 26,
|
188 |
+
"metadata": {},
|
189 |
+
"output_type": "execute_result"
|
190 |
}
|
191 |
],
|
192 |
"source": [
|
|
|
207 |
"m = leafmap.Map(style=\"positron\")\n",
|
208 |
"m.add_gdf(intersects.execute(),layer_type=\"fill\", name = \"intes\", paint=paint)\n",
|
209 |
"m.add_layer_control()\n",
|
210 |
+
"m.to_html(\"new_in_2024.html\")\n",
|
211 |
"m"
|
212 |
]
|
213 |
},
|
|
|
225 |
"id": "1e538620-19f5-42eb-8233-e280b5c5b920",
|
226 |
"metadata": {},
|
227 |
"outputs": [],
|
228 |
+
"source": []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
},
|
230 |
{
|
231 |
"cell_type": "code",
|
232 |
+
"execution_count": null,
|
233 |
"id": "21dbc7c4-20e2-4422-ac21-cd50badcae58",
|
234 |
"metadata": {},
|
235 |
+
"outputs": [
|
236 |
+
{
|
237 |
+
"data": {
|
238 |
+
"application/vnd.jupyter.widget-view+json": {
|
239 |
+
"model_id": "34dc23600db64d4899b43e42348907b4",
|
240 |
+
"version_major": 2,
|
241 |
+
"version_minor": 0
|
242 |
+
},
|
243 |
+
"text/plain": [
|
244 |
+
"FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))"
|
245 |
+
]
|
246 |
+
},
|
247 |
+
"metadata": {},
|
248 |
+
"output_type": "display_data"
|
249 |
+
},
|
250 |
+
{
|
251 |
+
"data": {
|
252 |
+
"application/vnd.jupyter.widget-view+json": {
|
253 |
+
"model_id": "1c7b2f7a0bf548ce933d40d7bb0e7f43",
|
254 |
+
"version_major": 2,
|
255 |
+
"version_minor": 0
|
256 |
+
},
|
257 |
+
"text/plain": [
|
258 |
+
"FloatProgress(value=0.0, layout=Layout(width='auto'), style=ProgressStyle(bar_color='black'))"
|
259 |
+
]
|
260 |
+
},
|
261 |
+
"metadata": {},
|
262 |
+
"output_type": "display_data"
|
263 |
+
}
|
264 |
+
],
|
265 |
"source": [
|
266 |
+
"%%time\n",
|
267 |
"import duckdb\n",
|
268 |
"db = duckdb.connect()\n",
|
269 |
"db.install_extension(\"spatial\")\n",
|
270 |
"db.load_extension(\"spatial\")\n",
|
271 |
"\n",
|
272 |
+
"\n",
|
273 |
+
"tbl_2023 = tbl.filter(_.Release_Year == 2023) # no buffer\n",
|
274 |
+
"tbl_2024 = tbl.filter(_.Release_Year == 2024)\n",
|
275 |
+
"tbl_2023.execute().to_file(\"la_2023.geojson\")\n",
|
276 |
+
"tbl_2024.execute().to_file(\"la_2024.geojson\")\n",
|
277 |
+
"\n",
|
278 |
+
"\n",
|
279 |
"db.sql('''\n",
|
280 |
+
"CREATE OR REPLACE TABLE t1 AS SELECT OBJECTID AS gid, st_make_valid(geom) AS geom, FROM st_read(\"la_2024.geojson\");\n",
|
281 |
+
"CREATE OR REPLACE TABLE t2 AS SELECT OBJECTID AS gid, st_make_valid(geom) AS geom, FROM st_read(\"la_2023.geojson\");\n",
|
282 |
"''')\n",
|
283 |
"db.sql('''\n",
|
284 |
"COPY (\n",
|
|
|
290 |
") \n",
|
291 |
"select st_difference(b.geom,coalesce(t.geom, 'GEOMETRYCOLLECTION EMPTY'::geometry)) as geom\n",
|
292 |
"from t1 b left join temp t on b.gid = t.gid\n",
|
293 |
+
") TO 'new2024.geojson' WITH (FORMAT GDAL, DRIVER 'GeoJSON', LAYER_CREATION_OPTIONS 'WRITE_BBOX=YES')\n",
|
294 |
"''')"
|
295 |
]
|
296 |
},
|
|
|
304 |
"import ibis\n",
|
305 |
"from ibis import _\n",
|
306 |
"con = ibis.duckdb.connect()\n",
|
307 |
+
"diff = con.read_geo(\"new2024.geojson\")\n"
|
308 |
]
|
309 |
},
|
310 |
{
|
new2024.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7c530fe7e3a29c907ec16a03f9173708d20561b576dea783b31406b89139ab5b
|
3 |
+
size 48392372
|