raster

How to Replace Raster Values Less than 0 to NA in R code

送分小仙女□ 提交于 2019-11-30 03:06:28
问题 I am working with Landsat imagery to calculate net radiation. There are very low negative values (ex: -0.000003) that are in my converted reflectance raster layers. I want to make sure that my reflectances are 0 - 1 in order to reduce error in my future calculations. How can I replace raster values less than 0 to "NA" in R. Similar to a raster calc function. I'm unsure how to provide an example, but I'm certain one of you could help me, yes? Here is my equation for the reflectivity derived

R crop raster data and set axis limits

爱⌒轻易说出口 提交于 2019-11-30 01:32:11
With your help in another thread I have managed to plot some global maps. First I convert meteorological GRIB2 data to Netcdf and then plot the global maps. Now I want to plot just a subregion of the map. I have tried crop command and succesfully extracted the subregion of the global nc file. But when plotting I can't find how to control axis limits. It plots a map bigger than data region so big white spaces appear on both sides. This is the script I'm using to plot maps library("ncdf") library("raster") library("maptools") DIA=format(Sys.time(), "%Y%m%d00") # Data d'avui url=sprintf("ftp:/

How to project and resample a grid to match another grid with GDAL python?

て烟熏妆下的殇ゞ 提交于 2019-11-29 20:31:19
Clarification: I somehow left out the key aspect: not using os.system or subprocess - just the python API. I'm trying to convert a section of a NOAA GTX offset grid for vertical datum transformations and not totally following how to do this in GDAL with python. I'd like to take a grid (in this case a Bathymetry Attributed Grid, but it could be a geotif) and use it as the template that I'd like to do to. If I can do this right, I have a feeling that it will greatly help people make use of this type of data. Here is what I have that is definitely not working. When I run gdalinfo on the resulting

How to fix map boundaries on d3 cartographic raster reprojection?

邮差的信 提交于 2019-11-29 20:29:16
问题 I try to use the raster reprojection of a map following this example. If I change the example kavrayskiy7 projection by the Azimuthal Equidistant projection, var projection = d3.geo.azimuthalEquidistant() .scale(90) .translate([width / 2, height / 2]) .clipAngle(180 - 1e-3) .precision(.1); it should project the Earth onto a disc (the image of the projection map). However, the raster reprojection goes beyond that disc and fills the entire canvas with an extended picture (the inverse projection

Add raster image to HDF5 file using h5py

心不动则不痛 提交于 2019-11-29 14:55:25
问题 I apologize if this is sort of a newbie question, but I am fairly new to Python and HDF5. I am using h5py, numpy, and Python 2.7. I have data from various files that need to be imported into one HDF5 file. The data from each file is to be stored in a different group. Each of these groups needs to contain 1) the raw data from the file as an m x n matrix and 2) an image raster generated from normalized raw data. I am able to accomplish part 1, and am able to normalize the data, but I am not

Plotting netcdf file with levels in R

大城市里の小女人 提交于 2019-11-29 12:22:56
I have recently started to work with netcdf in R. Sample data is here: http://www.earthstat.org/data-download/ > Harvested area and yield for 175 crops > individual crops > soybean_HarvAreaYield2000_NetCDF In this folder, there is a netcdf file called soybean_AreaYieldProduction.nc This is how I open the netcdf library(ncdf4) dat <- nc_open("soybean_AreaYieldProduction.nc") print(soy) 1 variables (excluding dimension variables): float soybeanData[longitude,latitude,level,time] LayerDescriptions: struct(5).Data(:,:,1/2/3/4/5/6) to access data layer: 1=Harvested Area fraction, 2=Yield 3

How to remove the box frame in “plot.raster” in R package “raster”

≯℡__Kan透↙ 提交于 2019-11-29 11:45:25
问题 I need to remove the box frame around the figure in R package "raster", but I cannot figure out which argument I should change. The example is as follows: library(raster) r <- raster(nrows=10, ncols=10) r <- setValues(r, 1:ncell(r)) plot(r) plot(r,axes=F) 回答1: This works: plot(r, axes=FALSE, box=FALSE) To learn how you could have found that out for yourself, have a look at the underlying functions by trying the following. (The calls to showMethods() and getMethod() are needed because the

R - plotting multiple rasters using matrix layout

余生颓废 提交于 2019-11-29 10:42:23
In R (Win64), I'm trying to plot a combination of raster images and histograms in a single plot window using the layout() command with a matrix defining the layout. Here's some sample code with simplified data: library(raster) r <- raster(ncols=5, nrows=5, xmn=1, xmx=5, ymn=1, ymx=5) rast1 <- rasterize(expand.grid(1:5,1:5), r, rnorm(25)) rast2 <- rasterize(expand.grid(1:5,1:5), r, rnorm(25)) rast3 <- rasterize(expand.grid(1:5,1:5), r, rnorm(25)) layout(matrix(c(1,2,3,4,1,2,3,5,1,2,3,6), 3, 4, byrow=T)) layout.show(6) plot(rast1, axes=F, ann=F, legend=F, box=F, useRaster=T) plot(rast2, axes=F,

R plot background map from Geotiff with ggplot2

本小妞迷上赌 提交于 2019-11-29 09:49:38
问题 With the R base plot, I can plot any geotiff with the following command: library("raster") plot(raster("geo.tiff")) For example, downloading this data, I would do the follwing: setwd("C:/download") # same folder as the ZIP-File map <- raster("smr25musterdaten/SMR_25/SMR_25KOMB_508dpi_LZW/SMR25_LV03_KOMB_Mosaic.tif") How do you Plot GeoTif Files in ggplot2? EDIT: 1: I've replaced the greyscale map from the sample files with a coloured map to ilustrate the problem of the missing colortable. 2:

Find second highest value on a raster stack in R

怎甘沉沦 提交于 2019-11-29 08:45:03
In R I can easily compute the max/min value of each cell in a georeferenced raster stack using the max/min commands. set.seed(42) require(raster) r1 <- raster(nrows=10, ncols=10) r2=r3=r4=r1 r1[]= runif(ncell(r1)) r2[]= runif(ncell(r1))+0.2 r3[]= runif(ncell(r1))-0.2 r4[]= runif(ncell(r1)) rs=stack(r1,r2,r3,r4) plot(rs) max(rs) min(rs) However, I have been trying to find a way to find the second highest values across a stack. In my case, each raster on the stack denotes performance of a particular model across space. I would like to compare the first vs second best values to determine how much