Hi Jackson,
calc is meant to apply a function pixel wise on a single raster object.
Its equivalent for multiple raster objects is overlay.
Kind regards,
Loïc
On 05/28/2020 09:05 AM, Bede-Fazekas Ákos wrote:
Dear Jackson,
I think this is what you are searching for:
new_s3 <- setValues(r,
Hi Jackson,
All the layers of the toy dataset you create in your example are
identical. Is that intentional?
Below I create a more heterogeneous dataset and introduce a few NAs.
library(raster)
library(trend)
set.seed(12)
r <- raster(nrow=10, ncol=10)
s <- lapply(1:200, function(i)
Hi Jackson,
The strategy is to make your function work for raster::calc, and
parallelize it with raster's built in parallelization utils (see ?clusterR).
Looping over pixels of a raster/matrix is nearly never the correct answer.
stars::st_apply would probably also be a good option.
Thanks Edzer,
I confirm that it's working now.
Kind regards,
Loïc
On 04/25/2020 07:05 PM, Edzer Pebesma wrote:
See https://github.com/r-spatial/stars/issues/276
should be fixed now.
Thanks!
On 4/25/20 6:06 PM, Loïc Dutrieux wrote:
Hi Edzer,
Below an example that generates a raster
Hi everyone,
I have a large geoTiff raster file that does not fit in memory (if I do
read_stars(file_path) I get "Error: cannot allocate vector of size 12.7
Gb"). How can I read a spatial subset of that file.
The example below works with a toy example but not with the actual large
dataset.
On 14/02/2018 04:11, Roger Bivand wrote:
> On Tue, 13 Feb 2018, Adam Fera wrote:
>
>> Hello, Amos,
>>
>> I came across this posting because I had a similar problem using R for
>> mapping within GNU Emacs Org Mode on GNU/Linux. I work on a research
>> team
>> that uses a shared directory for
This is also possible with rgeos
library(sp)
library(rgeos)
x <- 673593.21
y <- 673593.21
sp0 <- SpatialPoints(coords = data.frame(x=x, y=y),
proj4string = CRS('+proj=utm +zone=20 +south
+ellps=WGS84 +datum=WGS84 +units=m +no_defs'))
sp1 <- gBuffer(sp0, byid=TRUE, width =
On 31/08/17 14:22, Miluji Sb wrote:
I have a set of coordinates:
temp <- dput(head(gcp,10))
structure(list(lon = c(-180, -180, -179, -179, -178, -178, -177,
-176, -176, -175), lat = c(67, 68, 67, 68, 67, 68, 67, 66, 67,
66)), datalabel = "", time.stamp = "11 Aug 2017 16:10", .Names = c("lon",
On 24/08/17 10:23, Roger Bivand wrote:
On Thu, 24 Aug 2017, manuel.schnei...@agroscope.admin.ch wrote:
Dear list
I am searching alternatives to ESRI shapefiles for the storage of GPS
data, i.e. tagged point features, and came across SpatialLite or
Geopackage. Unfortunately writing to both
writeRaster() defaults to Float 8, regardless of the data type of your
input matrix. You can set it explicitly to write to integer by using the
datatype= argument.
writeRaster(r, "Test_writeRaster.asc",NAflag =-999,overwrite=T,
datatype='INT2S')
Cheers,
Loïc
On 17/05/2017 03:21, Michael Koehler
sk rik ozi rasterlite
> mbtiles postgisraster arg
>
> I think the problem is the driver that is used to manage the jp2 file.
> Any idea how can I include in the R code the --config GDAL_SKIP JP2ECW
> option.
>
> Cheers,
> M
>
>> El 15 mar 2017, a las 23:13, Loïc Dutrie
Hi,
I tried your code with some S2 images I had lying around, and it works
on my system. I modified it a bit to write the output layers to the same
directory and not to my working directory.
library(gdalUtils)
library(raster)
Image_Path<-'/path/to/images/'
S2_JP2_List <- list.files(Image_Path,
Thanks for providing an example, see the suggestion inline
On 22/02/2017 10:45, Francesc Montserrat wrote:
> Dear List,
>
> As I have only recently started using R for spatial analysis, and I am
> not a geographer or spatial data specialist by any means, I have a -what
> I presume to be-
On 12/02/2017 03:14, Michael Sumner wrote:
> I believe the "remote" package has functions for doing exactly this.
>
> HTH
>
> On Sun, Feb 12, 2017, 17:42 Thiago V. dos Santos via R-sig-Geo <
> r-sig-geo@r-project.org> wrote:
>
>> Dear all,
>>
>> I have a netcdf file with monthly temperatures
Thanks for figuring it out Barry. I informed Robert about it.
Cheers,
Loïc
On 30/01/2017 08:19, Barry Rowlingson wrote:
> On Sun, Jan 29, 2017 at 7:26 PM, Loïc Dutrieux
> <loic.dutri...@conabio.gob.mx> wrote:
>> world <- getData(name = 'countries')
>
> The world count
Hi,
Were there any changes made to the ucdavis server, from which getData()
gets its data? I'm trying to download a spatialpolygondataframe of the
world, but it returns a status 403. Can anyone reproduce?
Same thing happens when I try to run the url in the browser or with wget.
Also, is r-forge
Good question, it's rarely necessary, or a good idea, to convert rasters
to dataframes/data.tables for analysis. For pixel wise operations use
raster::calc() or simple raster arithmetics, which inherits from vector
arithmetics.
Cheers,
Loïc
On 19/01/2017 09:35, Zhang Tianyi wrote:
> Dear all,
>
On 13/01/2017 10:59, Miluji Sb wrote:
> Thank you for your reply. This is what I did:
>
> ###
> library(data.table)
> library(raster)
> library(rgdal)
> library(foreign)
>
> elevation_world <- getData('worldclim', var='alt', res=2.5)
>
> # Aggregate Elevation to 1 degree
>
On 28/11/2016 10:26, Francesco Carotenuto via R-sig-Geo wrote:
> Hi everyone,I'm looking for a method to downscale a 250x250 km wide
> resolution altitudemap of the past (about 3 million years ago) to a finer
> resolution. I would the spatialstructure of the downscaled map to resemble
> the
copy is_raster is_vector
> 151 SQLite SQLite / Spatialite TRUE FALSE FALSE TRUE
>
> In that case, you may want to use st_write instead.
>
> On 10/11/16 15:47, Loïc Dutrieux wrote:
>> Hi,
>>
>> Is it possible to write sf objects to spatialite databases
Hi,
Is it possible to write sf objects to spatialite databases? I tried to
adapt the postgis example of the st_write_db function but I get the
following error:
Error in sqliteSendQuery(con, statement, bind.data) :
error in statement: no such function: AddGeometryColumn
Cheers,
Loïc
library(sf)
Hi Lukas,
What does your function do? Can you use the built-in parallel
functionalities of the raster package instead? See ?beginCluster
Cheers,
Loïc
On 26/08/2016 12:23, Lukas Lehnert via R-sig-Geo wrote:
Dear list members,
I tried to process a large GeoTIFF file in a blockwise manner
On 17/08/2016 02:51, Bacou, Melanie wrote:
Maybe create a function that takes a date as input and returns a
meteorological season, and pass this function to `zapply(by=fun)`.
--Mel.
On 8/16/2016 8:38 PM, Thiago V. dos Santos via R-sig-Geo wrote:
Dear all,
I am using the raster package to
Hi Milu,
The code you provided works perfectly on my computer. What doesn't work
in your case? Do you get an error message?
Cheers,
Loïc
On 21/07/2016 22:57, Miluji Sb wrote:
Dear all,
I have the following GDP data by latitude and longitude at 0.5 degree by
0.5 degree.
temp <-
Hi everyone,
I'm struggling to apply a function on multiple RasterBrick with
raster::overlay.
In the dummy example below the idea is that the function takes two
numeric vectors and returns the slope of the linear model. Therefore I
would expect to have a RasterLayer in return with slope for
This works fine for me:
library(raster)
r <- raster(ncol=5,nrow=5)
r[] <- 0
vec <- c(1,1,1,3,4,5,6,7,8,8,8,9)
a <- data.frame(table(vec))
a$vec <- as.numeric(a$vec) # Not very elegant coercion, there must be a
better way
r[a$vec] <- r[a$vec] + a$Freq[a$vec]
Cheers,
Loïc
On 07/11/2016 02:58
.811 0.047 0.866
Cheers,
-- Thiago V. dos Santos
PhD student
Land and Atmospheric Science
University of Minnesota
On Friday, June 3, 2016 4:25 AM, Loïc Dutrieux <loic.dutri...@wur.nl> wrote:
This can also be done with zApply:
library(zoo)
sYM <- zApply(s, by = as.yearmon, sum)
This can also be done with zApply:
library(zoo)
sYM <- zApply(s, by = as.yearmon, sum)
sM <- zApply(sYM, by = months, mean)
Cheers,
Loïc
On 06/03/2016 02:02 AM, Vijay Lulla wrote:
I think the following StackOverflow question has the answer:
Hi Thiago,
calc is not aware of neighbouring pixels in the x,y dimensions, so
functions like focal cannot work.
I found the function below in an old repos of mine. It still seems to
work fine :)
#' Focal for RasterBrick or RasterStack
#'
#' @param x RasterBrick/Stack or character pointing
It's related to a change in R, not in raster. See "DEPRECATED AND
DEFUNCT" related to R 3.3.0 in https://cran.r-project.org/src/base/NEWS
Cheers,
Loïc
On 05/17/2016 06:20 AM, Thiago V. dos Santos via R-sig-Geo wrote:
I also noticed those warnings after the last raster update. Here is one
-Original Message-
From: Frede Aakmann Tøgersen
Sent: 8. april 2016 08:01
To: 'Maggie CY Lau'; r-sig-geo@r-project.org
Subject: RE: proj4string error on data.frame generated from NCEP data
Hi Maggie
Your error message says that there is some coordinates with latitudes
above 90
On 04/08/2016 08:50 AM, Frede Aakmann Tøgersen wrote:
Reposting again again without data. So fetch the data yourself :-(
Yours sincerely / Med venlig hilsen
Frede Aakmann Tøgersen
Specialist, M.Sc., Ph.D.
Plant Performance & Modeling
Technology & Service Solutions
T +45 9730 5135
M +45 2547
it looks like unique combinations in the 3rd dimension is what
unique() returns in the case of a multilayer raster object.
Cheers,
Loïc
ds
On Wed, Mar 02, 2016 at 3:24 AM "Loïc Dutrieux" <">"Loïc Dutrieux"
> wrote:
On 03/02/2016 01:48 AM, Dominik Schne
On 03/02/2016 01:48 AM, Dominik Schneider wrote:
I'd like to summarise a raster using elevation and watershed. I was
originally using extract() with a shape file and then each elevation band
within each polygon but it's very slow. zonal() is much faster and I can
rasterize my polygons to use
Hi MArk,
I believe you're looking for readAll()
Cheers,
Loïc
On 03/01/2016 12:06 PM, Mark R Payne wrote:
Hi,
Once upon a time I remember there being functionality in the raster package
to force it to read the contents of a raster object into memory (admittidly
at your own risk). However, I
Hi Thiago,
A few calc tips inline that you can use together with Tim's suggestion.
On 02/27/2016 07:47 AM, Tim Appelhans wrote:
Dear Thiago,
have a look at the gimms package, available on CRAN. The function of
interest is significantTau().
On 02/23/2016 09:22 PM, Tadaishi Yatabe-Rodriguez wrote:
Hi community,
I have a raster object of a kernel density, where the linear unit is meter,
and when I plot it it gives me very small density values (units per sq
meter, I suppose). I figure that if I multiply it, say by a 1000, it will
Hi Sohrab,
I don't think there is a method for weighted centroids specifically.
What if you get the centroid coordinates of each "block" using
gCentroid() and calculate a weighted average of the coordinates of every
centroid?
See an example below assuming your blocks are a
Hi,
Have you tried gIntersection from the rgeos package.
Given 3 SpatialPolygon* objects you can probably do something like:
sp12 <- gIntersection(sp1, sp2)
sp123 <- gIntersection(sp12, sp3)
Cheers,
Loïc
On 02/18/2016 10:25 AM, John Wasige wrote:
Dear all,
I have three shapefiles that I
Hi Thiago,
Otherwise overlay wrapped in do.call seems to work.
See example below:
Cheers,
Loïc
library(raster)
# Create multiple raterStacks
s1 <- stack(system.file("external/rlogo.grd", package="raster"))
s2 <- s1 * 2
s3 <- s1 * 3
s4 <- s1 * 4
# Create a unnamed list (not sure why it
on
arguments are passed, I think. I don't understand the S4 system that
well. Basically, how would I use a list with names in do.call with
raster::overlay?
On Wed, Dec 2, 2015 at 11:26 AM, Loïc Dutrieux <loic.dutri...@wur.nl> wrote:
Hi Thiago,
Otherwise overlay wrapped in do.call
Hi Thiago,
This should work for aggregating to decades.
library(raster)
library(lubridate)
# Create the date sequence
idx <- seq(as.Date("2010/1/1"), as.Date("2099/12/31"), by = "year")
# Create raster stack and apply the date
r <- raster(ncol=360, nrow=180)
s <- stack(lapply(1:length(idx),
, but
SpatialPolygonsDataFrame() doesn't. (I made a mistake in my initial
example, I want to create a SpatialPolygonsDataFrame, not a
SpatialPointsDataFrame).
Cheers,
Loïc
On 11/19/2015 03:08 PM, Edzer Pebesma wrote:
On 19/11/15 14:37, Loïc Dutrieux wrote:
Hi all,
I'm trying to look at correlation between two
Hi all,
I'm trying to look at correlation between two raster layers, for
different polygons. So I use raster::extract to get all the raster
values for every polygon, do the calculation and feed the output back to
a SpatialPolygonDataFrame.
I got it working, but I have a doubt regarding the
Hi Thiago,
extract() and some dataframe manipulation should do the trick. See
comments in line.
Cheers,
Loïc
On 10/29/2015 09:06 PM, Thiago V. dos Santos wrote:
Hi all,
I am trying to extract temperature values from a raster stack for about 400
municipalities in Brazil. My final goal is
Hi Thiago,
I think zApply should get you there (for each stack independently).
library(zoo)
library(raster)
#Create a rasterStack similar to my data - same dimensions and layer names
r <- raster(ncol=360, nrow=180)
s <- stack(lapply(1:730, function(x) setValues(r,
Hi Victor,
I don't have much experience with beginCluster; however, I have written
a parallel version of raster::calc a little while ago that uses forking.
https://github.com/dutri001/bfastSpatial/blob/master/R/mc.calc.R
calc and overlay are analogue so that it shouldn't be too hard to extend
Hi Victor,
As far as I know there isn't anything yet for dealing with raster that
have more than 3 dimensions in R. The raster package actually has a 4D
class (raterQuad I think) though, but it does not have any methods yet,
so it won't help you much, unless you want to develop the methods
Hi,
Have a look at merge in the sp package.
?sp::merge
Cheers,
Loïc
On 08/18/2015 04:12 AM, Metastate Metastate wrote:
Hi all,
I am starting to learn spatial analysis using R. Do anyone know if the
attribute data in a spatialpolygonsdataframe can contain multiple
observations within the same
package.
Cheers,
Loïc Dutrieux
On 08/17/2015 11:43 AM, Marcelo Kittlein wrote:
Hi all
I want to change a MSS landsat image which has bad georeferencing.
I have a grid of points with correct georeferences and want to use them
to reproject the image to a correct reference system.
Is there some way
Hi John,
Possibly what you're looking for is in the geosphere package
(https://cran.r-project.org/web/packages/geosphere/geosphere.pdf).
Cheers,
Loïc
On 07/31/2015 04:47 PM, john d wrote:
Dear all,
Here's another issue that I've been struggling with and I'd really
appreciate any input.
I
Hi Ned,
dataType with capital T is the function to retrieve the data type of a
raster object. When used as argument to set the type of a file being
written, use datatype= (with lower case t).
Cheers,
Loïc
On 07/08/2015 02:32 AM, Ned Horning wrote:
Hi all -
I am trying to project a raster
=+proj=longlat +datum=WGS84 +no_defs,
dstfile=file.path(dir, 'mosaic_latlong.tif'))
r - raster(file.path(dir, 'mosaic_latlong.tif'))
plot(r)
Hope this helps
Best regards,
--
Loïc Dutrieux
Laboratory of Geo-Information Science and Remote Sensing
Wageningen University
The Netherlands
On 14-04-30
Dear Guillermo,
Yes, there are a few differences among platforms when it comes to rgdal.
You may check that your gdal installation has the GTiff driver.
##
library(rgdal)
gdalDrivers()
In most cases gdal will automatically configure with GTiff though.
Best regards,
--
Loïc Dutrieux
54 matches
Mail list logo