hrbrmstr / albersusa

Tools, shapefiles & data to work with an "AlbersUSA" composite projection in R
Other
77 stars 16 forks source link

SpatialPointsDataFrame support? #1

Open rdinter opened 7 years ago

rdinter commented 7 years ago

Is there a method here that can plot a SpatialPointsDataFrame over the state or county map and have the Alaska and Hawaii points adjusted? Possibly a function to take all points within the bounding box of Alaska/Hawaii and adjust to the bounding box of the accompanying shapefiles?

hrbrmstr commented 7 years ago

Aye. I need to work out a bit more of the details for the point transformations for the elided states. Using the core transformation steps doesn't quite get the points where they need to be (though I never poked at it too hard).

rdinter commented 7 years ago

I might be amiss here, but do you have the original shapefile and the transformed shapefile as well? I think I'd be able to create a function with the original shapefile available to the transformed. There's probably an issue with different projections, but at least this would be a temporary first step...

ghost commented 7 years ago

The steps were outlined in a blog post last year (the transformations were the same, though I seem to have misplaced the generation script #sigh). When I helped someone last year with this some elided points did not get placed on the targets in HI and AK. Lemme try to regen it and provide the transform function (will try to get to it by the weekend).

rdinter commented 7 years ago

Found the blog post! And if the shapefiles for albersusa came from that particular post/repository, then it shouldn't be too difficult to add in an elide_points function here.

The maptools::elide() function implicitly uses a bounding box whenever it rotates or scales a polygon. So to rotate, scale, and shift points then we need the original bounding box used for Alaska and Hawaii to get the identical transformation and explicitly call this bounding box with the function. So long as the shapefiles are coming from that post and it's outlined methods, then I've got the bounding boxes.