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

Get basic SVG map with states & a few HUCs #1

Merged
merged 4 commits into from
Nov 23, 2021

Conversation

lindsayplatt
Copy link
Contributor

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).
image

Comment on lines +20 to +25
# 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")
),
Copy link
Member

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?

Copy link
Contributor Author

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 :)

Copy link
Contributor Author

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

@cnell-usgs
Copy link
Member

The map created for me did not have the CO line:
Screen Shot 2021-11-23 at 7 21 37 AM

@lindsayplatt
Copy link
Contributor Author

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) %>%
Copy link
Member

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

Copy link
Contributor Author

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

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.

Copy link
Member

@cnell-usgs cnell-usgs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌮

@cnell-usgs
Copy link
Member

Good by me!

@lindsayplatt lindsayplatt merged commit 7a40a48 into USGS-VIZLAB:main Nov 23, 2021

}

generate_addl_islands <- function(proj_str) {

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?

Copy link
Contributor Author

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

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.

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

Successfully merging this pull request may close these issues.

3 participants