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 packages | |
library(prioritizr) | |
library(prioritizrdata) | |
library(terra) | |
library(microbenchmark) | |
# import planning unit data | |
wa_pu <- get_wa_pu() | |
# preview data |
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 packages | |
library(prioritizr) | |
library(prioritizrdata) | |
library(terra) | |
# import planning unit data | |
wa_pu <- get_wa_pu() | |
# preview data | |
print(wa_pu) |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 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
countryname code biogeoregion | |
Albania Alpine Alpine Bio-geographical Region | |
Albania Mediterranean Mediterranean Bio-geographical Region | |
Andorra Alpine Alpine Bio-geographical Region | |
Andorra Mediterranean Mediterranean Bio-geographical Region | |
Austria Alpine Alpine Bio-geographical Region | |
Austria Continental Continental Bio-geographical Region | |
Austria Pannonian Pannonian Bio-geographical Region | |
Belgium Continental Continental Bio-geographical Region | |
Belgium Atlantic Atlantic Bio-geographical Region |
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
################# other format ################## | |
#' @param x [`Raster-class`], | |
#' [sf::st_sf()], | |
#' [`SpatialPolygonsDataFrame-class`], | |
#' [`SpatialLinesDataFrame-class`], | |
#' [`SpatialPointsDataFrame-class`], | |
#' [data.frame()] object, | |
#' [numeric()] vector, or | |
#' [matrix()] specifying the planning units to use in the reserve | |
#' design exercise and their corresponding cost. It may be desirable to |
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
#### 1. Sign up at GitHub.com ################################################ | |
## If you do not have a GitHub account, sign up here: | |
## https://github.com/join | |
# ---------------------------------------------------------------------------- | |
#### 2. Install git ########################################################## | |
## If you do not have git installed, please do so: |
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
import os | |
import subprocess | |
import rasterio | |
def extract_bands(file, bands=None): | |
dataset = rasterio.open(file) | |
if bands is None: | |
bands = range(1, dataset.count + 1) | |
elif isinstance(bands, int): |
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
as.data.table.raster <- function(x, row.names = NULL, optional = FALSE, | |
xy = FALSE, inmem = canProcessInMemory(x, 2), | |
...) { | |
stopifnot(require("data.table")) | |
if(inmem) { | |
v <- as.data.table(raster::as.data.frame(x, row.names=row.names, | |
optional=optional, xy=xy, ...)) | |
coln <- names(x) | |
if(xy) coln <- c("x", "y", coln) |
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: "R Notebook" | |
output: html_document | |
--- | |
```{r echo=FALSE, warning=FALSE, message=FALSE} | |
library(tidyverse) | |
library(leaflet) | |
library(mapview) | |
library(sf) |
We can make this file beautiful and searchable if this error is corrected: It looks like row 9 should actually have 9 columns, instead of 3 in line 8.
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
SS,SSB,SSBS,Sample_start_earliest,Sample_end_latest,Max_linear_extent,Landcover_sampling,Landcover_postsampling,Years_before_change | |
AD1_2001__Liow 1,AD1_2001__Liow 1 ,AD1_2001__Liow 1 5,1999-03-01,1999-07-03,2e3,Forest,Urban,13 | |
AD1_2001__Liow 2,AD1_2001__Liow 2 ,AD1_2001__Liow 2 5,1999-03-01,1999-07-03,2e3,Forest,Urban,13 | |
AD1_2006__Blanche 2,AD1_2006__Blanche 2 ,AD1_2006__Blanche 2 3,2005-01-01,2005-12-31,222.80710269545455,Forest,Agriculture,3 | |
AD1_2006__Blanche 2,AD1_2006__Blanche 2 ,AD1_2006__Blanche 2 5,2005-01-01,2005-12-31,222.80710269545455,Shrubland,Forest,3 | |
AD1_2006__Marshall 1,AD1_2006__Marshall 1 B,AD1_2006__Marshall 1 B 23,2003-06-04,2003-07-08,97.46794345,SparseVegetation,Grassland,4 | |
AD1_2006__Marshall 1,AD1_2006__Marshall 1 E,AD1_2006__Marshall 1 E 26,2003-06-04,2003-07-08,154.11035005,SparseVegetation,Grassland,4 | |
AD1_2006__Marshall 1,AD1_2006__Marshall 1 E,AD1_2006__Marshall 1 E 5,2003-06-04,2003-07-08,145.77379735,Agriculture,Grassland,4 | |
AD1_2006__Marshall 1,AD1_2006__Marshall 1 L,AD1_2006_ |
NewerOlder