Skip to content

Instantly share code, notes, and snippets.

@Fil
Last active September 6, 2018 01:41
Show Gist options
  • Save Fil/f67b0f6ccfa1f072c555775e331c307b to your computer and use it in GitHub Desktop.
Save Fil/f67b0f6ccfa1f072c555775e331c307b to your computer and use it in GitHub Desktop.
d3 geojson polygons
d3 = require("d3-geo", "d3-geo-projection", "d3-geo-voronoi")
polygons = d3.geoVoronoi().polygons({…})
projected = d3.geoProject(
d3.geoProject(
polygons,
d3
.geoEquirectangular()
.scale(180 / Math.PI)
.translate([0, 0])
),
d3.geoIdentity().reflectY(true)
)
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"site":{"geometry":{"coordinates":[2.1699187,41.387917],"type":"Point"},"properties":{},"type":"Feature"},"sitecoordinates":[2.1699186999999998,41.387917],"neighbours":[2,1]},"geometry":{"type":"Polygon","coordinates":[[[-180,-74.0381278500317],[-176.47892607274323,-66.00880576646676],[-174.65569775327359,-57.937832020697115],[-172.68810087050022,-41.754874807896016],[-172.44074527625605,-38.803411475018095],[-172.44074527625605,-38.803411475018095],[-161.16349915493592,-19.14004727575766],[-152.3961056124241,1.0574441119192515],[-143.50938959198953,21.229893551188844],[-131.73871271170887,40.786343208411694],[-123.0829281380575,49.94554621758851],[-110.60545051201875,58.1694877832828],[-91.75328413623009,64.51467704576945],[-65.51106105521595,67.3301654446393],[-38.349086920931356,65.36959778135802],[-18.03771140041878,59.54412514797861],[-4.575705730807699,51.5798693103272],[4.641748608367312,42.551758506707685],[7.559254723744014,38.80341147501814],[8.745867946737622,20.759703539728708],[9.671605572358802,2.7096412267595213],[10.569221589388995,-15.341105924865172],[11.643069846816655,-33.387560874479064],[13.303832218786315,-51.41971318314907],[17.24689305344609,-69.39611592983361],[23.383397266712816,-78.28176993194873],[31.795788775495176,-82.59007759173075],[40.91106075964011,-84.6148317145966],[59.652847807469314,-86.35419750078076],[97.93734174712752,-87.210290201037],[137.69813773652564,-86.46844827671043],[157.66352994865503,-84.76932110618128],[167.26806684892478,-82.75797690849586],[176.00651309975532,-78.45803999823431],[180,-74.0381278500317],[180,-90],[0,-90],[-180,-90],[-180,-74.0381278500317]]]}},{"type":"Feature","properties":{"site":{"geometry":{"coordinates":[7.205232,43.66049],"type":"Point"},"properties":{},"type":"Feature"},"sitecoordinates":[7.205232000000001,43.66049000000001],"neighbours":[0,2]},"geometry":{"type":"Polygon","coordinates":[[[180,-21.784338598516293],[173.64858394856898,-3.09967995010821],[167.5254098022961,15.621592963774702],[160.1318549668064,34.138077707733615],[155.1833299606344,43.19139598683106],[148.5302188056942,51.95752341574594],[138.75338310153333,60.17005259018618],[123.07902186706386,67.21141504199748],[97.7819492577016,71.66932953683644],[66.23197620575824,71.55953508621707],[41.38172320081089,66.94727156386107],[26.04225196100864,59.83385578885997],[16.444800597084114,51.58847297263066],[9.887562308244057,42.80593335892277],[7.559254723744014,38.80341147501814],[4.641748608367312,42.551758506707685],[-4.575705730807699,51.5798693103272],[-18.03771140041878,59.54412514797861],[-38.349086920931356,65.36959778135802],[-65.51106105521595,67.3301654446393],[-91.75328413623009,64.51467704576945],[-110.60545051201875,58.1694877832828],[-123.0829281380575,49.94554621758851],[-131.73871271170887,40.786343208411694],[-143.50938959198953,21.229893551188844],[-152.3961056124241,1.0574441119192515],[-161.16349915493592,-19.14004727575766],[-172.44074527625605,-38.803411475018095],[-172.44074527625605,-38.803411475018095],[-180,-21.784338598516293],[-180,6.16174605111278],[-180,34.10783070074185],[-180,62.053915350370914],[-180,90],[0,90],[180,90],[180,62.053915350370914],[180,34.10783070074185],[180,6.16174605111278],[180,-21.784338598516293]]]}},{"type":"Feature","properties":{"site":{"geometry":{"coordinates":[12.4942486,41.8905198],"type":"Point"},"properties":{},"type":"Feature"},"sitecoordinates":[12.494248600000002,41.89051980000001],"neighbours":[1,0]},"geometry":{"type":"MultiPolygon","coordinates":[[[[180,-74.0381278500317],[176.00651309975532,-78.45803999823431],[167.26806684892478,-82.75797690849586],[157.66352994865503,-84.76932110618128],[137.69813773652564,-86.46844827671043],[97.93734174712752,-87.210290201037],[59.652847807469314,-86.35419750078076],[40.91106075964011,-84.6148317145966],[31.795788775495176,-82.59007759173075],[23.383397266712816,-78.28176993194873],[17.24689305344609,-69.39611592983361],[13.303832218786315,-51.41971318314907],[11.643069846816655,-33.387560874479064],[10.569221589388995,-15.341105924865172],[9.671605572358802,2.7096412267595213],[8.745867946737622,20.759703539728708],[7.559254723744014,38.80341147501814],[9.887562308244057,42.80593335892277],[16.444800597084114,51.58847297263066],[26.04225196100864,59.83385578885997],[41.38172320081089,66.94727156386107],[66.23197620575824,71.55953508621707],[97.7819492577016,71.66932953683644],[123.07902186706386,67.21141504199748],[138.75338310153333,60.17005259018618],[148.5302188056942,51.95752341574594],[155.1833299606344,43.19139598683106],[160.1318549668064,34.138077707733615],[167.5254098022961,15.621592963774702],[173.64858394856898,-3.09967995010821],[180,-21.784338598516293],[180,-47.911233224274],[180,-74.0381278500317],[180,-74.0381278500317]]],[[[-180,-21.784338598516293],[-172.44074527625605,-38.803411475018095],[-172.44074527625605,-38.803411475018095],[-172.68810087050022,-41.754874807896016],[-174.65569775327359,-57.937832020697115],[-176.47892607274323,-66.00880576646676],[-180,-74.0381278500317],[-180,-47.911233224274],[-180,-21.784338598516293],[-180,-21.784338598516293]]]]}}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment