1

I have a shapefile that has all the US counties along with Puerto Rico and I want to visualize them in "albersUsa" projection using Vega or Vega-Lite.

Problem is that in other projections, Puerto Rico is visible but in "albersUsa" projeciton it vanishes.

The closest I got to is this example by Mike Bostock.

You can download the counties-10m.json file over there.

Is there a way to render it completely(including Puerto Rico) as an "albersUsa" projection?

My biggest concern is that the "albersUsa" projection itself won't allow Puerto Rico to be displayed.

Any leads on how do I go about using a composite projection in Vega. Since there is an example in d3 and Vega is built on top of d3, I suppose there should be a way.

EDIT

It looks like the file here has a projected version of Puerto Rico in albersUsa projection.

However, when I plot it in Vega-Lite using "albersUsa" projection, I get the following - enter image description here

2

Vega does not support the AlbersUSA projection with Puerto Rico in it because the D3 implementation doesn't either. You can add a custom projection to Vega, though. See https://vega.github.io/vega/docs/api/extensibility/#projections for documentation on how to add a custom projection.

3
  • Is there a way to do it via the JSON specifications? I am a little comfortable with Vega-Lite and Altair but not with Vega. So it may take a very long time for me to actually grasp how to make it work. – jar Jun 28 '20 at 2:42
  • Unfortunately not since you need to provide the implementation of the projection. – dominik Jun 28 '20 at 19:45
  • That makes sense. So for the implementation we would need a javascript file right? Something like this or this ? The next question is, where do I keep the js files so that it is used instead of the default files that does not have the implementation of the projection? How will a Vega spec make use of the new implementation in these files? – jar Jun 29 '20 at 3:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.