postgis question/project: create tiles for the complement(!) of polygons

18 views
Skip to first unread message

Brendan Farrell

unread,
Sep 11, 2023, 4:55:29 AM9/11/23
to cu...@googlegroups.com

Dear CUGOS,

I've had an interesting technical challenge come up: I need to create vector tiles from postgresql that show both the polygons of interest and their complement. The end result would be a web map that shows the polygons with their data available for display, and then there also be a display for their complement, i.e. the area for which there are no polygons. In that area we will assign a field that essentially says there is no data available there. I need to do this through postgis rather than precomputing tiles.

Does anybody want to help me figure this one out? I think it might make a nice blog post if we do. I've pretty much got to figure it out this week, so please let me know quickly if you're interested or have ideas. 

Brendan

tony.ca...@gmail.com

unread,
Sep 12, 2023, 12:13:27 AM9/12/23
to Cascadia Users of Geospatial Open Source
Brendan - You can accomplish this relatively simply via a combination of `ST_TileEnvelope`, `ST_Difference`, `ST_AsMVTGeom` (convert geometries to tile coordinates), and `ST_AsMVT` (to produce MVT-encoded data). 

Best of luck - 
tony

Brendan Farrell

unread,
Sep 12, 2023, 12:50:42 AM9/12/23
to tony.ca...@gmail.com, Cascadia Users of Geospatial Open Source
Tony,

I don't think it's so simple. The general idea would be to use those three functions, but the details are a bit tricky. For example, for tiles that do not intersect any polygons, one wants to show the whole tile. But I usually include a where clause in my queries for where the data intersects the tiles and find that that is faster than only having the cut out function in ST_AsMVTGeom. 

Would you like to work on this together? It's not a huge project, but I think it needs a little careful work and I at least think it's a little bit interesting.

Brendan

--
You received this message because you are subscribed to the Google Groups "Cascadia Users of Geospatial Open Source" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cugos+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cugos/622090e9-e60c-4d56-802e-0fba4a31946an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages