New York Centroid Fixed
✓ Published0🌍 Public
PPhilippe Rivière
Last edited Feb 20, 2017
Created on Feb 15, 2017
This example demonstrates a workaround for a known issue in d3-geo where computing the centroid of a geographic feature collection can produce inaccurate results. It visualizes New York City neighborhoods on a Mercator projection, with orange and red dots marking computed centroids. The code uses `d3.geoCentroid` and `d3.geoPath` to project and render the data. A fix is applied by including the centroids as a MultiPoint feature in the projection's `fitExtent` calculation, ensuring the map is properly scaled and centered on the data.
AI-generated descriptionFix for d3-geo issue #81.
forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/c62c0d706d1f046f84c0f0cf698bc0a9'>New York Centroid Test</a>
mit Licensed