raster

Error in ncol(xj) : object 'xj' not found using rowSums

╄→尐↘猪︶ㄣ 提交于 2019-12-13 22:17:29
问题 I'm using R and rowSums function for a data frame as discussed in this post: Sum over spatialGridDataFrame: rowSums or colSums. Now suing rowSums as follows: FLintMod[[2+nsim]] <- rowSums(FLintMod@data[, 2:(1+nsim)], na.rm=TRUE) Now I'm facing new error and I really don't have any idea why I'm getting this error: Error in ncol(xj) : object 'xj' not found Could you please help me understand this problem and solve it. For your information, this code worked before but after improving code and

Create a Scatterplot of Raster Images in R

ぐ巨炮叔叔 提交于 2019-12-13 22:10:06
问题 I am not entirely sure if these kind of questions are allowed at SO, as I have no reproducible data at the moment. My question is in regards to how one might go about creating a scatterplot of raster images in R. I am not familiar with any packages that allow you to do this. This is the only example I have come across so far in my search. Essentially, this is what I would like to do, however, I am wondering if it's possible for R to simply take the input data and plot the image rather than be

Converting HDF to georeferenced file (geotiff, shapefile)

醉酒当歌 提交于 2019-12-13 20:24:13
问题 I am dealing with 28 HDF4 files on ocean primary productivity (annual .tar files can be found here: http://orca.science.oregonstate.edu/1080.by.2160.monthly.hdf.cbpm2.v.php) My goal is to do some calculations (I need to calculate concentrations per area and obtain the mean over several years, i.e. combine all files spatially) and then convert them to a georeferenced file I can work with in ArcGIS (preferably shapefile, or geotiff). I have tried several ways to convert to ASCII or raster files

Pixel image in R from character array

二次信任 提交于 2019-12-13 20:15:22
问题 I have generated a pixel-based image by encoding each input character to a certain color in the image. For example, in input txt <- "ABACDAAFFEDDADFAFAED" i plotted 'A' as a red pixel, 'B' as purple, 'C' by blue and 'D' by some other color. I used R for it. Here is the answer from where I have taken help for this Generate pixel based image in R from character array Now, I want to update this for handling a case as well where I have a character presents 2 or three times consecutively and I

Mapping slope of an area and returning percent above and below a threshold in R

拟墨画扇 提交于 2019-12-13 20:10:40
问题 I am trying to figure our the proportion of an area that has a slope of 0, +/- 5 degrees. Another way of saying it is anything above 5 degrees and below 5 degrees are bad. I am trying to find the actual number, and a graphic. To achieve this I turned to R and using the Raster package. Let's use a generic country, in this case, the Philippines {list.of.packages <- c("sp","raster","rasterVis","maptools","rgeos") new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,

Crop raster with polygon in R: Error extent does not overlap

谁说我不能喝 提交于 2019-12-13 15:26:58
问题 I want to crop a raster stack using a polygon shapefile i made in ArcGIS, however I get error that extent does not overlap. First I create the raster stack: test1 < stack("C:/mydir/test1.tif") define projection myCRS <- test1@crs then read shapefile myExtent <- readShapePoly("C:/mydir/loc1.shp", verbose=TRUE, proj4string=myCRS) Crop myCrop <- crop(test1, myExtent) Error in .local(x, y, ...) : extents do not overlap I have searched for a solution, but i only find that projection can be the

Poor resolution of raster plot when output to file

我只是一个虾纸丫 提交于 2019-12-13 13:33:31
问题 I have a reasonably high definition global map raster and want to plot to file, but cannot seem to maintain resolution. Plotting a restricted region works ok, but the whole world always ends up with reduced resolution, no matter what method I've used. Am I missing something here? I've often output high-res rasters before without this problem, but I'm unable to identify the cause in this case. To illustrate: require(raster) require(rworldmap) data(countriesCoarse); worldmap = countriesCoarse

Plot pixels time series

你说的曾经没有我的故事 提交于 2019-12-13 07:22:35
问题 I'm trying to create an interactive plot of a raster brick, whereby clicking on a pixel gives you a time series of data at that pixel. (My raster brick is about 345 image.) This is what I did: library(raster) EVI <- "D:\\Modis_EVI\\Original\\EVI_Stack_single5000.tif" y.EVI <- brick(EVI) plot(as.numeric(click(y.EVI)), type="l", lwd=2) But it does not plot at all. And when i try with a smaller stack like 4 images only it gives this error: Error in plot.window(…) : need finite 'xlim' values Any

How to find second highest value and corresponding layer name in a raster stack in R

霸气de小男生 提交于 2019-12-13 05:46:15
问题 I have a rasterstack with 12 layers and I would like to extract the 2nd highest value along with its corresponding layer name. I found codes to order my values into 12 new layers in decreasing order: rs_ord <- calc(inraster, fun=function(X,na.rm) X[order(X,decreasing=T)]) Now, if I could only do the same but return the corresponding layer's name, it would answer it all. Thanks, Pierre 回答1: Depending on the dimensions of your rasters, you may be able to use the following, which I'll

plot raster with discrete colors using rasterVis

别来无恙 提交于 2019-12-13 04:53:17
问题 I have a few rasters I would like to plot using gplot in the rasterVis package. I just discovered gplot (which is fantastic and so much faster than doing data.frame(rasterToPoints(r))). However, I can't get a discrete image to show. Normally if r is a raster, I'd do: rdf=data.frame(rasterToPoints(r)) rdf$cuts=cut(rdf$value,breaks=seq(0,max(rdf$value),length.out=5)) ggplot(rdf)+geom_raster(aes(x,y,fill=cuts)) But is there a way to avoid the call to rasterToPoints? It is very slow with large