This file contains 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
# Source this file at the top of an R or Rmd file using `rgrass` together | |
# with GRASS 8 installed via OSGeo4W (https://trac.osgeo.org/osgeo4w/) on a | |
# Windows machine. | |
# e.g. source(file.path(getwd(), 'grass8-setup-win-osgeo4w.R')) | |
# You can alternatively add the contents to a project-specific .Rprofile. | |
# Its better to set these variables in an R session rather than in System, | |
# especially if you have other GIS software like PostGIS installed, which has |
This file contains 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
# In reference to https://fosstodon.org/@TheRealJimShady/109559871547727070 | |
# Caution! Much like h3jsr itself, just because you can do this doesn't mean you should :P | |
# Nonetheless, a demonstration: | |
library(terra) | |
library(sf) | |
library(dplyr) | |
library(h3jsr) |
This file contains 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(munsellinterpol) | |
library(dplyr) | |
library(tibble) | |
library(purrr) | |
rgb2hex <- function(r,g,b) rgb(r, g, b, maxColorValue = 255) | |
munsells <- tribble(~ID, ~HUE, ~VALUE, ~CHROMA, | |
1, '10YR', '3', '6', | |
2, '5Y', '5', '1', |
This file contains 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
# further to https://urbandemographics.blogspot.com/2016/04/creating-tilted-and-stacked-maps-in-r.html, | |
# an sf-friendly approach. | |
library(sf) | |
nc <- st_read(system.file('shape/nc.shp', package = 'sf')) | |
plot(nc) | |
sm <- matrix(c(2, 1.2, 0, 1), 2, 2) |
This file contains 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
# Source this file at the top of an R or Rmd file using rgrass7 together | |
# with GRASS installed via OSGeo4W (https://trac.osgeo.org/osgeo4w/) on a | |
# Windows machine. | |
# e.g. source(file.path(getwd(), 'rgrass7-setup-win-osgeo4w.R')) | |
# You can alternatively add the contents to a project-specific .Rprofile. | |
# Its better to set these variables in an R session rather than in System, | |
# especially if you have other GIS software like PostGIS installed, which has |
This file contains 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
# re https://twitter.com/Dale_Masch/status/1184744060428242944 | |
library(sf) | |
nc <- st_read(system.file("shape/nc.shp", package="sf")) | |
# I should get this damn epsg code tattooed somewhere | |
nc1 <- st_transform(nc[1, ], 32617) | |
# randomise grid origin a little | |
rx <- sample(seq(-250, 250), 1) |
This file contains 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
# Recipe for pulling imagery crops from the Queensland Government's public imagery basemap | |
# remember to credit output images appropriately using the metadata info at | |
# http://qldspatial.information.qld.gov.au/catalogue/custom/search.page?q=%22Queensland+Imagery+Whole+Of+State+Satellite+Public+Basemap+Service%22 | |
library(sf) | |
library(raster) | |
library(httr) | |
# web service - QLD Imagery Whole of State Public basemap (no WCS unforts, hence all this) | |
qldimg_wms <- 'https://spatial-img.information.qld.gov.au/arcgis/services/Basemaps/LatestSatelliteWOS_AllUsers/ImageServer/WMSServer?' |
This file contains 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
# after https://twitter.com/ColinJCarlson/status/1142202184324530176 | |
# kind of riffs of the game of life demo in ?raster::focal | |
grow_by_one <- function(x = NULL) { | |
focal(x, w = matrix(1, ncol = 3, nrow = 3), | |
fun = function(win) { | |
if(!is.na(win[5])) { | |
return(win[5]) | |
} | |
This file contains 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
# datapasta'd http://worldpopulationreview.com/us-counties/nc/ | |
#library(datapasta) | |
#df_paste() | |
nc_pop <- data.frame(stringsAsFactors=FALSE, | |
V1 = c("Mecklenburg County", "Wake County", "Guilford County", | |
"Forsyth County", "Cumberland County", "Durham County", | |
"Buncombe County", "Union County", "New Hanover County", | |
"Gaston County", "Cabarrus County", "Johnston County", "Onslow County", | |
"Pitt County", "Iredell County", "Davidson County", | |
"Alamance County", "Catawba County", "Orange County", "Randolph County", |
This file contains 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
# faffing about with methods to approximate a "lag vertex polygon" (Poore, 1986) | |
# or "best-fit regular geometric feature" (Stoddard, 1965) for polygon shape | |
# metric | |
# References: | |
# Poore 1986 - MSc Thesis on soil map quantification at | |
# https://ir.library.oregonstate.edu/downloads/zk51vk04q | |
# Stoddart, D. (1965). The shape of atolls. Marine Geology, 3(5), 369–383. | |
# doi:10.1016/0025-3227(65)90025-3 (its on scihub) | |
# also apparently Fridland 1972 "The pattern of the soil cover" but that's |
NewerOlder