Skip to content

Instantly share code, notes, and snippets.

@cybernar
cybernar / S2_reflectance.R
Created January 21, 2019 18:29
Process Sentinel2 reflectance data from Theia
## CALCUL NDVI avec masque nuages
## Image couleur naturel Sentinel2
library(raster)
library(rgdal)
library(stringr)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cybernar
cybernar / ncdf_extract_values.R
Last active November 23, 2016 12:10
Extract values at XY position from NetCDF file
library(raster)
library(ncdf4)
library(maptools)
# netcdf file from ftp://aspen.atmos.albany.edu/pdsi/cmip5/scPDSIpm/pdsisc.monthly.maps.1900-2099.r2.5x2.5.EnsAvg14Models.TP2.ipe=2.nc
# shp file from http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/cultural/ne_50m_airports.zip
# load netcdf file as a raster brick
f <- "D:/bacasable/pdsisc.monthly.maps.1900-2099.r2.5x2.5.EnsAvg14Models.TP2.ipe=2.nc"
rbr <- brick(f, varname="pdsisc")
CREATE TABLE carto.parcelles
(
num_fiche serial NOT NULL,
date_debut date,
date_fin date,
surface numeric(10, 2),
personnes text,
code_dept character(10),
laboratoire text,
# snippets R raster
library(raster)
# creer raster vide type entier 60 x 80 km, res 500 m
rvide.crs <- CRS("+init=EPSG:2154")
rvide.ext <- extent(c(688500,748500,6292500,6372500))
rvide.val <- rep(0, 120*160)
rvide <- raster(crs=rvide.crs, ext=rvide.ext, resolution=500, vals=rvide.val)
writeRaster(rvide, filename="D:/GIS_DATA/HomeRange/RSpatial/reference_grid2.asc", format="ascii", datatype='INT2S', NAflag=-9999)