Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions Analyzing_Data/RasterFlow_FTW.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,28 @@
"metadata": {},
"source": [
"## Generate PM Tiles for visualization\n",
"To improve visualization performance of a large number of geometries, we can use Wherobots built-in high performance PM tile generator."
"To improve visualization performance of a large number of geometries, we can use Wherobots built-in high performance PM tile generator.\n",
"\n",
"The FTW model has a tendency to create extremely large boundary geometries, which doesn't play nicely with PMTiles. To avoid this we subdivide the boundary geometries."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d9d346fc22058fe",
"metadata": {},
"outputs": [],
"source": [
"fields_df = df.where(\"layer = 'field'\")\n",
"# 1266 is the vertex count of the second-largest boundary geometry.\n",
"# We use this instead of the absolute largest boundary (an extreme outlier)\n",
"# so the subdivision threshold is high enough to keep most geometries intact\n",
"# while still forcing that outlier-sized boundary to be subdivided for\n",
"# better PMTiles rendering performance.\n",
"boundaries_df = df.where(\"layer = 'field_boundaries'\").withColumn(\"geometry\", f.expr(\"ST_SubDivideExplode(geometry, 1266)\"))\n",
"tile_features_df = fields_df.withColumn(\"layer\", f.lit(\"fields\")).unionByName(\n",
" boundaries_df.withColumn(\"layer\", f.lit(\"boundaries\"))\n",
")"
]
},
{
Expand All @@ -373,7 +394,7 @@
"source": [
"from wherobots import vtiles\n",
"full_tiles_path = os.getenv(\"USER_S3_PATH\") + \"tiles.pmtiles\"\n",
"vtiles.generate_pmtiles(df, full_tiles_path)"
"vtiles.generate_pmtiles(tile_features_df, full_tiles_path)"
]
},
{
Expand Down