raster

How to set up step color regions?

牧云@^-^@ 提交于 2020-01-06 04:28:23
问题 With levelplot / spplot we can use at to define the color region range (min, max, interval). My question is: how can I use red for values greater than 29.5? This is my sample NCDF file --> download here library (raster) r <- brick('bali.nc', varname='TEMPERATURE', level=1) library(rasterVis) jet <- colorRampPalette( c('#00007F', 'blue', '#007FFF', 'cyan', 'yellow', '#FF7F00', 'red', '#7F0000') ) # First Figure - without at levelplot(r, layer=1, margin=F, contour=F, col.regions=jet) # Second

How to set up step color regions?

孤街浪徒 提交于 2020-01-06 04:28:10
问题 With levelplot / spplot we can use at to define the color region range (min, max, interval). My question is: how can I use red for values greater than 29.5? This is my sample NCDF file --> download here library (raster) r <- brick('bali.nc', varname='TEMPERATURE', level=1) library(rasterVis) jet <- colorRampPalette( c('#00007F', 'blue', '#007FFF', 'cyan', 'yellow', '#FF7F00', 'red', '#7F0000') ) # First Figure - without at levelplot(r, layer=1, margin=F, contour=F, col.regions=jet) # Second

Conditionally calculating the difference between max(raster) and each raster layer of raster stack

送分小仙女□ 提交于 2020-01-05 04:35:14
问题 I have a list of raster stacks named r.lst . I need to calculate the difference between max(r.lst[[i]]) (stacked rasters) and every raster layer of that raster stack. However, I want to do this conditionally for each pixel by considering which.max(r.lst[[i]]) . So that each cell in deducted from its previous max not the next. Please see below example: # example data------------------------------------------- set.seed(123) #our list of rasters r.lst <- as.list(1:3) # setting up list pf raster

plotting spatial points over a raster layer in r

前提是你 提交于 2020-01-04 02:39:08
问题 I wish to plot a matrix (temp_matrix) after converting it to a raster object (tempMap). Further, I wish to add few points whose latitude and longitude locations are available to me on the same plot window. I have tried few approaches but none seems to work since the points available are specific locations in lat/long while the raster object I am getting has a different extent. Please help me with this issue. Given below is the sample data for the problem. library(raster) temp_matrix<-array(NA

Coerce raster time series (rts) object back to raster* object

偶尔善良 提交于 2020-01-03 19:44:13
问题 Should seem straight forward but have failed to find a way. How does one coerce a rts raster time series back to a raster (stack)? The following example from the rts package. library(raster) library(rts) path <- system.file("external", package="rts") lst <- list.files(path=path,pattern='.asc$',full.names=TRUE) r <- stack(lst) d <- c("2000-02-01","2000-03-01","2000-04-01","2000-05-01") # corresponding dates to 4 rasters d <- as.Date(d) # creating a RasterStackTS object: rt <- rts(r,d) 回答1: In

Coerce raster time series (rts) object back to raster* object

怎甘沉沦 提交于 2020-01-03 19:43:19
问题 Should seem straight forward but have failed to find a way. How does one coerce a rts raster time series back to a raster (stack)? The following example from the rts package. library(raster) library(rts) path <- system.file("external", package="rts") lst <- list.files(path=path,pattern='.asc$',full.names=TRUE) r <- stack(lst) d <- c("2000-02-01","2000-03-01","2000-04-01","2000-05-01") # corresponding dates to 4 rasters d <- as.Date(d) # creating a RasterStackTS object: rt <- rts(r,d) 回答1: In

Running raster::stackApply() function in parallel

旧时模样 提交于 2020-01-03 04:45:14
问题 I'm trying to parallelize this example. I have a bunch of rasters that I am trying to aggregate by week of the year. Here is what this looks like in series: # create a raster stack from list of GeoTiffs tifs <- list.files(path = "./inputData/", pattern = "\\.tif$", full.names = TRUE) r <- stack(tifs) # get the date from the names of the layers and extract the week indices <- format(as.Date(names(r), format = "X%Y.%m.%d"), format = "%U") indices <- as.numeric(indices) # calculate weekly means

MATLAB: Plot raster map with custom colormap

旧城冷巷雨未停 提交于 2020-01-02 06:53:10
问题 In MATLAB, I have a matrix map_data associated with referencing object R (both in this MAT-file). I want to map it with a discrete colorbar given an irregular range of values to look something like this: I would like to use geoshow() or something similar that allows me to reproject at will and to overlay shapefiles on top of the raster. But really anything that gets me on the right track would be much appreciated. I'm using MATLAB r2014b. Here is the relevant information for the colormap: R G

How to make bmp image from pixel byte array in java

懵懂的女人 提交于 2020-01-02 06:11:50
问题 I have a byte array containing pixel values from a .bmp file. It was generated by doing this: BufferedImage readImage = ImageIO.read(new File(fileName)); byte imageData[] = ((DataBufferByte)readImage.getData().getDataBuffer()).getData(); Now I need to recreate the .bmp image. I tried to make a BufferedImage and set the pixels of the WritableRaster by calling the setPixels method. But there I have to provide an int[], float[] or double[] array. Maybe I need to convert the byte array into one

How to make bmp image from pixel byte array in java

﹥>﹥吖頭↗ 提交于 2020-01-02 06:09:52
问题 I have a byte array containing pixel values from a .bmp file. It was generated by doing this: BufferedImage readImage = ImageIO.read(new File(fileName)); byte imageData[] = ((DataBufferByte)readImage.getData().getDataBuffer()).getData(); Now I need to recreate the .bmp image. I tried to make a BufferedImage and set the pixels of the WritableRaster by calling the setPixels method. But there I have to provide an int[], float[] or double[] array. Maybe I need to convert the byte array into one