library(aqp)
library(soilDB)
f <- fetchNASIS()
#> NOTE: some records are missing surface fragment cover
#> mixing dry colors ... [1 of 43 horizons]
#> mixing moist colors ... [1 of 43 horizons]
#> NOTE: some records are missing rock fragment volume
#> NOTE: all records are missing artifact volume
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
c("abcd123", "abcd124", "abcd133", "acbd123", "dbac312", "dcba321") |> | |
(\(x) { | |
strsplit(x, "") |> | |
lapply(\(x) sapply(x, charToRaw)) |> | |
sapply(\(x) c(0, diff(as.integer(x)) == 1)) |> | |
colSums() | |
})() | |
#> [1] 5 4 3 2 1 0 |
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
# torus | |
ratio <- sort(c((seq(1, 10, 0.101)) / 10))#$, (seq(1, 10, 2)))) | |
plt <- function(i){ | |
d <- expand.grid(data.frame( | |
R = 1, | |
r = 1 * i, | |
theta = seq(0, 2 * pi, 0.25), | |
phi = seq(0, 2 * pi, 0.25) |
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
#' Convert hydrologic unit IDs to boundaries at the specified level. | |
#' | |
#' Hydrologic unit boundaries are retrieved from the USGS NationalMap ArcGIS MapServer web services: `"https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/"`. | |
#' | |
#' @param x character. Hydrologic Unit IDs | |
#' @param layerid numeric. `1:8` where `2*layerid` is equal to the number of digits in the Hydrologic Unit Code (HUC). Default: `5` for "HUC-10" watershed. See details. | |
#' @param base_url Default: `"https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/"` | |
#' @details | |
#' The levels of `layerid` correspond to the numeric codes for the following hydrologic units (HU): | |
#' - WBDLine (0) |
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
--- | |
title: "rpostgis" | |
output: html_document | |
date: "2023-03-18" | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` |
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
#' Convert X,Y coordinates to hydrologic unit boundaries at the specified level. | |
#' | |
#' Hydrologic unit boundaries are retrieved from the USGS NationalMap ArcGIS MapServer web services: `"https://hydro.nationalmap.gov/arcgis/rest/services/wbd/MapServer/"`. | |
#' | |
#' @param x A `SpatVector` object or `numeric` vector. | |
#' @param y `NULL` (when x is a spatial object); otherwise a `numeric` vector equal in length to `x` | |
#' @param layerid numeric. `1:8` where `2*layerid` is equal to the number of digits in the Hydrologic Unit Code (HUC). Default: `5` for "HUC-10" watershed. See details. | |
#' @param sr_in integer. Spatial Reference System of input (`x`, `y`) as specified with numeric code. Default: `4326` for `"EPSG:4326"`. | |
#' @param sr_out integer. Spatial Reference System of result as specified with numeric code. Default: `sr_in`; equivalent to input. |
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(terra) | |
gdal(lib = "") | |
data(us_states, package = "spData") | |
x <- vect(us_states)[1,] | |
y <- project(x, "EPSG:5070") | |
writeVector(x, "test.gpkg") | |
writeVector(y, "test.gpkg", layer = "test2", insert = TRUE) |
#' Generate Requests for SSURGO Portal Data Loader
#'
#' Generate commands for or JSON output from the SSURGO Portal Data Loader command-line interface.
#'
#' @param request One of the available request types, see Details.
#' @param pyz_path Path to "SSURGO Portal" .pyz file. Default `"SSURGOPortal.pyz"`
#' @param ... Additional parameters for `request`
#' @param schema Return request and response schemas? Default: `FALSE`
#' @param command_only Return command string rather than executing it? Default: `FALSE`
library(soilDB)
library(terra)
#> terra 1.6.40
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
data(us_states, package = "spData")
# query soil data access for dominant condition (by mapunit) parent material information for NY
NewerOlder