Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering of USA map using geoAlbersUsa not as expected. #65

Closed
gallowayevan opened this issue Aug 4, 2022 · 2 comments
Closed

Rendering of USA map using geoAlbersUsa not as expected. #65

gallowayevan opened this issue Aug 4, 2022 · 2 comments

Comments

@gallowayevan
Copy link

I've really enjoyed playing with this library - fills a much needed gap in javascript cartography!

I ran into an issue making a map of the US. I have geojson of US states from the US Census (https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html; converted from shapefile to geojson using mapshaper). When I try to make a state map using bertin.js, I get this: https://observablehq.com/d/c5d2bf78b1e0534e
The most interesting thing about the rendering is that one state at a time will be stroked white, and you can trigger a change in the displayed state by mousing out of the cell.

I'm not sure what is causing this - maybe the Alaska and Hawaii inset in the AlbersUSA projection break things somehow?

@Fil
Copy link
Contributor

Fil commented Aug 4, 2022

The shapes are not in the winding order that D3 expects; try this import:
import {normalizeWindingInPlace} from "@fil/normalize-winding"

then call
cb_2021_us_state_500k = FileAttachment("cb_2021_us_state_500k.json").json().then(normalizeWindingInPlace)

@gallowayevan
Copy link
Author

Thanks, Fil! That was it. I thought I had checked the winding order when converting in mapshaper, but I guess not!

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

No branches or pull requests

2 participants