Skip to content

Instantly share code, notes, and snippets.

View agila5's full-sized avatar

Andrea Gilardi agila5

View GitHub Profile
@agila5
agila5 / inla-me.md
Created March 8, 2021 15:25
INLA-ME
# packages
library(INLA)
#> Carico il pacchetto richiesto: Matrix
#> Carico il pacchetto richiesto: foreach
#> Carico il pacchetto richiesto: parallel
#> Carico il pacchetto richiesto: sp
#> This is INLA_21.02.23 built 2021-02-22 21:11:05 UTC.
#>  - See www.r-inla.org/contact-us for how to get help.
# load packages
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
# packages
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
# packages
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(sfnetworks)

# create network
roxel_sfn <- as_sfnetwork(roxel, directed = FALSE)

# sample two points in that area
string <- "\"sidewalk\"=>\"none\""
print(string, quote = FALSE)
#> [1] "sidewalk"=>"none"
read.table(
  text = gsub(',?([^,]+)=>',"\n\\1:", string, perl = TRUE), 
  sep = ":", 
  col.names = c("key", "value")
)
#&gt; key value
library(sf)
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
# packages
library(spatstat)
#> Loading required package: spatstat.data
#> Loading required package: spatstat.geom
#> spatstat.geom 2.2-2
#> Loading required package: spatstat.core
#> Loading required package: nlme
#> Loading required package: rpart
#> spatstat.core 2.3-0
# packages
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1
library(osmdata)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(osmextract)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright.
#> Check the package website, https://docs.ropensci.org/osmextract/, for more details.
data_old <- tibble::tibble(
  "Location_Northing_OSGR" = c(1, 2, 3), 
  '1st_Road_Number' = c("a", "b", "c")
)
janitor::clean_names(data_old, replace = c("1" = "fir"))
#> # A tibble: 3 x 2
#>   location_northing_osgr first_road_number
#>                    <dbl> <chr>            
#&gt; 1 1 a 
# packages
library(tidygraph)
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(sfnetworks)