Centroids and bounds
Bounds are the limits of the rectangle that contains the entire shape, and are an important measure for selecting and zooming to shape boundaries. Centroids are the center of gravity of a shape, and are useful for placing labels or symbols near the middle of the shape. Centroids and bounds may be computed on the sphere, before the projection occurs, or on the projected plane.
Planar centroids and bounds are computed with d3.geoPath() methods. The geoPath.centroid(object) method returns an array with pixel coordinates [x,y] for the projected planar centroid of a shape. The geoPath.bounds(object) method returns pixel coordinates of two opposite corners of a rectangle that contains the projected object, in an array with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access