-
Notifications
You must be signed in to change notification settings - Fork 2
/
UsefulCode_databases.Rmd
196 lines (142 loc) · 6.29 KB
/
UsefulCode_databases.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
---
title: Useful R code - databases
author: |
| Matthew Malishev
| @darwinanddavis
fontsize: 10
geometry: margin=1in
documentclass: article
linkcolor: pink
urlcolor: blue
citecolor: red
always_allow_html: yes
output:
html_document:
highlight: tango
code_folding: show
toc: yes
toc_depth: 4
number_sections: no
toc_float: yes
md_document:
variant: markdown_github
pdf_document:
includes:
in_header: # add .tex file with header content
highlight: tango
template: null
fig_width: 4
fig_height: 5
fig_caption: true
df_print: tibble
citation_package: biblatex # natbib
latex_engine: xelatex #pdflatex # lualatex
keep_tex: true # keep .tex file in dir
word_document:
highlight: tango
keep_md: yes
pandoc_args: --smart
#reference: mystyles.docx
inludes:
before_body: before_body.tex
subtitle:
tags:
- nothing
- nothingness
params:
dir: "/Users/malishev/Documents/Melbourne Uni/Programs/R code/UsefulCode"
date: !r Sys.Date()
version: !r getRversion()
email: "matthew.malishev [at] gmail.com"
doi: https://github.com/darwinanddavis/UsefulCode
classoption: portrait
# ^['https://github.com/darwinanddavis/UsefulCode'] # footnote
---
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ TeX: { equationNumbers: {autoNumber: "all"} } });
</script>
```{r echo = FALSE}
library(rmarkdown)
# setwd("")
# f <- list.files()[1]
# render(f, output_format='pdf_document')
# render(f, output_format='pdf_document')
```
```{r, set-options, echo = FALSE, cache = FALSE}
options(width=100)
knitr::opts_chunk$set(
eval = F, # run all code
results='hide',
# echo = FALSE, # show code chunks in output
comment = "",
tidy.opts=list(width.cutoff=100), # set width of code chunks in output
tidy=TRUE, # make output as tidy
message = FALSE, # mask all messages
warning = FALSE, # mask all warnings
collapse = T,
size="small" # set code chunk size
)
# https://github.com/ucb-stat133/stat133-fall-2016/blob/master/hws/hw02-tables-ggplot.Rmd
knitr::opts_knit$set(root.dir=paste0(params$dir,"/")) # set working dir
setwd(paste0(params$dir,"/")) # for running just in R not knitr
pacman::p_load(dplyr,readr,rvest,xml2,magrittr,sp,sf,rgdal,ggmap,ggplot2,stringr,ggthemes,ggnetwork,colorspace,ggtext,ggsn,ggspatial,showtext,here)
```
\
Date: `r params$date`
`R` version: `r params$version`
*Corresponding author: `r params$email`
This document can be found at `r params$doi`
\newpage
## Overview
Directory for online databases and collating useful online resources
### Population
Hi-res world population density
https://data.humdata.org/organization/kontur
### hillshade and elevation data options
import hillshade and bathymetry data https://nceas.github.io/oss-lessons/spatial-data-gis-law/3-mon-intro-gis-in-r.html
hillshade/relief esri plot backgrounds?
https://github.com/riatelab/maptiles
hires hillshade render x rayshade
https://github.com/pierreroudier/hillshader
elevation/hillsahde mapping {stars} https://twitter.com/ldcgodoy/status/1327462181806469120/photo/1
raster/hillshade rnaturalearth data as alt raster/hillshade method https://www.naturalearthdata.com/downloads/10m-raster-data/
hi-res elevation relief in ggplot
https://timogrossenbacher.ch/2016/12/beautiful-thematic-maps-with-ggplot2-only/
hillshade/elevation in raster (ne_download)
https://www.naturalearthdata.com/downloads/10m-raster-data/
good ggplot examples w full country polygon ('relief map') https://rpubs.com/MRufino/Portugal
elevation from gpx files
https://rpubs.com/ials2un/gpx1
mask/crop hlllshade or raster to area (plus inverse mask) https://geocompr.robinlovelace.net/geometric-operations.html
reduce tiff/raster size using resize_matrix() {rayshader} https://www.tylermw.com/adding-open-street-map-data-to-rayshader-maps-in-r/
{hillshader}
get image/elevation by bbox (north america) https://elevation.nationalmap.gov/arcgis/rest/services/3DEPElevation/ImageServer/exportImage?bbox=-122.522%2C37.707%2C-122.354%2C37.84&bboxSR=4326&size=600%2C480&imageSR=4326&time=&format=jpgpng&pixelType=F32&noData=&noDataInterpretation=esriNoDataMatchAny&interpolation=+RSP_BilinearInterpolation&compression=&compressionQuality=&bandIds=&mosaicRule=&renderingRule=&f=html
global elevation by tilesets
https://srtm.csi.cgiar.org/srtmdata/
tanaka maps and tanaka contours with ggplot
https://github.com/riatelab/tanaka
### Elevation profile
get elevation profile for line passing through raster layer https://geocompr.robinlovelace.net/raster-vector.html
digital elevation profile based on xyz data https://rdrr.io/github/ITSLeeds/slopes/man/plot_dz.html
sparkline plot for interactive elevation profile {https://www.rpubs.com/dnchari/rcharts}
### 3d renders/maps
3d globe http://www.rayrender.net/
rayvista 3d landscapes https://github.com/h-a-graham/rayvista
spinning d3 globe https://daranzolin.github.io/software/
hires raster globe using {stars} https://ggplot2-book.org/maps.html
{webglobe} https://twitter.com/richard_vogg/status/1333032445931900928/photo/1
{globe4r} https://twitter.com/dickoah/status/1333082949638627329
city pop density maps with rayshader
https://github.com/Pecners/rayshader_portraits/blob/main/R/portraits/alabama/render_graphic.R L65
### Bathymetry
bath1 - https://mikkovihtakari.github.io/ggOceanMaps/
bath2 w ggplot examples - https://rpubs.com/MRufino/Portugal
bath3 (marmap) - https://rdrr.io/cran/marmap/man/readGEBCO.bathy.html
routing directions check googleway option for getting driving directions
(https://stackoverflow.com/questions/40077798/r-plotting-multiple-decoded-polylines-using-leaflet)
mapbox routing directions and road network https://walker-data.com/mapboxapi/articles/navigation.html
osrm::osrmRoute() https://github.com/daranzolin/freshAirFinderApp/blob/main/inst/freshAirFinder/app.R
lubridate::cyclic_encoding() cycling duration/distance
{sfnetworks} calc distance between points https://stackoverflow.com/questions/70186124/how-to-calculate-distances-between-points-along-a-path
{r5r} Rapid Realistic Routing with R5 in R https://cran.r-project.org/web/packages/r5r/vignettes/intro_to_r5r.html
{geobr} & {r5r} isopleth walking/routing times (for colouring osm data with multicoloured streets) https://www.urbandemographics.org/post/mapping-walking-time-osm-r5r/