Intersect polygons (in planar coords) with polygons (in geo coords).

Dear community, i want to intersect polygons (in planar coordinates) with polygons (in geo coordinates).

See World Grids / neocarto / Observable

Red hexagons are in planar coordinates (svg document). The Black polygon (world outline) is in geographical coordinates (lat, lon). What I want to do is intersect the red polygons (planar) with the black polygon (geo).

To solve that, I tried to unproject reds hexagons. It works in most cases. But at world scale, when dots are outside the sphere, I have some problems (as you can see)

And when I try to project each points defining the world outline, the result is surprising…

From a more general point of view, I need to convert geometries with planar coordinates (in the coordinates of the svg document) into geometries with lat,lon coordinates (from a geojson or topojson). And vice versa. This operation is easy for points with projection() and projection.invert(). Is there the same type of function ready to use for more complex geometries (polygons with holes, multipolygons, etc).

Well, I’m not sure to be clear. But any help is welcome :slight_smile:

1 Like

Is there a computational reason you need to do this? Or, is it just for display purposes? If the latter, then perhaps you could accomplish your objective with a clipPath.

Yes. My idea is to allocate values according to polygons intersections. With Turf.js I gess.

1 Like

Have you looked into d3-geo’s clipping capabilities?

Yes. But I was not able to solve my problem like that. I think my main problem is that I have 2 geometries with different coordinate system.

Well. I found a solution. Final result available here World Grids & some GIS operations / neocarto / Observable. Thanks to all :pray: