# Positive Slope Scenario
x <- wk::wkt(
c(
"LINESTRING(0.0 0.0, 2.0 2.0)", # target line
"LINESTRING(0.5 0.75, 2.5 2.75)", # one we've deemed parallel
# desribes the overlap range (2D)
"POLYGON((0.5 0.75, 2.0 0.75, 2.0 2.0, 0.5 2.0, 0.5 0.75))"
)
)
This file contains hidden or 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
# https://fosstodon.org/@coolbutuseless/111029564256521659 | |
x <- letters | |
x <- structure(letters, class = "zero_indexed") | |
`[.zero_indexed` <- function(obj, i, ...) { | |
if (is.numeric(i)) { | |
i <- i + 1 | |
NextMethod() |
This file contains hidden or 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(sf) | |
#' Plots vertices where Hausdorff distance is calculated from | |
#' | |
#' @param x any single geometry | |
#' @param y any single geometry | |
#' @returns two points as an `sfc` object that are the locations where Hausdorff distance | |
#' is calculated from | |
plot_hd_points <- function(x, y) { | |
This file contains hidden or 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(arcgislayers) | |
# this can use the authorization from Pro | |
token <- auth_binding() | |
set_auth_token(token) | |
# read in a shapefile from sf | |
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf")) | |
# transform to 3857 |
This file contains hidden or 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(sfdep) | |
library(sfnetworks) | |
nb <- st_contiguity(guerry) | |
wt <- st_weights(nb) | |
listw <- recreate_listw(nb, wt) | |
mstree <- spdep::mstree(listw, 1) | |
edges <- data.frame( |
This file contains hidden or 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(arcgis) | |
img_url <- "https://landsat2.arcgis.com/arcgis/rest/services/Landsat/MS/ImageServer" | |
# create an ImageServer object | |
landsat <- arc_open(img_url, token = "") | |
# get attributes | |
y <- arc_select( | |
x, |
This file contains hidden or 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(sf, quietly = TRUE) | |
library(spdep, quietly = TRUE) | |
nc <- read_sf(system.file("shape/nc.shp", package = "sf")) | |
# define neighbors | |
nb <- poly2nb(nc) | |
# choose variable | |
x <- nc$SID74 |
This file contains hidden or 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(sf) | |
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE | |
library(arcgis) | |
#> Attaching core arcgis packages: | |
#> - {arcgisutils} v0.1.0 | |
#> - {arcgislayers} v0.1.0 | |
# store the URL | |
furl <- "https://utility.arcgis.com/usrsvcs/servers/6d515686b57f4f4b948502cc88a90347/rest/services/Planning/i15_Crop_Mapping_2021_Provisional/MapServer/0" |
This file contains hidden or 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
new_post <- function(author, title, tags, published_date) { | |
structure( | |
list( | |
author = author, | |
title = title, | |
tags = tags, | |
published_date = published_date | |
), | |
class = "post" | |
) |
This file contains hidden or 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(sf) | |
library(sfheaders) | |
# define polygon coords | |
m <- matrix( | |
c(2, -2, 2, 2, -2, 2, -2, -2, 2, -2), | |
ncol = 2, byrow = TRUE | |
) | |
# create polygon from matrix |