Skip to content

Instantly share code, notes, and snippets.

@emileten
Created November 9, 2023 11:24
Show Gist options
  • Save emileten/aa24ddac2d2b413672250f797c498499 to your computer and use it in GitHub Desktop.
Save emileten/aa24ddac2d2b413672250f797c498499 to your computer and use it in GitHub Desktop.
try-lonboard
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "9262b818-a847-4c31-867a-ca2b165d7db0",
"metadata": {},
"outputs": [],
"source": [
"from lonboard import viz\n",
"import geopandas as gpd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "e994a48b-4102-4fcd-9873-4bf0417ad7f0",
"metadata": {},
"outputs": [],
"source": [
"gdf = gpd.read_file('/Users/emiletenezakis/devseed/tri_seasonal_s1_sar_composites/example_item.json', lines=True)\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "a6a777b1-f6de-4ebf-94f8-e93b218f8c81",
"metadata": {},
"outputs": [],
"source": [
"gdf_subset = gdf[['geometry']]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "968ec1bb-91db-4eec-91b1-791c2f233ced",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>geometry</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>POLYGON ((22.08242 49.27447, 21.79142 49.46630...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" geometry\n",
"0 POLYGON ((22.08242 49.27447, 21.79142 49.46630..."
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gdf_subset"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "afa3b304",
"metadata": {},
"outputs": [],
"source": [
"import geopandas as gpd\n",
"from lonboard import Map, SolidPolygonLayer\n",
"\n",
"# A GeoDataFrame with Polygon geometries\n",
"layer = SolidPolygonLayer.from_geopandas(\n",
" gdf_subset,\n",
")\n",
"map_ = Map(layers=[layer])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "c8d14728-34cd-42fb-9ed5-1d54081ecb8f",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "5e95a98744584a2b985f8333f05e9400",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Map(layers=[SolidPolygonLayer(table=pyarrow.Table\n",
"geometry: list<item: list<item: fixed_size_list<item: double…"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"map_"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8097bfd-ee2b-4027-afaa-0a53045403b9",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "lonboard",
"language": "python",
"name": "lonboard"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment