raster

PCA using raster datasets in R

£可爱£侵袭症+ 提交于 2019-12-01 17:02:29
问题 I have several large rasters that I want to process in a PCA (to produce summary rasters). I have seen several examples whereby people seem to be simply calling prcomp or princomp. However, when I do this, I get the following error message: Error in as.vector(data): no method for coercing this S4 class to a vector Example code: files<-list.files() # a set of rasters layers<-stack(files) # using the raster package pca<-prcomp(layers) I have tried using a raster brick instead of stack but that

R raster recognizing black color raster image

一世执手 提交于 2019-12-01 11:54:32
The code below produces two boxes on my image. I am planning to analyze pixels within those boxes further. I want to put a condition that if along an edge of a box, there is a black color (or a similar color such as grey) pixel then don't proceed. How can i specify such condition? In below example, in the case of the red square I don't want to proceed further as it has black pixels at the top right hand corner. While I would like to proceed in the case of green square as it doesn't have a black color pixel along it's edge. library(raster) r1 <- brick(system.file("external/rlogo.grd", package=

ploting artefact with points over raster

那年仲夏 提交于 2019-12-01 04:27:42
I noticed some weird behavior when resizing the plot window. Consider library(sp) library(rgeos) library(raster) rst.test <- raster(nrows=300, ncols=300, xmn=-150, xmx=150, ymn=-150, ymx=150, crs="NA") sap.krog300 <- SpatialPoints(coordinates(matrix(c(0,0), ncol = 2))) sap.krog300 <- gBuffer(spgeom = sap.krog300, width = 100, quadsegs = 20) shrunk <- gBuffer(spgeom = sap.krog300, width = -30) shrunk <- rasterize(x = shrunk, y = rst.test) shrunk.coords <- xyFromCell(object = rst.test, cell = which(shrunk[] == 1)) plot(shrunk) points(shrunk.coords, pch = "+") If you resize the window, plotted

Shapefile to raster conversion in R?

二次信任 提交于 2019-12-01 04:06:16
I have a shapefile downloaded from the worldwildlife.org for the terrestrial ecoregions of the world. The file can be loaded here: http://worldwildlife.org/publications/terrestrial-ecoregions-of-the-world . It comes as a standard shape file and I would like to do two things with it. First: take the shapefile from my local directory and clip it to an extent of eastern North America (ext= extent (-95, -50, 24, 63)) # Read shapefile using package "maptools" eco_shp <- readShapeLines("F:/01_2013/Ecoregions/Global/wwf_terr_ecos.shp", proj4string=CRS("+proj=utm +zone=33 +datum=WGS84")) # Set the

what is a clockwise face in openGL

僤鯓⒐⒋嵵緔 提交于 2019-12-01 04:06:06
In back face culling you may either use the face normals to see if the face is pointing away from the camera of you may do some technique with if the triangle is drawn clock wise or counter clock wise. I am confused about this technique with the clockwise. It seems like with this method, the ordering of the vertex data that gets sent to the graphics card decides whether it is facing towards or away from the camera. I don't see how this makes sense because the camera can be looking in any direction, it's as if the vertex data would have to change based on the camera position and that is

Moving window regression

核能气质少年 提交于 2019-12-01 01:54:42
I want to perform a moving window regression on every pixel of two raster stacks representing Band3 and Band4 of Landsat data. The result should be two additional stacks, one representing the Intercept and the other one representing the slope of the regression. So layer 1 of stack "B3" and stack "B4" result in layer 1 of stack "intercept" and stack "slope". Layer 2 of stack B3 and stack B4 result in layer 2,.... and so on. I already came along the gwr function, but want to stay in the raster package. I somehow know that focal must be included in order to set my moving window (which should be

what is a clockwise face in openGL

▼魔方 西西 提交于 2019-12-01 01:08:08
问题 In back face culling you may either use the face normals to see if the face is pointing away from the camera of you may do some technique with if the triangle is drawn clock wise or counter clock wise. I am confused about this technique with the clockwise. It seems like with this method, the ordering of the vertex data that gets sent to the graphics card decides whether it is facing towards or away from the camera. I don't see how this makes sense because the camera can be looking in any

R - original colours of georeferenced raster image using ggplot2- and raster-packages

邮差的信 提交于 2019-11-30 22:01:36
I would like to use the original colortable of a >>georeferenced raster image<< (tif-file) as coloured scale in a map plotted by ggplot/ggplot2 . Due to not finding an easier solution, I accessed the colortable -slot from the legend -attribute of the loaded raster image (object) raster1 like so: raster1 <- raster(paste(workingDir, "/HUEK200_Durchlaessigkeit001_proj001.tif", sep="", collapse="")) raster1.pts <- rasterToPoints(raster1) raster1.df <- data.frame(raster1.pts) colTab <- attr(raster1, "legend")@colortable Ok, so far so good. Now I simply need to apply colortable as a colored scale to

Is StretchBlt HALFTONE == BILINEAR for all scaling?

為{幸葍}努か 提交于 2019-11-30 21:42:51
Can anyone clarify if the GDI StretchBlt function for the workstation Win32 API performs bilinear interpolation for scaling to both larger and smaller images for 24/32-bit color images? And if not, is there a GDI ( not GDI+) function that does this? The SetStretchBltMode fn has a setting HALFTONE which is documented as follows: HALFTONE Maps pixels from the source rectangle into blocks of pixels in the destination rectangle. The average color over the destination block of pixels approximates the color of the source pixels. I've seen references (see follow-up to first answer) that this performs

Plot continuous raster data in binned classes with ggplot2 in R

狂风中的少年 提交于 2019-11-30 20:40:31
I quite like the look and feel of ggplot2 and use them often to display raster data (e.g facetting over timesteps for time-varying precipitation fields is very useful). However, I'm still wondering whether it is easily possible to bin the continuous raster values into discrete bins and assign to each bin a single colour , that is shown in the legend (as many GIS systems do). I tried with the guide = "legend" , and breaks arguments of the scale_fill_gradient option. However these affect just the legend on the side of the graph, but the plotted values are still continuous. library(ggplot2) data