raster

Merging multiple rasters in R

隐身守侯 提交于 2019-12-03 02:01:19
I've been trying to find a time-efficient way to merge multiple raster images in R. These are adjacent ASTER scenes from the southern Kilimanjaro region, and my target is to put them together to obtain one large image. This is what I got so far (object 'ast14dmo' representing a list of RasterLayer objects): # Loop through single ASTER scenes for (i in seq(ast14dmo.sd)) { if (i == 1) { # Merge current with subsequent scene ast14dmo.sd.mrg <- merge(ast14dmo.sd[[i]], ast14dmo.sd[[i+1]], tolerance = 1) } else if (i > 1 && i < length(ast14dmo.sd)) { tmp.mrg <- merge(ast14dmo.sd[[i]], ast14dmo.sd[[i

Can R be used for GIS? [closed]

北慕城南 提交于 2019-12-03 01:56:38
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'd like to create some GIS plots, and I'm wondering if R can be used for this. Here are some examples of plots I'd similar in concept to those I'd like to make: A temperature plot (or contour plot) of the United States, with color (or height) determined by state GDP. Thus, state

R: Write RasterStack and preserve layer names

谁都会走 提交于 2019-12-02 22:55:45
I have a raster stack, stk , consisting of three raster images in R. Here is a simple example # set up a raster stack with three layers > library(raster) > r <- raster(nrows=10,ncols=10) > r[] <- rnorm(100) > stk <- stack(r,r,r) # layer names are set by default > names(stk) [1] "layer.1" "layer.2" "layer.3" I assign names to the raster layers: # set layer names to "one", "two" and "three" > names(stk) <- c('one','two','three') > names(stk) [1] "one" "two" "three" When I write the RasterStack to a GeoTiff (multilayered) using: writeRaster(stk,"myStack.tif", format="GTiff") The layers are

ggplot2: raster plotting does not work as expected when setting alpha values

浪尽此生 提交于 2019-12-02 21:58:58
First post here, I hope I'm observing website etiquette. I couldn't find and answer on the site and I previously posted this to a ggplot2 specific group, but no solutions as yet. Basically I am trying to overlay two rasters using ggplot2 and require the top one to be semi-transparent. I have a hillShade raster which is computed from an elevation data raster, and I wish to overlay the elevation raster onto the hillshade raster so the resulting plot doesn't look 'flat'. You can see what I mean in the reproducible R code below. Using base graphics I can achieve the desired result and I have

How many non-NA values in each row for a matrix?

江枫思渺然 提交于 2019-12-02 17:52:55
问题 I have a matrix(raster) that I am computing the the mean of each row in this raster as: library (raster) r <- raster(nrows=10, ncols=10);r <- setValues(r, 1:ncell(r)) extent(r) = extent(c(xmn=-180,xmx=180,ymn=-90,ymx=90)) stepsize = (r@extent@ymax - r@extent@ymin) / r@nrows yvals = seq(r@extent@ymax - stepsize / 2, r@extent@ymin, -stepsize) The x-values will be the mean of each row in the raster: xvals = rowMeans(as.matrix(r)) plot(xvals, yvals) What I need is to know how many values were

Identify a linear feature on a raster map and return a linear shape object using R

风流意气都作罢 提交于 2019-12-02 17:42:59
I would like to identify linear features, such as roads and rivers, on raster maps and convert them to a linear spatial object ( SpatialLines class) using R. The raster and sp packages can be used to convert features from rasters to polygon vector objects ( SpatialPolygons class). rasterToPolygons() will extract cells of a certain value from a raster and return a polygon object. The product can be simplified using the dissolve=TRUE option, which calls routines in the rgeos package to do this. This all works just fine, but I would prefer it to be a SpatialLines object. How can I do this?

How to obtain Dates of annual maximum gridcell values of rasterbrick?

房东的猫 提交于 2019-12-02 17:28:13
问题 How can i get two rasters that gives the maximum value for each grid cells per year and also gives the dates on which that maximum value has occured. Below is the reproducible example with some steps i have implemented. library(raster) # Create a raster r1 <- raster(nrow=10, ncol=7) r <- stack(setValues(r1, runif(ncell(r1))), setValues(r1, runif(70 ,0.6,0.9)), setValues(r1, runif(70 ,0.2,0.4)), setValues(r1, runif(70 ,1,2)), setValues(r1, runif(70 ,0.5,1.0)), setValues(r1, runif(70 ,0.3,0.9))

Can R be used for GIS? [closed]

↘锁芯ラ 提交于 2019-12-02 14:04:51
I'd like to create some GIS plots, and I'm wondering if R can be used for this. Here are some examples of plots I'd similar in concept to those I'd like to make: A temperature plot (or contour plot) of the United States, with color (or height) determined by state GDP. Thus, state boundaries would give discontinuities in the resulting plot. A temperature plot of the United States where altitude is used for data. In this case, the resulting plot should vary smoothly across state boundaries. The sum of the above 2 plots (with some scaling applied). I'm just starting to learn R, and want to know

How to obtain Dates of annual maximum gridcell values of rasterbrick?

随声附和 提交于 2019-12-02 11:42:07
How can i get two rasters that gives the maximum value for each grid cells per year and also gives the dates on which that maximum value has occured. Below is the reproducible example with some steps i have implemented. library(raster) # Create a raster r1 <- raster(nrow=10, ncol=7) r <- stack(setValues(r1, runif(ncell(r1))), setValues(r1, runif(70 ,0.6,0.9)), setValues(r1, runif(70 ,0.2,0.4)), setValues(r1, runif(70 ,1,2)), setValues(r1, runif(70 ,0.5,1.0)), setValues(r1, runif(70 ,0.3,0.9)), setValues(r1, runif(70 ,1,2))) r # Make Dates. This is random, i have about 24000 values. Dates<-data

How do I get a Raster from an Image in java?

房东的猫 提交于 2019-12-02 11:34:32
问题 I'm trying to load a gif image from a url into a java.util.image.Raster so I can manipulate it. The only method for loading and decompressing an image I could find was Toolkit.getImage, which returns a java.awt.Image. I need to turn that into a Raster so I can work with it. Suggestions? 回答1: Load your Image into a Buffered Image and then get the data from it BufferedImage img = null; try { img = ImageIO.read(new File ("c:/imageFile.gif")); } catch(Exception e) {} Raster R=img.getData(); 回答2: