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

Support Puerto Rico in Albers USA projection #152

Open
kevinahuber opened this issue Jan 5, 2019 · 21 comments · Fixed by #206
Open

Support Puerto Rico in Albers USA projection #152

kevinahuber opened this issue Jan 5, 2019 · 21 comments · Fixed by #206

Comments

@kevinahuber
Copy link

In the Philippe Rivière diagram (and others), the Albers USA projection includes Puerto Rico
image

Would there be an objection to including that in albersUsa.js?

@Fil
Copy link
Member

Fil commented Jan 28, 2019

Not for me to decide, but I would tend to think it a good idea and I don't see a drawback. If you want the map w/o PR, you could filter out PR from your features… the only strange case I'm thinking of is, if you're using the inverse proj in that (oceanic) region.

@mbloch
Copy link

mbloch commented Jan 28, 2019

@kevinahuber, it looks like you pulled in the U.S. Virgin Islands along with P.R... was that on purpose?

@hudsonb
Copy link

hudsonb commented Jan 28, 2019

I'd rather not see this added to albersUsa, but would be for adding a albersUsaPr.

@clhenrick
Copy link

clhenrick commented Jan 28, 2019

One disadvantage I see here is that the counties in Puerto Rico are drawn very small at the scale that's being used in @Fil's diagram and thus difficult to read. That could potentially be overcome by trying to maximize the real estate for it in the lower right corner of the map frame.

Another point worth considering is that Puerto Rico is one of many territories the U.S. holds, and not a state. U.S. Albers projection is specifically meant for representing the lower 48 states, d3 albersUsa is a composite projection that includes the two non-lower 48 states so that all 50 states can be included in a single map which is a common use case. Puerto Rico is often treated as a U.S. state in news coverage and sometimes included in this composite projection, but more than often it isn't.

My vote would be for a separate composite projection that includes Puerto Rico, because it's often not included when mapping data of the U.S. states & counties. If it was to be included by default then users of the projection would have to manually filter it out when it's not needed, which doesn't seem ideal to me.

@mbostock mbostock reopened this Aug 31, 2019
@mbostock
Copy link
Member

(Sorry, misclick.)

@mbostock
Copy link
Member

Here’s an updated implementation:

https://observablehq.com/@d3/u-s-map-with-puerto-rico

It would be nice to generalize this so that we don’t need as much code duplication with the existing geoAlbersUsa. Contributions welcome.

@jake-low
Copy link

jake-low commented Sep 1, 2019

Does this seem like a reasonable approach to reducing said duplication? If so I can clean it up and turn it into a PR.

https://observablehq.com/@jake-low/u-s-map-with-puerto-rico

@mbostock
Copy link
Member

mbostock commented Sep 1, 2019

Hey, thanks @jake-low! That looks promising. One thought I had is whether it’s worth designating the first projection in the list as the “primary” projection, and the others as “inset” projections, with the requirement that the insets are exclusive (non-overlapping) and contained within the clipExtent of the primary projection (if there is a clipExtent). The for doing the inverse projection, you’d test the projections in reverse order so that the primary’s inverse is only used if the given point is not within an inset.

@curran
Copy link
Contributor

curran commented Jun 19, 2020

Since d3/d3-geo-projection#195 was closed as a dupe of this, I thought I might add:

This issue is also about including

  • US Virgin Islands
  • American Samoa
  • Guam, and
  • Northern Mariana Islands

in the projection.

@curran
Copy link
Contributor

curran commented Jun 19, 2020

Renamed the closed issue to Support All US Territories in Albers USA projection to clarify.

@almccon
Copy link

almccon commented Jun 19, 2020

Here's my preferred option, with American Samoa, Guam, and Northern Mariana Islands in the left corner (which makes sense because they're in the Pacific, and therefore should probably be shown to the left of the US, not the right). https://observablehq.com/@almccon/u-s-map-with-puerto-rico-us-virgin-islands-american-samoa-gua
Screen Shot 2020-06-19 at 1 30 33 PM

@armsp
Copy link

armsp commented Jun 28, 2020

I downloaded the geoshape json files - one projected and another un-projected - from Mike Bostock's example both of which have Puerto Rico.

I am trying to display them in the "albersUsa" projection in Vega or Vega-Lite which uses d3. However I don't see it at all. In the unprojected file, "albersUsa" projection filters Puerto Rico and never displays it. In the projected version there is no map, everything is a giant dark rectangle.

@curran @almccon Any idea how to get it to display in Vega/Vega-Lite?

I see that there are some js files with Puerto Rico too, how do I get them to replace the native d3 js file responsible for the "albersUsa" projection? Perhaps this technique may help me with displaying Puerto Rico too in "albersUsa" projection.

Update - GIS StackExchange Post

@curran
Copy link
Contributor

curran commented Jul 1, 2020

@armsp I think you need to register a custom projection extension with Vega, using vega.projection.

@curran
Copy link
Contributor

curran commented Jul 1, 2020

@almccon and I put together a geo-albers-usa-territories package. Feedback welcome!

@bmschmidt
Copy link

bmschmidt commented Dec 7, 2020

Edit--realized I forgot to express gratitude for all of your your work on this library, which is such an impressive achievement that I use frequently. Thank you!

Is it too late to reopen the question of whether @curran and @almccon's great work here should replace geoAlbersUsa in d3-geo, which was the request in both of the issues merged here? A link to an external package helps, but it's not the thing.

Puerto Rico et al. are part of the US. Actively excluding them should be a decision by whoever makes the dataset. If the US census bureau puts them in a shapefile of roads or McDonald's puts them in a csv of US restaurant locations, why would d3-geo insist it's not really USA?

With the current setup, I often don't even realize that Puerto Rico is being deleted from maps where I would have liked it to appear until it raises an unexpected error. E.g. I ended up here today after trying to access the 'coordinates' property of each polygon in a feature collection of the US.

Certainly it's true that lots of people don't expect to see the territories in a map of the US, especially if they're just plotting some global-scale data. But that expectation is bad! Here's a recent book with an on-topic cover that's been widely discussed in the historical profession recently.

Daniel Immerwahr, how to hide an empire, cover image

@kevinahuber
Copy link
Author

kevinahuber commented Dec 8, 2020

I agree with @bmschmidt, and that was the original intent of raising this issue. Thank you for raising this and providing additional details!

@bmschmidt
Copy link

(Just added a thank you to the authors/maintainers in the first post here, which I somehow omitted the first time).

Out of curiosity, went poking around some of the most popular AlbersUsa maps on observable to see if they have Puerto Rico (FIPS 72) data in the underlying set being dropped. It's really common. For instance, there is suppressed PR data in:

  1. Several of @mbostock's maps to demonstrate basic cartographic features of D3, including bubble maps of population from the census, bivariate choropleth of obesity and diabetes from the CDC, and his basic choropleth example using unemployment data
  2. Several of Jeffrey Heer's demonstrations in the introduction to Vega-Lite geographic visualization notebook including zip codes.
  3. Some (e.g., "New York Times Coronavirus cases by county", labor statistics, Census API) but not all (law enforcement agencies) of the county level data in Ian Johnson's set of county level datasets

The only case here where I think the creator might have actively wanted to remove PR is for the bivariate choropleth, where it seems obesity may be missing.

@Fil Fil reopened this Dec 8, 2020
@curran
Copy link
Contributor

curran commented Dec 9, 2020

Totally open to do whatever is required to migrate features from geo-albers-usa-territories into mainline D3!

@Zulu-Inuoe
Copy link

Any movement on this? Having this additional option for albersusa in would save a lot of people a lot of time, as right now everyone seems to be getting along by having to do a lot of reading and eventually doing something like monkey-patching a modified d3-geo version into their project

@andsat
Copy link

andsat commented Mar 21, 2022

Also wondering where this is at. Kind of odd that there's no option to include these US territories in a US map.

@bmschmidt
Copy link

I see four options for including PR and the rest.

  1. Include d3-geo-albersUsa-territories in d3-geo-projections (not this package).
  2. Add an option to d3.geo.AlbersUsa that would add the territories.
  3. Add an option to d3.geoAlbersUsa that drops the territories, plot by default.
  4. Replace d3-geo-albersUsa with d3-geo-albersUsaTerritories.

I support 4 at the next major version bump on the grounds that most plots that drop PR are doing it accidentally. I would also support 3. 1 and 2 would make it harder for users of downstream packages (eg vega-lite) to make a decent map of the whole United States.

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

Successfully merging a pull request may close this issue.