raster

Conditional command from Raster Calculator transfer to R

偶尔善良 提交于 2019-12-11 05:06:18
问题 So far I used the following statement in the Raster Calculator of ArcGIS: Con(("Land_use.rst" == -20), "Export.rst") This calculates a new Raster which only contains the Data from Export where Land_use equals -20. That is exactly what I want. But I want to automatise this in R , as I have to do it a lot of times. So far I got something like this: for (catch_dir in Dir_List) { r1 <- raster(paste0(catch_dir, '/Export.rst')) r2 <- raster(paste0(catch_dir,'/LAND_use.rst')) ### statement that

ASCII to raster conversion

China☆狼群 提交于 2019-12-11 04:05:41
问题 I am using following code for opening a Raster image in single band (with temperature values)- library(raster) nrows = 764 ncols = 1022 df1 <- read.table("AA092800_1.asc", skip = 11, header = FALSE, sep = "\t", dec = ",") r.mat <- matrix(data = "df1", nrow = nrows, ncol = ncols) r <- raster(r.mat) extent(r) <- extent(c(30,45.95,30,45.95)) res(r) plot(r) I am doing a silly mistake and the code is throwing the error- "Error in setValues(r, as.vector(t(x))) : values must be numeric, integer,

Plotting multiple layers with geom_raster() or geom_tile or geom_rect()

蓝咒 提交于 2019-12-11 04:05:33
问题 I have a data.frame of b/w raster image data that I'm using as a background/base layer. It has three columns: x, y, z. Where x and y are the respective coordinates and z is a continuous value defining a 512 x 512 image. I set this background fill to a black-white gradient and plot using geom_raster() in ggplot2 and then save the image to a PDF file. ### MWE of base layer # original 512x512 data is read in from a file in matrix format, so here's a mocked up example of same: h = matrix(data =

Paper.js Background Rasterization Glitches

余生长醉 提交于 2019-12-11 04:05:23
问题 We are building an image editor of sorts using Paper.js. We have a queue on the side of the Paper.js canvas that allows switching between images. Each time we switch between images, we want to flatten all the annotations (rasterize) onto the image just being edited. Each time we switch images, this method is called, which rasterizes the current image and annotations to a data URL. (If we revisit this image, a raster from this data URL will be displayed.) var flattenToDataUrl = function() {

Paper.js Subraster Added Behind Rectangle Instead of in Front

与世无争的帅哥 提交于 2019-12-11 03:33:21
问题 In this Paper.js Sketch, selecting an area of the Mona Lisa raster makes a whiteout Rectangle of the area in place, as well as a generating a subraster of the area. The whiteout rectangle is added first, and the subraster second. However, as you witness in the sketch, the whiteout rectangle remains on top. Test this by commenting out the whiteout rectangle chunk and uncommenting the last line to see that the subraster does indeed get generated. This can be remedied in this scenario with a

Combining SpatialPolygonsDataFrame of two neighbour countries

浪尽此生 提交于 2019-12-11 03:33:01
问题 I want to combine the SpatialPolygonsDataFrame of two neighbour countries like Pakistan and India. My MWE is below: library(raster) Pakistan.adm1.spdf <- getData( "GADM" , country = "Pakistan" , level = 1 ) India.adm1.spdf <- getData( "GADM" , country = "India" , level = 1 ) How can I combine these two shapefiles? 回答1: From the answer to this question, use rbind and the argument makeUniqueIDs . adm1.spdf <- rbind(Pakistan.adm1.spdf, India.adm1.spdf, makeUniqueIDs = TRUE) plot(adm1.spdf) 来源:

Convert Lambert conformal conic projection to wgs84 in r

人走茶凉 提交于 2019-12-11 03:25:51
问题 I have Lambert conformal conic projection x,y information. I need the WGS84 coordinate. But I don't know what is lcc exactly. I have provided the lcc information below. Is there a way to convert lcc to WGS84 in r? example lcc x,y : xy <- cbind(c(509535.7, 514535.7),c(201098.6, 201098.6)) lcc information : Latitude of first standard parallel : 30.0 Latitude of second standard parallel : 60.0 Origin latitude : 38.0 Origin longitude : 126.0 Easting of computation point : 43 Northing of

How to display the same legend for all raster layers in a rasterStack

耗尽温柔 提交于 2019-12-11 02:55:37
问题 I've looked through all SO but haven't been able to find an answer to this specific question: I have a rasterStack with several layers whose values span over a quite large range. Knowing the values of each layer and the chosen colour scale I believe I have managed to plot all the rasters with the same colour scale, but I face three problems now: I can't be sure that the values are being plotted with the same colour scale, although it seems like it I can't manage to plot the same scale and

How to change the resolution of .tif raster file without losing data

青春壹個敷衍的年華 提交于 2019-12-11 01:26:24
问题 For example, A .tiff file of 400*200 size, I can read it as a 2-D array(400 x 200) in python. I want to change the tiff size to 200 x 100 or other ratio. How to realize that in Python or GIS software(QGIS, ArcGIS et.al). I know the resemble tool in ArcGIS can change the size of raster data. but the length-width ratio is fixed. Example Diagram: (source: tietuku.com) 回答1: With R you can do things like library(raster) r <- raster('file.tif') a <- aggregate(r, c(2,3)) 来源: https://stackoverflow

R for leaflet redirect when clicking on raster image

穿精又带淫゛_ 提交于 2019-12-11 01:16:50
问题 I'm using leaflet for R and I simply would like to be redirected on some URL when I click on the raster image. My current code is the following : library(htmlwidgets) library(raster) library(leaflet) library(sp) imgPath = paste(projectPath,"/test.tif", sep = "") outPath = paste(projectPath, "/leaflethtmlgen.html", sep="") r <- raster(imgPath) pal <- colorNumeric(c("#FF0000", "#666666", "#FFFFFF"), values(r), na.color = "transparent") m <- leaflet() m <- addTiles(m) m <- addRasterImage(m,r,