Skip to content

d3.geoBounds gives incorrect bounds for one of the polygons in world-atlas countries50, Fiji) #243

Description

@jrus

If I do:

const countries50 = (() => {
  const
    url = "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-50m.json",
    raw = await fetch(url),
    topo = await raw.json();
  return topojson.feature(topo, topo.objects.countries);
})();

const fiji = countries50.features[170];
const polygon = ({ type: 'Polygon', coordinates: fiji.geometry.coordinates[15] })
const bounds = d3.geoBounds(polygon)

The result is [[-180,-16.541749856561054],[180,-16.43238163897263]]

I would instead expect the left longitude to be 179.something and the right longitude to be -179.something.

After conversion from topojson to geojson, the polygon in question has coordinates:

[
  [180,-16.54001385310727],
  [179.9855998559986,-16.541749856561054],
  [179.9855998559986,-16.522653818569424],
  [-180,-16.48966975294752],
  [-179.94239942399423,-16.441061656241544],
  [-179.89919899198992,-16.43238163897263],
  [-179.9279992799928,-16.479253732224805],
  [-179.9279992799928,-16.503557780577793],
  [-180,-16.54001385310727],
  [180,-16.54001385310727]
]

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions