View gist:5f1b0faa3e93073784e01d5a4bb60eca
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) 2019, Edzer Pebesma, CC-BY-SA | |
set.seed(1331) | |
library(stars) | |
library(colorspace) | |
tif = system.file("tif/L7_ETMs.tif", package = "stars") | |
r = read_stars(tif) | |
nrow = 5 | |
ncol = 8 | |
#m = matrix(runif(nrow * ncol), nrow = nrow, ncol = ncol) |
View gist:9c5c24434ffcaf42917796a98c4dd9a6
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
see https://github.com/r-spatial/sf/blob/master/demo/twitter.R |
View gist:442d74a5775abcd5068cf3e73b23687b
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
https://twitter.com/allison_horst/status/1071456081308614656 |
View gist:c91541972ccd862b543467e8f59c26c3
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
# from: https://github.com/Irosenthal/Floating_Forests/blob/master/scripts/demo_of_merge/demo_merge.R | |
# see https://twitter.com/jebyrnes/status/963279659868749825 | |
# alt: indicates a stars+sf workflow alternative to sp+raster | |
########### | |
# Libraries | |
########### | |
library(sp) | |
library(rgdal) | |
library(rgeos) |
View sf-hexagon-with-sf.R
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
require("sf") | |
require("dplyr") | |
require("hexbin") | |
# Linux libertine font "sf", converted to path with Inkscape, | |
# added points between existing points 2 times, then turned all segments into straight lines. | |
# Saved as SVG with absolute coordinates (Preferences > SVG Output > Path Data). | |
# Loaded coords from SVG source code, remove letters from start and end, and replace " " with "," | |
coords_f <- c(218.1169,163.46992,215.56952,177.96334,213.51976,189.84421,211.82546,200.33884,210.34442,210.67351,208.24728,226.35176,205.51032,243.54066,201.92029,259.27223,197.26391,270.57846,195.45112,272.90665,193.28288,274.70167,190.97247,275.85687,188.73314,276.26564,187.03291,276.03164,185.79476,275.38887,184.84097,274.42619,183.99382,273.23248,182.45947,271.13533,180.24976,269.10927,177.54243,267.58084,174.51519,266.97658,171.25987,267.58973,169.08867,269.18036,167.87718,271.37526,167.501,273.8012,168.44294,277.0032,171.48203,279.79643,176.93817,281.77214,185.13126,282.52154,191.01986,281.80176,196.83737,279.60686,202.29944, |
View gist:4c45ae3d4438801ab95ae00bc3e42431
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(openeo) # make the openEO api functions available to the user | |
eo = openeo_connect("http://.../api/v0", user = "edzer", passwd = "****") # auth | |
# R6 object with reference semantics / encapsulated OOP | |
eo$datasets() # list/describe data sets available: | |
# Sentinel2A-L1C | |
# Proba-V | |
# ... |
View gist:381dac079ddcd5174be31209675b3822
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(stars) | |
library(sf) | |
geomatrix = system.file("tif/geomatrix.tif", package = "stars") | |
x = st_stars(geomatrix) | |
st_dimensions(x) | |
## from to offset delta geotransform | |
## x 1 20 1841002 1.5 1841000, 1.5, -5, 1144000, -5, -1.5 | |
## y 1 20 1144003 -1.5 1841000, 1.5, -5, 1144000, -5, -1.5 | |
## refsys point values | |
## x +proj=utm +zone=11 +datum=WGS84 +units=m +no_defs TRUE NULL |
View gist:29d10b133bba2df9f768e427bc50b098
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
> system.time(for(i in 1:100000){a <- st_as_sfc("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))")}) | |
user system elapsed | |
11.228 0.000 11.231 | |
> system.time(for(i in 1:100000){a <- wkt_coords("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))")}) | |
user system elapsed | |
33.340 0.000 33.349 |
View cast0.R
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
st_cast0 <- function(x, to, ...) UseMethod("st_cast0") | |
# see this figure: | |
# https://cloud.githubusercontent.com/assets/520851/21387553/5f1edcaa-c778-11e6-92d0-2d735e4c8e40.png | |
# columns start counting at 0: | |
which_col = function(cls) { | |
switch(cls, | |
POINT = 0, | |
LINESTRING = 1, |