# Load necessary libraries
library(sf)
#> Linking to GEOS 3.13.1, GDAL 3.10.2, PROJ 9.5.1; sf_use_s2() is TRUE
library(tmap)
library(tmaptools)
url <- "https://gisco-services.ec.europa.eu/distribution/v2/nuts/shp/NUTS_RG_20M_2024_3035.shp.zip"
EU_eflsk_2 <- sf::read_sf(
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
| # DuckDB Vector Tiles with mapgl Example | |
| # This script demonstrates how to serve vector tiles from DuckDB using ST_AsMVT() | |
| # and display them in a mapgl map using httpuv | |
| library(mapgl) | |
| library(duckdb) # Requires the latest DuckDB version (>= 1.4.0) | |
| library(httpuv) | |
| library(sf) | |
| library(duckspatial) | |
| library(tigris) |
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
| { | |
| // this is the settings.json file | |
| // file behaviour | |
| "files.hotExit": "onExitAndWindowClose", | |
| "files.defaultLanguage": "r", | |
| "files.insertFinalNewline": true, | |
| "files.trimFinalNewlines": true, | |
| "files.trimTrailingWhitespace": true, | |
| "files.associations": { |
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
| # Load necessary libraries | |
| library(sf) | |
| library(tmap) | |
| library(tmaptools) | |
| url <- "https://gisco-services.ec.europa.eu/distribution/v2/nuts/shp/NUTS_RG_20M_2024_3035.shp.zip" | |
| EU_eflsk_2 <- sf::read_sf( | |
| paste0("/vsizip/","/vsicurl/", url) | |
| ) |> |
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
| #!/bin/sh | |
| # https://gist.github.com/christiangalsterer/5f55389b9c50c74c31b9 | |
| # Copyright 2015 Christian Galsterer | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # |
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
| #### --------------------------------------------- | |
| ## Edit via: RStudio > Tools > Edit Code Snippets | |
| # Released under a MIT license | |
| snippet fragment | |
| [${1:text}]{.${2:type}} | |
| snippet aside | |
| [${1:text}]{.aside} | |
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
| COUNTYFIPS | NAME | STATEPLANEFIPS | EPSG | |
|---|---|---|---|---|
| 16079 | Shoshone County | 1103 | 26970 | |
| 16073 | Owyhee County | 1103 | 26970 | |
| 16071 | Oneida County | 1101 | 26968 | |
| 16077 | Power County | 1101 | 26968 | |
| 16075 | Payette County | 1103 | 26970 | |
| 06115 | Yuba County | 0402 | 26942 | |
| 06111 | Ventura County | 0405 | 26945 | |
| 06113 | Yolo County | 0402 | 26942 | |
| 31177 | Washington County | 2600 | 32104 |
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
| 16079 | Shoshone County | 1103 | 26970 | |
|---|---|---|---|---|
| 16073 | Owyhee County | 1103 | 26970 | |
| 16071 | Oneida County | 1101 | 26968 | |
| 16077 | Power County | 1101 | 26968 | |
| 16075 | Payette County | 1103 | 26970 | |
| 06115 | Yuba County | 0402 | 26942 | |
| 06111 | Ventura County | 0405 | 26945 | |
| 06113 | Yolo County | 0402 | 26942 | |
| 31177 | Washington County | 2600 | 32104 |
## function to split "label: text" into data.frame(label = text)
v1 <- function(x) {
x <- gsub(": ", ":", x) ## first clear that whitespace
dd <- read.delim(text = x, sep = ":", header = FALSE);
setNames(data.frame(dd[[2]]), dd[[1]][1])
}
library(sf)
sf::sf_use_s2(FALSE)
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
| #' @title split lines | |
| #' @description Splits lines longer than a given threshold into the minimum number of pieces to all be under the given threshold. | |
| #' @param lines data.frame of class sf with LINESTRING sfc column. | |
| #' @param max_length maximum segment length to return | |
| #' @param id name of ID column in data.frame | |
| #' @return only the split lines. | |
| #' @importFrom dplyr group_by ungroup filter left_join select rename mutate | |
| #' @export | |
| #' | |
| split_lines <- function(input_lines, max_length, id = "ID") { |
NewerOlder