1

I am trying to make a map of North Carolina, USA. Everything is working until I change

var path = d3.geoPath();

to

var path = d3.geoPath().projection(projection);

When I do that, the map turn into this triangle off the top right corner.

Block: http://bl.ocks.org/Ognami/0ce1d2777c97f4adedfd06e32996076a

Ognami
  • 190
  • 1
  • 8
  • 1
    Your data would appear to be projected based on the name `nc-albers`, which can be confirmed when looking at the coordinates, eg: `[870.3929659530004,229.4677310032339]` as these aren't latitude longitude pairs. This also explains why it works without a projection - it's already Cartesian data. A d3 geoprojection takes in lat/long pairs - non Cartesian data (points on a 3d globe). Instead, a d3.geoIdentity would probably fit the bill fairly easily. This [answer](https://stackoverflow.com/a/42430876/7106086) should help with working with projected data and/or d3 geoIdentities. – Andrew Reid Jul 23 '18 at 17:53
  • Oh.... Somehow this very important tidbit just didn't process in my head. I understand now. The coordinate I am trying to plot is lat/log, but the map is already projected to flat coords for my map. Thank you. – Ognami Jul 23 '18 at 17:57
  • No problem, it's easy to miss. Glad to help. – Andrew Reid Jul 23 '18 at 17:59

0 Answers0