library(ggmap)
library(data.table)
# registrar Google API Key
register_google(key = 'xxxxx-xxxxxx-xxxxx-xxxxx')
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Code by Rafael H. M. Pereira and Marcus Saraiva | |
#' | |
#' Radiation model (Simini et al 2012) | |
#' Tij = Ti * ((Pi * Pj) / ((Pi + Pij) * (Pi + Pj + Pij))) | |
#' | |
#' Where: | |
#' | |
#' Tij: Avarage flux between origin i and destination j predicted by the radiation model | |
#' Ti: Proportion of population in i relative to total population | |
#' Pi: Absolute population in i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gtfs2gps) | |
library(gtfsrouter) | |
# original process | |
sp <- system.file("extdata/saopaulo.zip", package ="gtfs2gps") | |
time_gps <- system.time(gps_gps <- gtfs2gps(sp, parallel = T, spatial_resolution = 200)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(geobr) | |
library(ggplot2) | |
library(sf) | |
library(sfheaders) | |
df <- read_municipality(year=2018) | |
centrd <- st_centroid(df) | |
centrd <- sfheaders::sf_to_df(centrd, fill=T) | |
df$position <- centrd$y + centrd$x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(googleAnalyticsR) | |
library(data.table) | |
library(ggplot2) | |
library(dplyr) | |
library(rworldmap) | |
library(sf) | |
options(scipen=999) | |
## setup | |
ga_auth() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(geobr) | |
library(sf) | |
library(mapview) | |
library(stringr) | |
mapviewOptions(platform = 'leafgl') | |
# read original census tracts | |
urban_cts <- read_census_tract(year = 2000, code_tract = 'RJ', zone ='urban', simplified = F) | |
rural_cts <- read_census_tract(year = 2000, code_tract = 'RJ', zone ='rural', simplified = F) |
A simple reproducible Hexsticker for r5r, a package for Rapid Realistic Routing with R5 in R.
### Libraries ------------------------
remotes::install_github("GuangchuangYu/hexSticker")
library(hexSticker) # https://github.com/GuangchuangYu/hexSticker
library(ggplot2)
library(sf)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
library(sf) | |
library(geobr) | |
# sample spatial data | |
df <- read_state() | |
# create random pop and cases | |
df$pop <- sample(1:27, 27, replace = T) |