-
Notifications
You must be signed in to change notification settings - Fork 4
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
Get basic SVG map with states & a few HUCs #1
Conversation
# Get basins | ||
# TODO: add more than the one IWS basin and propogate these | ||
# labels through to the SVG additions. | ||
tar_target( | ||
p1_huc8s, c("07120001", "07120002", "07120003") | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if we wanted to make a map with all HUCs we would need to list them all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to make a helper function for this - allow you to pass in specific HUC 8s or get all. But currently, yes you would. Just don't have time to outfit the pipeline to do all the things just yet :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made an issue. See #2
Oh what?! I have been trying to dig into that this morning with no luck. |
bind_rows(usa_addl_islands_sf) %>% | ||
st_buffer(0) %>% | ||
st_cast("MULTIPOLYGON") %>% # Needed to bring back to correct type to use st_coordinates | ||
rmapshaper::ms_simplify(0.5) %>% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could go much lower with this number without any noticeable difference. Would be worth exploring how much that affects files size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capturing these ideas as we go. See #3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, later we could also investigate setting this as a function of how large the bounding box is, with really high simplification for larger CONUS-level maps, where that detail detracts visually, and less simplification for maps that cover regions or smaller areas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌮
Good by me! |
|
||
} | ||
|
||
generate_addl_islands <- function(proj_str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I had no idea that there was so much funkiness to work through. Is this the case with any r spatial data package? Or is it that more of the oddities in how the polygons are drawn and whether or not they are multipolygons come out when converting to svg? Have you explored using another package like rnaturalearth
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was more about how they are drawn once you are creating the SVG. I had to split up like this to make sure the islands are not connected together when drawing. There is a ton of weirdness. It would be fun to explore a different package, but this maps
package is what we've always used, so I had the code to get around the funkiness already :)
I know that there is also usmap
(no territories, so would still need to add those) which I've wanted to explore. Creating an issue to do this, see #6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. That makes sense. So much to think through! Totally makes sense to use existing code that has all the workarounds.
Way more to do but this creates an SVG map!
Lots of "TODOs" marked in the code that I will be coming back to (including the step to push the final SVG map to S3 & smoother parameterization).
Currently have a weird issue with Colorado (
st_buffer(0)
didn't fix that).