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

hex sticker #11

Closed
rafapereirabr opened this issue Aug 15, 2020 · 5 comments
Closed

hex sticker #11

rafapereirabr opened this issue Aug 15, 2020 · 5 comments

Comments

@rafapereirabr
Copy link
Member

First things first. r5 should have a cool sticker :) . I've added a script that creates a very simple sticker base we can use as a starting point. Please have a look at it here.

@mvpsaraiva
Copy link
Collaborator

Now, my productivity is gone... I'll spend two months procrastinating on a logo 😆

@rafapereirabr
Copy link
Member Author

rafapereirabr commented Aug 17, 2020

This is a rough idea with a shortest path tree as the "root" of r5r. I drawed this using vectr but ideally the logo should be a reprodducible example in R using OSM, sf, + other packages

Capture

@rafapereirabr
Copy link
Member Author

rafapereirabr commented Aug 20, 2020

Ok, this is my first result using the sample data we have in the package. Let me know what you thin.

r5r_test_b

@rafapereirabr
Copy link
Member Author

Reproducible code for the hex sticker :

##### HEX sticker


### Libraries ------------------------
remotes::install_github("GuangchuangYu/hexSticker")

library(hexSticker) # https://github.com/GuangchuangYu/hexSticker
library(ggplot2)
library(sf)
library(r5r)
library(sysfonts)

# add special text font
sysfonts::font_add_google(name = "Roboto", family = "Roboto")

### setup ------------------------

# load origin/destination points
points <- read.csv(system.file("extdata/poa_hexgrid.csv", package = "r5r"))
points_sf <- sfheaders::sf_point(points, x='lon', y='lat', keep = T)

origin <- subset(points_sf, id == '89a90129977ffff')
destinations <- subset(points_sf, id %like% c('89a901299'))

# build transport network
data_path <- system.file("extdata", package = "r5r")
r5r_core <- setup_r5(data_path = data_path)


# routing
df <- detailed_itineraries(r5r_core,
                           origins = origin,
                           destinations = destinations,
                           mode = 'WALK',
                           departure_datetime = as.POSIXct("13-03-2019 14:00:00", format = "%d-%m-%Y %H:%M:%S"),
                           max_trip_duration = 30000L)


st_crs(destinations) <- st_crs(df)


### network plot  ------------------------

# plot results
test <- ggplot() +
          geom_sf(data = df, color='gray95', alpha=.2) +
          # geom_sf(data=destinations,  color='gray95', size=1) +
          # geom_sf(data=destinations,  color='navyblue', size=.6) +
          scale_x_continuous(limits = c(-51.20560, -51.18052 )) +
          scale_y_continuous(limits = c(-30.02239, -30.0002 )) +
          theme_void() +
          theme(panel.grid.major=element_line(colour="transparent"))


### save sticker  ------------------------

# big
sticker(test,

         # package name
         package= expression(paste("R"^5,"R")),  p_size=10, p_y = 1.5, p_color = "gray95", p_family="Roboto",

         # ggplot image size and position
         s_x=1, s_y=.85, s_width=1.4, s_height=1.4,

         # blue hexagon
         h_fill="#0d8bb1", h_color="white", h_size=1.3,

         ## blackhexagon
         # h_fill="gray20", h_color="gray80", h_size=1.3,

         # url
         url = "github.com/ipeaGIT/r5r", u_color= "gray95", u_family = "Roboto", u_size = 1.8,

         # save output name and resolution
         filename="./man/figures/r5r_biag.png", dpi=300 #
)

logo logo

@rafapereirabr
Copy link
Member Author

I believe we can close this now. Thanks @mvpsaraiva !

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

No branches or pull requests

2 participants