developmentseed / dirty-reprojectors

Make quick and dirty projections to use in your web maps instead of Web Mercator
https://www.developmentseed.org/dirty-reprojectors-app/
MIT License
120 stars 10 forks source link

Reprojecting Puerto Rico in albersUsa projection doesn't show it in the map #19

Open armsp opened 4 years ago

armsp commented 4 years ago

I have a peculiar issue - I have a shapefile of States from the US Census website which has Puerto Rico. As usual, PR is not shown in albersUsa projection. Doing a web search showed me that I can reproject the file using dirty-reprojectors and make albersUsa projection show PR.

So I used the following command - cat states.geojson | dirty-reproject --forward albersUsa > states_pr.geojson However, when I read the states_pr.geojson file in geopandas, then I don't see Puerto Rico like before. I understand that I am not using d3, rather geopandas, but my understanding was that if PR is reprojected to albersUsa then even geopandas or any other charting library should be able to plot it, right?

dereklieu commented 4 years ago

Hi @armsp unfortunately Puerto Rico is not included in the output of the d3 projection that this library uses under the hood.

Using the command you reference means you're using d3's implementation of albers even if you choose to view the output in geopandas, or qgis, or any other software.

It looks like there has been work done to show Puerto Rico in a custom albers projection. It should be pretty straightforward for someone to add that projection to the ones available in this repo.

armsp commented 4 years ago

@dereklieu I think I may have completely misunderstood https://github.com/d3/d3-geo/issues/152 and https://github.com/developmentseed/dirty-reprojectors/issues/17 I thought that all I have to do to add Puerto Rico in an albersUsa projection is to use your library. I got started with GIS a few weeks ago, so I don't think I would be able to do it, but anyways, thanks for the clarification at least.

soichih commented 3 years ago

I saw this post

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

and I've updated the patch so that it will work with the version of @d3. Now I am seeing Puerto Rico data!

image

Here is the patched version of d3-geo.js

https://github.com/soichih/apred/blob/master/backend/container/d3-geo.js

You can install this by doing something like $ cp d3-geo.js /usr/local/lib/node_modules/dirty-reprojectors/node_modules/d3-geo/dist/d3-geo.js

Or if you'd like to use my docker container, feel free to use this cat input.geojson | singularity exec docker://soichih/apred:1.1 dirty-reprojectors --forward albersUsa > output.geojson

Tmodurr commented 1 year ago

@soichih are you aware if the approach you took with PR will also work with other US territories (e.g Guam, etc)?

Tmodurr commented 1 year ago

@soichih are you aware if the approach you took with PR will also work with other US territories (e.g Guam, etc)?

@armsp @soichih pinging this again if you get a sec?