Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postclip with polygon path maybe... #266

Open
saifulazfar opened this issue Oct 5, 2022 · 10 comments
Open

postclip with polygon path maybe... #266

saifulazfar opened this issue Oct 5, 2022 · 10 comments

Comments

@saifulazfar
Copy link

saifulazfar commented Oct 5, 2022

im trying making a composite projection map as shown here

https://observablehq.com/@saifulazfar/composite-projection-with-d3-geoclippolygon

the map was originally design with avenza mappublisher to get the initial composition..i understand the sphere coordinate cause the issue of rounded with geoClip.polygon...but is there a way postclip with path/polygon? not just with rectangle...

im trying recreating this natgeo pacific map
\ picture remove due to copyright concern

@Fil
Copy link
Member

Fil commented Oct 5, 2022

We can define the spherical pre-clip shapes with more intermediate points—it still won't be a perfect line, but the issue will not be visible. On top of that, it's difficult to clip a shape with itself, so we need to take extra-care when we draw the outlines. I've sent you a suggestion. This is going to be a beautiful map!

@Fil
Copy link
Member

Fil commented Oct 5, 2022

PS: There might be a way to do the correct planar clipping, but it will be for another time :)

@saifulazfar
Copy link
Author

saifulazfar commented Oct 5, 2022

thank u for your help...looks great...

@saifulazfar
Copy link
Author

saifulazfar commented Oct 7, 2022

sory another one question @Fil ... is there any plan support postclip with polygon path...while currently the map clip was define with coordinates interpolate planar...definitely works great with any projection...but its still hard-code coordinate...maybe i want like just draw mask/clip with svg/canvas so there is flexibilty to define margin/gap between composition map or such...like mbostock postclip example looks great define margin/padding but still lmit to rectangle...just wonder how with custom polygon with postclip

@saifulazfar saifulazfar reopened this Oct 7, 2022
@Fil
Copy link
Member

Fil commented Oct 10, 2022

d3-geo doesn't include a generic planar clipping algorithm (see d3/d3-polygon#4). It would be neat to have a generic clipping function (polygon postclip), but I don't think there is an easy solution.

@saifulazfar
Copy link
Author

hi @Fil ..sory for reopen this issue just...since interpolate planar works great to counter clip with spehere coordinate...i assume there is no way to have rounded clip right?...like shown image below
NG New Zealand NewGuinea 1962

@Fil
Copy link
Member

Fil commented Apr 3, 2023

The "rounded path" needs to be a polygon with as many vertices as necessary to give a good enough precision?

@saifulazfar
Copy link
Author

need help https://observablehq.com/d/63fa416fb7f91e82 ... how to use d3.geoClipAntimeridian to clip d3.geoInterruptedHomolosine()

@Fil
Copy link
Member

Fil commented Apr 7, 2023

you could try this:

<clipPath id="popsdensityclip"><path d="${pops_density(outline)}" /></clipPath>
<path stroke="#333333" fill="white" stroke-width="0.4" d="${pops_density(land)}" clip-path="url(#popsdensityclip)" />
<path stroke="#333333" fill="none" stroke-width="1" d="${pops_density(outline)}"  />

Capture d’écran 2023-04-07 à 06 55 02

(and remove the antimeridian clip)

@saifulazfar
Copy link
Author

saifulazfar commented Apr 7, 2023

yeah...i tought originally there are like d3.geo.polygon way of clip the sphere of Interrupt Goode Homolosine projection...after looks at more example it seems just use svg and canvas clip only...i prefer to use d3.geo.polygon way of clipping (either clipAngle or d3.clipPolygon) since its more code literate and cleaner code output...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants