raster

Fastest way to mask raster using points

六眼飞鱼酱① 提交于 2020-05-16 22:02:02
问题 I have a very large rasterbrick and some coordinates held in a different object. I wish to use the points as a mask, returning NA for all cells except where my points are located (for my particular application I need to preserve the extent, resolution and origin of the input rasterbrick ). I can accomplish this with the following: library(raster) library(tidyverse) library(sf) # Load a rasterbrick b <- brick(system.file("external/rlogo.grd", package="raster")) # Create some random points as

Fastest way to mask raster using points

♀尐吖头ヾ 提交于 2020-05-16 22:01:15
问题 I have a very large rasterbrick and some coordinates held in a different object. I wish to use the points as a mask, returning NA for all cells except where my points are located (for my particular application I need to preserve the extent, resolution and origin of the input rasterbrick ). I can accomplish this with the following: library(raster) library(tidyverse) library(sf) # Load a rasterbrick b <- brick(system.file("external/rlogo.grd", package="raster")) # Create some random points as

Fastest way to mask raster using points

落爺英雄遲暮 提交于 2020-05-16 22:01:08
问题 I have a very large rasterbrick and some coordinates held in a different object. I wish to use the points as a mask, returning NA for all cells except where my points are located (for my particular application I need to preserve the extent, resolution and origin of the input rasterbrick ). I can accomplish this with the following: library(raster) library(tidyverse) library(sf) # Load a rasterbrick b <- brick(system.file("external/rlogo.grd", package="raster")) # Create some random points as

Extracting values for specific lat long from netcdf

穿精又带淫゛_ 提交于 2020-05-14 09:02:19
问题 I'm trying to read into R a netCDF file. The netcdf chirps-v2.0.1981.days_p05.nc is downloaded from here: ftp://ftp.chg.ucsb.edu/pub/org/chg/products/CHIRPS-2.0/global_daily/netcdf/p05/ This netCDF file describes daily rainfall globally as a function of longitude, latitude and has size of 1.1 GB I also have a set of lon lat dat <- structure(list(locatioID = paste0('ID', 1:16), lon = c(73.73, 86, 73.45, 86.41, 85.36, 81.95, 82.57, 75.66, 82.03, 81.73, 85.66, 85.31, 81.03, 81.70, 87.03, 73.38),

R: over-write xy coordinates of raster layer

人走茶凉 提交于 2020-05-09 04:44:29
问题 I have a raster with XY pixel coordinates which I want to convert to lat and long. class : RasterLayer dimensions : 1617, 1596, 2580732 (nrow, ncol, ncell) resolution : 1, 1 (x, y) extent : 0, 1596, 0, 1617 (xmin, xmax, ymin, ymax) coord. ref. : NA data source : C:\janW1.png names : janW1 values : 0, 255 (min, max) I have calculated the lat/long coords using the formula specified here. This has resulted in the following dataframe heads(cords) lat lon x y janW1 1 46.99401 -14.99122 0.5 1616.5

Extract raster values (from Stack) to points in for loop

浪子不回头ぞ 提交于 2020-04-30 07:49:22
问题 I have a raster stack and 100 points. For each raster I want to extract the value and do so using three different scales/buffers. First, here are three rasters combined into a stack library(raster) # Make rasters and combine into stack set.seed(123) r1 = raster(ncol=1000, nrow=1000, xmn=0, xmx=1000, ymn=0, ymx=1000) values(r1) = round(runif(ncell(r1),1,100)) r2 = raster(ncol=1000, nrow=1000, xmn=0, xmx=1000, ymn=0, ymx=1000) values(r2) = round(seq(1:ncell(r1))) r3 = raster(ncol=1000, nrow

Extract raster values (from Stack) to points in for loop

我的未来我决定 提交于 2020-04-30 07:48:16
问题 I have a raster stack and 100 points. For each raster I want to extract the value and do so using three different scales/buffers. First, here are three rasters combined into a stack library(raster) # Make rasters and combine into stack set.seed(123) r1 = raster(ncol=1000, nrow=1000, xmn=0, xmx=1000, ymn=0, ymx=1000) values(r1) = round(runif(ncell(r1),1,100)) r2 = raster(ncol=1000, nrow=1000, xmn=0, xmx=1000, ymn=0, ymx=1000) values(r2) = round(seq(1:ncell(r1))) r3 = raster(ncol=1000, nrow

How to build Internal Overviews with Python gdal BuildOverviews()?

混江龙づ霸主 提交于 2020-04-18 00:50:43
问题 Trying to mimic the result of running gdaladdo -r average "D:\image.tif" using python gdal bindings. When I run the code below, I get an external .ovr file. How can I generate an internal overview? Am I using the correct function to mimic gdaladdo? from osgeo import gdal InputImage = r"D:\image.tif" Image = gdal.Open(InputImage,1) Image.BuildOverviews("AVERAGE", [2,4,8,16,32,64]) I've also tried Image = gdal.Open(InputImage, gdal.GA_Update) 回答1: This worked for me: Image = gdal.Open('example

How to build Internal Overviews with Python gdal BuildOverviews()?

坚强是说给别人听的谎言 提交于 2020-04-18 00:50:25
问题 Trying to mimic the result of running gdaladdo -r average "D:\image.tif" using python gdal bindings. When I run the code below, I get an external .ovr file. How can I generate an internal overview? Am I using the correct function to mimic gdaladdo? from osgeo import gdal InputImage = r"D:\image.tif" Image = gdal.Open(InputImage,1) Image.BuildOverviews("AVERAGE", [2,4,8,16,32,64]) I've also tried Image = gdal.Open(InputImage, gdal.GA_Update) 回答1: This worked for me: Image = gdal.Open('example

Keeping raster variable names when converting to NetCDF using R

假装没事ソ 提交于 2020-03-18 15:24:19
问题 Taking a raster file of monthly temperature data for multiple years which has a name attached accessible via names(object) in the following format 'Jan.1981', 'Feb.1981' etc (example files for two years that works with code below here - adding all files makes it too big. Reading in and writing this to NetCDF using the following code: #Load Packages library(raster) library(ncdf4) #Read in temperature files r1 <- brick('TavgM_1981.grd') r2 <- brick('TavgM_1982.grd') #stack them together