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

Add Puerto Rico #34

Closed
wants to merge 7 commits into from
Closed

Add Puerto Rico #34

wants to merge 7 commits into from

Conversation

dcaud
Copy link

@dcaud dcaud commented Apr 22, 2020

I've tried to revise things to make PR remapping in the Gulf of Mexico a reality.

I made some progress for sure:

  1. Points in PR remap to the Gulf with usmap_transform().
  2. The big basis issue is that I can't get the outline of PR to plot.

Please have mercy on me...I'm still figuring out much of github, making changes to libraries, and your wonderful package!

Any idea what to do next?

Likely need to adjust Bounding Pox for Puerto Rico
@dcaud
Copy link
Author

dcaud commented May 1, 2020

I think I may also need to add Puerto Rico data to the "us_states_raw.csv" file so the following works in format_map_df.R

states_map_df <- readr::read_csv("us_states_raw.csv")

the same goes for the centroid raw data (us_state_centroids_raw.csv)

However, I'm not sure the source of those files. Any ideas?

@dcaud
Copy link
Author

dcaud commented May 1, 2020

Here's something that may work to get shape data for PR:

library(tidyverse)       # Tidyverse for Tidy Data
library(tmap)            # Thematic Mapping
library(tmaptools)
library(tigris)          # Get Census Geography Poloygons
library(sf)

us_geo <- tigris::states(class = "sf")

select_states <- us_geo %>%
  filter(STUSPS ==  "PR")

tm_shape(select_states) +
  tm_polygons( id = "Name")

sp_select_states <- as_Spatial(select_states)

library(broom)

map_data_fortified <- tidy(sp_select_states)  %>%
  mutate(id = as.numeric(id))

write.csv(map_data_fortified, "us_states_raw_with_PR.csv", row.names = FALSE)

@dcaud
Copy link
Author

dcaud commented May 1, 2020

I've now got something that mostly works, but needs a good bit of clean-up. The below map is created by the below code:

image

library(devtools)
install_github("dcaud/usmap")
library(usmap)

# notice new last data points for San Juan, Puerto Rico
data <- data.frame(
  lon = c(-74.01, -95.36, -118.24, -87.65, -134.42, -157.86, -66.104),
  lat = c(40.71, 29.76, 34.05, 41.85, 58.30, 21.31, 18.466),
  pop = c(8398748, 2325502, 3990456, 2705994, 32113, 347397, 347052)
)

# Transform data
transformed_data <- usmap_transform(data)

# Plot transformed data on map
library(ggplot2)

plot_usmap() + geom_point(
  data = transformed_data,
  aes(x = lon.1, y = lat.1, size = pop),
  color = "red", alpha = 0.5
)

And just for reference, here's where San Juan is according to Google Maps:

image

San Juan plots on the top right of the island in both images.

There are a few things to revise, but here's one to start with:

Create-map-df.R now just produces the needed extra data for PR, which is then merged to the older data in format-map-df.R. That process could probably be done all in create-map-df.R and format-map-df.R could be returned to its prior state.

@pdil pdil self-assigned this Jul 7, 2020
@pdil pdil added the enhancement A suggestion or feature that improves existing functionality label Jul 7, 2020
@pdil pdil self-requested a review July 7, 2020 21:07
@pdil pdil removed their assignment Jul 7, 2020
@pdil
Copy link
Owner

pdil commented Jul 7, 2020

@dcaud Sorry for the delay in getting to this, I'll be reviewing the PR over the next couple days as I have time. Thanks for all your work!

@sarah-colq
Copy link

Hello! @pdil I notice that the travis CI is no longer being used as per #37 , would that fix the build problem here since it's the travis-ci that's failing? Thanks!

@pdil
Copy link
Owner

pdil commented Oct 28, 2020

Hello! @pdil I notice that the travis CI is no longer being used as per #37 , would that fix the build problem here since it's the travis-ci that's failing? Thanks!

@sarah-colq Travis CI was removed after this PR was created, as well as a lot of other changes so the master branch would have to be merged into this PR first before continuing to work on it so that build issues could be resolved.

@erstearns
Copy link

Hi all! @pdil -- just following up on the status of this as Puerto Rico is still not visible (at least not in the CRAN version of the package). Great package and really looking forward to the Puerto Rico inclusion! Thanks!

@pdil
Copy link
Owner

pdil commented Jun 6, 2022

Hi all! @pdil -- just following up on the status of this as Puerto Rico is still not visible (at least not in the CRAN version of the package). Great package and really looking forward to the Puerto Rico inclusion! Thanks!

@erstearns Thanks for the kind words! Unfortunately this pull request is quite old, but I will look into adding Puerto Rico (and other territories) to the current package since there has been interest in its inclusion for some time. Issue #20 is still open so we can use that to track it.

@pdil pdil closed this Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A suggestion or feature that improves existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants