Hot answers tagged

12

Here is an example of creating a stacked image, using the ee.ImageCollection.iterate() method. I also included code to define to define an example region and image collection, so that it is a working example. // Define a sample Region-of-Interest var roi = ee.Geometry.Polygon( [[[-109.1, 37.0], [-109.1, 36.9], [-108.9, 36.9], ...


10

This is not related to R 4.0.1 but to rgdal 1.5-8 and the migration to gdal 3 and proj 6. This is a very long and complex process that impact hundreds maybe thouthands of packages. All the packages are not yet up-to-date with what is coming. You can have a look to ?rgdal::set_thin_PROJ6_warnings() to eliminate those warnings. Edit after Roger's comment: See ...


9

You need to use the Composite Bands ArcGIS Geoprocessing tool. According to the ArcGIS Help, This tool can also create a raster dataset containing subset of the original raster dataset bands. This is useful if you need to create a new raster dataset with a specific band combination and order.


9

I have found on stack overflow a more generic way with the raster package using stackApply(). #get the date from the names of the layers and extract the month indices <- format(as.Date(names(ndvi.stack), format = "X%Y.%m.%d"), format = "%m") indices <- as.numeric(indices) #sum layers MonthNDVI<- stackApply(ndvi.stack, indices, fun = mean) names(...


9

If you read a TIFF with raster like you have in your loop you'll only get one layer read: > r = raster("./GcrfPicture.tif") > r class : RasterLayer band : 1 (of 4 bands) dimensions : 720, 960, 691200 (nrow, ncol, ncell) resolution : 1, 1 (x, y) The 1 (of 4 bands) is telling you that the source had four bands but its only read one....


8

Note that the new, better way to do this is with imageCollection.toBands().


6

I also needed to know how to rename bands in an open source environment so spent a whole day looking for answers. There is no way to name bands in QGIS while merging. But it can be done after the file is created, by editing their .aux.xml file. It works for both .tif and .img files, as far as I've researched. The solution is to include after each <...


5

So I am able to get all the layers in a single layer, a "composite" by using the MultiProvider provider in the class and just passing it the layers I want in the composite as the arguments. It results in a single JSON file that contains all of my layers. This is the layer I added in the cfg "composite": { "allowed origin":"*", ...


5

Geoprocessing was moved to processing toolbar in QGIS 2.16, as you can see below:


5

In Windows (run OSGeo4W shell): Scaling: for %i in (*.tif) DO gdal_translate -scale -2000 10000 -0.2 1 %i outputs\%i You might find recalculating instead better: for %i in (*.tif) DO gdal_calc.bat -A %i --outfile=outputs\%i --calc="A*0.0001" --NoDataValue=0 In Ubuntu looping through files is slightly different: for i in *.tif; do gdal_calc -A $i ......


5

You can use projectRaster() to resample to a new resolution (also extent and CRS): r2resampled <- projectRaster(r2,r1,method = 'ngb') r3resampled <- projectRaster(r3,r1,method = 'bilinear') The first one is categorical, so it's necessary to use nearest neighbor as method (ngb). The second one is numeric, so you can use bilinear (bilinear) or nearest ...


5

Just use a for loop with a little trick to iterate. First, as always is recommended, a reproducible example: library(raster) data('lsat',package='RStoolbox') names(lsat)[1:4] <- c('blue','green','red','NIR') images <- list() for(i in 1:27){ images[[i]] <- lsat[[1:4]] } images <- stack(images) images ## class : RasterStack ## ...


4

First, you are using R. R Studio is just an IDE for R so in the future please make this an R question. I will warn you that working with HDF files in R is a pain. In theory GDAL supports HDF5 so one could use readGDAL in the rgdal package. Depending on the source of the data readGDAL has a high fail rate making it less than reliable. Historically, there ...


4

You can manage multi-extent-problem resampling your data before mask() function. This work for aligned and non-aligned pixels (for non-aligned, choose wisely method argument). Also, you can use extendto align boundaries of your data. I'd made an reproducible example for recreate our problem: library(raster) a <- raster(xmn=-100, xmx=100, ymn=-90, ymx=90,...


4

The most accurate solution to create monthly composites from these 16-day best value images would be to take into consideration the accompanying 'composite_day_of_the_year' scientific data set (see also MOD13A1 V006 product description). For a rather straightforward solution, please have a look at temporalComposite from MODIS and, in particular, the example ...


4

You can use mget() to search for objects given a character vector. predictors<-stack(mget(unique(as.character(bestpredictors$var))))


4

If using rasterio >= 1.0, use the dataset.set_band_description(self, bidx, value) method and dataset.descriptions property. Sets the description of a dataset band. Parameters ---------- bidx : int Index of the band (starting with 1). value: string A description of the band. For example: descriptions = [ 'Band 1 Reflectance', 'Band 2 ...


3

Your question is a good example of why site guidelines request that you provide an example of what you have already tried and ideally, some example data. There are many aspects of your question that leave one speculating. For example, I am not clear as to what you mean by "one from a SpatialPolygonsDataFrame". Is your land-use raster data rasterized from ...


3

I think I've found the answer. Convert to data frame and use count in the plyr package; y <- extract(s,c(1:ncell(s))) ydf <- as.data.frame(y) head(ydf) count(ydf, vars = c("layer.1","layer.2","layer.3","layer.4"))


3

I had the troubles myself and couldn't find a solution. To export and import rasters between ENVI and R and keep the band names seems impossible (cf. this related question). A workaround is to copy the band_names from the .hdr file and rename the band names from the imported rasterstack. band names = {a,b,c} copied from file.hdr image <- stack("file....


3

You can control the number of plots per graphic device using the mfrow and mfcol arguments in par(). par(mfrow=c(3,4)) for(i in 1:12) {plot(runif(100),runif(100)*0.05)}


3

For unifying dimensions and resolutions of rasters, resample() function from Raster package works well for me: library(raster) r1 <- raster("Animal.tif") r2 <- raster("LandTrans.tif") r3 <- raster("TempJan.tif") r1 <- resample(r1,r3) r2 <- resample(r2,r3,method='ngb') rs <- stack(r1,r2,r3) plot(rs)


3

You are trying to read raster data with read_csv: library(readr) img1 <- read_csv("E:/Topic_sinkholes/Final data/stack layers/img1.hdr") You've not told us where you got this file from but if it is geospatial raster data it is unlikely to be a CSV file. Try: library(raster) img1 = raster("E:/Topic_sinkholes/Final data/stack layers/img1.hdr&...


2

For Ubuntu users, just change .bat for .py and quote the files with respective path Go to the Terminal and write: gdal_merge.py -separate -of GTiff -o "path/output.tif" "path/input1.tif" "path/input2.tif" "path/input3.tif"


2

You were right, the r.series manual page was a bit lousy. I have hopefully improved it now. Comments certainly welcome. Concerning quantiles, if you want a single, i.e. a global map value, then check r.quantile or r.univar Example: Calculation of multiple elevation quantiles, results are printed and not stored as a new map: g.region rast=elevation -p r....


2

If you choose rasterVis::levelplot, the layout argument will help you. Details about this argument can be found in the help page of lattice::xyplot: ‘layout’ is a numeric vector of length 2 or 3 giving the number of columns, rows, and pages (optional) in a multipanel display. library(raster) library(rasterVis) r <- raster() ll <- list() for (i in ...


2

Here are some hints. It is difficult to answer without knowing more about your data. Please show us the result of: raster(raster_data[1]) You pass arguments to the raster function that are ignored when you create an object from file. You do not need to use crop on this layer. Certainly not before you project the data to lon/lat. You never need ...


2

You could use the gimms package to download (downloadGimms) and rasterize (rasterizeGimms) half-monthly NDVI3g layers for a 10-year period (see ?downloadGimms) and subsequently run calc(..., fun = mean, na.rm = TRUE) to deduce the decadal-scale average NDVI. The dataset comes in a spatial resolution of 1/12 degree (approx. 8 km), which is quite close to ...


2

See the example below: library("gapfill") library("raster") ## create raster data for demo ## extent: x=10, y=10, month=3, years=2 data <- array(runif(600), c(10,10,6)) data[c(1,5,54,76,150,450,556)] <- NA input_stack <- stack(brick(data)) plot(input_stack) ## create array and predict missing values with gapfill() tmp <- array(input_stack, dim=...


Only top voted, non community-wiki answers of a minimum length are eligible