developmentseed / lonboard

A Python library for fast, interactive geospatial vector data visualization in Jupyter.
https://developmentseed.org/lonboard/latest/
MIT License
639 stars 33 forks source link

Polygon winding order #67

Open kylebarron opened 1 year ago

kylebarron commented 1 year ago

The deck.gl SolidPolygonLayer has a render option _windingOrder which says

This prop is only effective with _normalize: false. It specifies the winding order of rings in the polygon data, one of:

  • 'CW': outer-ring is clockwise, and holes are counter-clockwise
  • 'CCW': outer-ring is counter-clockwise, and holes are clockwise

The proper value depends on the source of your data. Most geometry formats enforce a specific winding order. Incorrectly set winding order will cause an extruded polygon's surfaces to be flipped, affecting culling and the lighting effect.

Thus, this is probably not the highest priority, given that it only happens with extruded polygons, but should be fixed eventually.

In GEOS, polygon winding order is unspecified, so we'd need to check/force it manually. There's no vectorized shapely function to do this, ref https://github.com/shapely/shapely/issues/1366. So the options are either:

So the end goal here is:

Ref https://github.com/geoarrow/deck.gl-layers/issues/36

kylebarron commented 11 months ago

Note that geoarrow-js now has a winding order check and fix https://github.com/geoarrow/geoarrow-js/blob/main/src/algorithm/winding.ts