Well. I’m testing turff.js within Observable to build buffers around countries. It’s simple and it works perfectly.
Here’s version of your notebook with working behaviours:
I assume that the winding order of some of your features is wrong. The d3-geo docs state:
Spherical polygons also require a winding order convention to determine which side of the polygon is the inside: the exterior ring for polygons smaller than a hemisphere must be clockwise, while the exterior ring for polygons larger than a hemisphere must be anticlockwise. Interior rings representing holes must use the opposite winding order of their exterior ring. This winding order convention is also used by TopoJSON and ESRI shapefiles; however, it is the opposite convention of GeoJSON’s RFC 7946. (Also note that standard GeoJSON WGS84 uses planar equirectangular coordinates, not spherical coordinates, and thus may require stitching to remove antimeridian cuts.)
This becomes apparent if you call:
and then rerun the SVG cell.
Thank you. The pb is solved using geojson-rewind GitHub - mapbox/geojson-rewind: enforce polygon ring winding order for geojson.
rewind = require(‘https://email@example.com’)
buff2 = rewind(mybuffer, true)
Nice notebook @neocarto :
Thank you! I really learned a lot!