A real Rust library for Zarr, including virtualization support, Icechunk integration and v3.
has its own Zarr v2 and v3 internal implementation, works but
A real Rust library for Zarr, including virtualization support, Icechunk integration and v3.
has its own Zarr v2 and v3 internal implementation, works but
isolines_terra_sf <- function(x, levels) {
if (missing(levels)) {
levels <- pretty(unlist(minmax(x[[1]])))
}
## OMG: note the [[1]] and wide = TRUE which is also weird but different to raster ...
b <- isoband::isolines(xFromCol(x), yFromRow(x), as.matrix(x[[1]], wide = TRUE), levels = levels)
sf::st_sf(level = levels, geometry = sf::st_sfc(isoband::iso_to_sfg(b), crs = crs(x)))| st_from_ellipses = function(path, crs = "EPSG:25832", res = 30) { | |
| e = read.csv(path) | |
| pnt = sf::st_as_sf(e, coords = c("X", "Y"), crs = crs) | |
| major = pnt$Major | |
| minor = pnt$Minor | |
| angle = pnt$Angle1 | |
| rotation = function(a){ | |
| r = a * pi / 180 #degrees to radians | |
| matrix(c(cos(r), sin(r), -sin(r), cos(r)), nrow = 2, ncol = 2) | |
| } |
## e.g.
## sf::st_as_text(sf::st_as_sfc(sf::st_bbox(c(xmin = 0, xmax = 1, ymin = 0, ymax = 1))))
wkt_template <- "POLYGON (({xmin} {ymin}, {xmax} {ymin}, {xmax} {ymax}, {xmin} {ymax}, {xmin} {ymin}))"
xmin <- -80; xmax <- -78
ymin <- 34.5; ymax <- 36
## the filter, anything within this box will be included entirely
wkt <- glue::glue(wkt_template) f <- "ftp.nass.usda.gov/download/res/2019_30m_cdls.img"
library(raster)
#> Loading required package: sp
crop_io <- function(x, ext, resample = "nearest_neighbour") {
rx <- raster::raster(x)
if (inherits(ext, "bbox")) {
ext <- raster::extent(ext[c("xmin", "xmax", "ymin", "ymax")])
} else {
ext <- raster::extent(ext)| st_close <- function(x) { | |
| UseMethod('st_close') | |
| } | |
| st_close.sfg <- function(x) x | |
| st_close.POLYGON <- function(x) { | |
| if (st_is_empty(x)) return(x) | |
| x[] <- lapply(x[], close_mat) | |
| x[vapply(x[], nrow, integer(1)) > 3] | |
| } | |
| st_close.MULTIPOLYGON <- function(x) { |
| library(gganimate) # thomasp85/gganimate | |
| library(cartogram) | |
| library(geogrid) # Need github version jbaileyh/geogrid | |
| library(rnaturalearth) | |
| library(sf) | |
| library(scico) | |
| us <- ne_states('united states of america', returnclass = 'sf') | |
| us <- us[!us$woe_name %in% c('Alaska', 'Hawaii'), ] | |
| us <- st_transform(us, '+proj=eqdc +lat_0=39 +lon_0=-96 +lat_1=33 +lat_2=45 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs') |
| library(tidycensus) | |
| library(tmap) | |
| library(tmaptools) | |
| library(sf) | |
| library(tigris) | |
| library(magick) | |
| library(tidyverse) | |
| options(tigris_use_cache = TRUE) | |
| ctys <- c("Dallas", "Tarrant", "Collin County", "Denton", |
| # data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat | |
| # Originally seen at http://spatial.ly/2014/08/population-lines/ | |
| # So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess, | |
| # and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after | |
| # @hadleywickham pointed that out. Also, switched from geom_segment to geom_line. | |
| # The result of the code below can be seen at http://imgur.com/ob8c8ph | |
| library(tidyverse) |
| library(xtable) | |
| library(plyr) | |
| fakedata = data.frame( | |
| Bacteria = c("G. vaginalis", "L. crispatus"), | |
| Count = log10(rlnorm(2*100, 13.5)) | |
| ) | |
| table1 = ddply(fakedata, .(Bacteria), summarize, | |
| Bacteria = paste("\\textit{",unique(Bacteria),"}", sep=""), |