raster

R: Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double'— raster data

自作多情 提交于 2019-12-12 03:15:05
问题 Im working in Studio with a raster .tif image. I have watched a tutorial on plotting the raster with the code below, however it does not work for me. I get the error: Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double' I have loaded the necessary packages( raster and rgdal ) I have also tried loading the arulesViz , yet get the same error YIELD <- raster("//Users//DevinOsborne//Desktop//Thesis//QGIS projects //Project//Rasters//Images//Yield_wheat.tif") plot(YIELD,main=

Converting band interleaved by pixel binary files into raster grids

旧巷老猫 提交于 2019-12-12 02:48:08
问题 I have a BIP binary file https://drive.google.com/open?id=0BwkLXkUMkLd4SnBmUHNmMW5CcDg with the following information: ncol <- 193 nrow <- 94 xmin <- -180 xmax<- 180 ymin <- -88.542000 ymax <- 88.542000 The file has 365 bands, I want to be able to convert them into raster grids (raster stack). I can read the files in R, but I don't know how to deal with the bands. Here is what I have done so far: cnt <- ncol*nrow*365 data <- readBin(file,what= "double", n=cnt, size=4,endian=.Platform$endian)

How to create cohesive Spatial Pixels from Spatial Points Dataset

回眸只為那壹抹淺笑 提交于 2019-12-12 02:35:28
问题 I have a Spatial Point DF spo (covering an irregular shaped area of interest). The data are not on a regular grid due to crs transformation. My goal is a raster with predefined resolution and extent of the area of interest ( more spatial point data are to be mapped on this master raster) . Problems start when I rasterize(spo, raster(ncol, nrow, extent, crs), spo$param) I need to adjust nrow and ncol in a way so that I wont get moire patterns of NAs within my area of interest. I can't use a

How to add a text to a levelplot?

烈酒焚心 提交于 2019-12-12 01:28:54
问题 library(raster) library(rasterVis) r <- raster(nrows=10, ncols=10) r <- setValues(r, 1:ncell(r)) levelplot(r) I want to put a word (a text) that is "Original map" under the xlab "Longitude" Is this possible? 回答1: This is a manual solution, but you can use mtext to place text around margins with line and adj parameters to put it where you want (or text ). plot.new() # open new plot r <- raster(nrows=10, ncols=10) r <- setValues(r, 1:ncell(r)) levelplot(r) mtext("Original map", 1, line=-3.4,

R apply raster function to a list of characters

左心房为你撑大大i 提交于 2019-12-12 01:09:12
问题 I started recently to work with R so this question has probably a simple solution. I have some .tif satellite images from different scenes. I can create a test raster brick with it but the process needs to be automatised because of the huge amount of files. Therefore I have been trying to create a function to read the list of .tif files and to output a list of rasters. You can find here below the code I have been using: # Description: Prepare a raster brick with ordered acquisitions # from

Aggregate the values in a raster that lie within a given distance from a given point (i.e. a circle)

独自空忆成欢 提交于 2019-12-12 00:34:49
问题 I have a raster file nightlights that maps nighttime luminosity from satellite imagery (300MB compressed data available here). It takes longitude-latitude inputs for extraction, e.g. extract(nightlights, data.frame(long, lat) for long-lat inputs. Given point <- (long, lat) , I want to be able to aggregate all values that lie within, say, 5 miles of point and calculate an average luminosity, ignoring NAs. The raster package comes with an aggregate method that performs this function, but only

Put invisible message in four part of image by using Raster

故事扮演 提交于 2019-12-11 16:47:10
问题 I found a tutorial from this website Steganography (it also include the code), and i want to put the four message into four difference part of image as i drew below link Four parties of image, but i am not sure how to exactly to put message to four of section. This is one part of the code i modified by using raster below private byte[] get_byte_data(BufferedImage image) { WritableRaster raster = image.getRaster(); int imageHeight=image.getHeight()/2; System.out.println("ImageHeight: "

Change coordinates to a series of rasters with multiple layers in R

喜欢而已 提交于 2019-12-11 16:34:02
问题 I have a problem with a climate projections database organised in raster files. Each file contains information (about precipitation for instance) for one year, organised as follow: 365 layers of data for a grid of 0.5 degrees going from 0 to 360 lon and from 65 to -65 lat. Each layer is a grid with 720 columns and 260 rows. class : RasterStack dimensions : 260, 720, 187200, 365 (nrow, ncol, ncell, nlayers) resolution : 0.5, 0.5 (x, y) extent : -0.25, 359.75, -65.25, 64.75 (xmin, xmax, ymin,

How can I save a 3 column data frame into a NetCDF file in R?

一世执手 提交于 2019-12-11 16:15:54
问题 I have a Nx3 tibble I'd like to save to a NetCDF (.nc) file. The tibble has three columns: Longitude (lon) Latitude (lat) Data for each point (var) How can I save this to a NetCDF (.nc) file in R? So far I've been using the raster package with mixed results: # Be careful to call raster and dplyr in this specific order. require(raster) require(dplyr) set.seed(10) df <- expand.grid(lon = 1:10, lat=1:10) %>% as_tibble() %>% mutate(var1 = rnorm(100)) val <- df %>% select(var1) %>% pull()

calculate atan2 from two raster object in R?

自闭症网瘾萝莉.ら 提交于 2019-12-11 14:02:02
问题 I have to raster object (u and v) download here . I want to calculate the direction of the velocity based on this equation below u <- brick('D:/uv.nc', varname = 'U') v <- brick('D:/uv.nc', varname = 'V') ws <- sqrt(u^2+v^2) wd <- (180/pi)*(atan2(u,v)) Unfortunately, I get an error message below: Error in atan2(y, x) : Non-numeric argument to mathematical function Then, I refer to atan2 {raster} and create a simple raster object below and work fine.. r1 <- r2 <- raster(nrow=10, ncol=10) r1[]