raster

Extracting values from inside polygons raster r

三世轮回 提交于 2019-12-13 04:17:28
问题 I'm trying to find the mean daily temperature for counties in South Dakota from raster grids ('bil' files) found at http://prism.oregonstate.edu/. I am getting county boundaries from the 'maps' package. library(maps) library(raster) sd_counties <- map('county','south dakota') sd_raster <- raster('file_path') How do I extract the grid cells within each county? I think I need to turn each county into it's own polygon to do this, but how? Then, I should be able to do something like the following

import multiple files R

≯℡__Kan透↙ 提交于 2019-12-13 03:43:55
问题 I hope you can help me. I have been trying to import multiple raster datasets into R, recode missing values for each raster data imported, link them to zipcodes and then export each raster data as a csv file with different names. I am trying to use a loop but so far I have only got errors. This is as far as I have gotten (dont laugh): import all 24 raster datasets file_names=as.list(dir(pattern="home.*")) listy<-lapply(file_names,raster, band=1) names(listy) <- paste0("hour", seq_along(0:23))

how to create vectorplot from velocity dataset?

♀尐吖头ヾ 提交于 2019-12-13 01:59:30
问题 Related to my previous question about calculate atan2 from two raster object in R?. It's possible to create a vector plot where the speed (slope) and direction (aspect) is displayed with a set of arrows (e.g. quiver in Matlab) based on this equation: for speed : ws <- sqrt(u^2+v^2) for direction : wd <- (180/pi)*(atan2(u,v)) my dataset sample can be downloaded here u <- raster(flname, varname = 'U') v <- raster(flname, varname = 'V') uv <- stack(u,v) I used rasterVis package to figure the

reconstruct image from array javascript

旧时模样 提交于 2019-12-13 01:43:09
问题 How do i reconstruct the image from an array of data in javascript. And display it on my page. the data is not hex or binary but a color value [0-255] black and white, so 8 bits image. Could some one give me show direction on how to rebuild the image from such raster data. I refer native javascript image object. here is a simple snippet of the data. IMAGE {"data":[[9,6,7,7,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,9,9,10,9,9,10,9,10,10,10,10,9,9,9,9,9,10,9,9,10,9,10,9,9,9,10,9,9,10,9

extract from {raster} package using excessive memory

江枫思渺然 提交于 2019-12-12 08:15:50
问题 I have been using the extract function from the raster package to extract data from raster files using an area defined by shapefiles. However, I am having problems with the amount of memory that this process is now requiring. I do have a large number of shapefiles (~1000). The raster files are large (~1.6gb) My process is: shp <- mclapply(list.files(pattern="*.shp",full.names=TRUE), readShapePoly,mc.cores=6) ndvi <- raster("NDVI.dat") mc<- function(y) { temp <- gUnionCascaded(y) extract <-

How to interpolate between rasters?

ε祈祈猫儿з 提交于 2019-12-12 07:16:56
问题 If have three rasters(as matrix): r1 <- raster(nrows=10, ncols=10); r1 <- setValues(r1, 1:ncell(r1)) r16 <- raster(nrows=10, ncols=10);r16 <- setValues(r16, 1:ncell(r16)) r30 <- raster(nrows=10, ncols=10);r30 <- setValues(r30, 1:ncell(r30)) I would like to linearly interpolate r1,c16,c30 to find the values in between i.e. r2,r3,r4,......r15 then r17,r18,r19,..........r29 . Is this possible using R? 回答1: Here is a way to do that library(raster) r <- raster(nrows=10, ncols=10); values(r) <- NA

R: how to create raster layer from an estUDm object

久未见 提交于 2019-12-12 04:52:57
问题 I've created Kernel home ranges from gps locations using the tool kernelUD from the package(adehabitatHR) using the code: 'udKerHref <- kernelUD(data[,1],h = "href", grid=100, kern = c("bivnorm"))' where data is a SpatialPointsDataFrame from 10 animals. I would now like to do two things: create a raster from the Kernel density values which I can multiply with another raster (Resource selection function raster) intersect other gps locations not used for building the home range with the raster

Creating Raster with values based on function output

守給你的承諾、 提交于 2019-12-12 04:37:21
问题 I have a function that calculates a price based on the input slope and distance. I want to write the price to a raster as the rastervalue. How do I do that? OpenSource and ArcMap solutions would work. slopeRaster = "slope.tif" emptyRaster = "emptyraster.tif" # How do I create an empty raster? road = "road.shp" for cell in emptyraster: # get slope from sloperaster at cell location ... slope = ... # get distance to nearest road from center of cell ... distance = ... # calculate price for cell

Calculating number of three consecutive values above a threshold (in raster stack)

老子叫甜甜 提交于 2019-12-12 04:34:14
问题 I need to compute number of three consecutive days when value of each pixel in a raster stack ( x ) is above a given threshold (defined by another raster y ). I tried using rle for the purpose with calc as follows after stacking x and y together into new raster a : library(raster) fn<-function(a) with(rle(a), sum(lengths>=3 & values>a[[nlayers(a)]])) calc(b,fn) However, I am getting the error: Error in .calcTest(x[1:5], fun, na.rm, forcefun, forceapply) : cannot use this function Reproducible

METRIC.EB Error in .local(x, …) : RasterLayer has no NA cells (for which to compute a distance)

假如想象 提交于 2019-12-12 03:53:30
问题 I am stuck on the Energy Balance calculation of the water package. The example code I am following is at this website https://cran.r-project.org/web/packages/water/vignettes/Landsat8.html. I am using my own data and am able to read both my original landsat image and the surface reflectance image with my area of interests (aoi). I get the following error when I use this code. Energy.Balance <- METRIC.EB(image.DN = image, image.SR = image.SR, plain=TRUE, aoi=aoi, n = 5, WeatherStation =