For a variety of reasons, I have not been able to do much work on raster
for the past year. And most of my thinking about it, and some work, has
been around a next generation replacement that is simpler in use and much
faster.
But for now, over the coming months, I will make sure that it gets
Works for me like this
library(raster)
r1 <- raster (matrix(ncol=3, data = 1,nrow = 3))
r2 <- raster (matrix(ncol=3, data = 21,nrow = 3))
r3 <- raster (matrix(ncol=3, data = 72,nrow = 3))
rst <- stack(r1, r2, r3)
calc (rst, mfri.test)
Here is an improved version (I think) of mfri.test
The raster way would be:
library(raster)
m <- lapply(c("TZA", "UGA", "GHA"), function(x) getData("GADM",
country=x, level=1))
m <- do.call(bind, m)
Robert
On Sat, Jul 23, 2016 at 4:10 AM, Bacou, Melanie wrote:
> Edzer, Rolf,
> Many thanks for the clarification!
> Just to
Tim, here is an an approach:
library(raster)
b <- brick(system.file("external/rlogo.grd", package="raster"))
p <- SpatialPoints(cbind(sample(77,10), sample(77,10)))
methods <- c("bilinear","simple","bilinear")
k <- methods == "simple"
x1 <- extract(b[[which(k), drop=F]], p)
x2 <-
That still misses the point completely. Geopackage is just another
format out of many. For a map you make in R, it normally should not
matter how the data used may have been stored. Perhaps it would be
more appropriate to call it the SpatialPolygons contest; but I think
that what you have in mind
Here is a solution using optimization
library(raster)
library(rgeos)
set.seed(7)
n <- 4
xy <- cbind(runif(n), runif(n))
f <- function(p) { max(pointDistance(rbind(p), xy, lonlat=FALSE)) }
p <- optim(colMeans(xy), f)
cc <- buffer(SpatialPoints(rbind(p$par)), width=p$value, quadsegs=45)
plot(cc)
Alex,
You should provide a full reproducible example. You can get the
boundaries via raster::getData, and you can create a raster in memory.
Your script should also indicate the packages you use.
To get the area of the polygons, I would do
library(raster)
nga <- getData('GADM', country='NGA',
> library(raster)
> library(spatstat)
( ...)
The following objects are masked from ‘package:raster’:
area, rotate, shift
So either do not load spatstat or call the raster function explicitly
raster::area(x)
Best, Robert
On Wed, Jun 8, 2016 at 12:49 PM, Alex Fitz
This (zapply passing ellipses arguments to stackApply) was fixed, I
think, in the development version. You can try it if you want:
install.packages("raster", repos="http://R-Forge.R-project.org;)
On Sat, Jun 4, 2016 at 1:59 PM, Thiago V. dos Santos via R-sig-Geo
wrote:
For lon/lat coordinates, you can use the circles function in "dismo":
library(dismo)
r <- raster(system.file("external/rlogo.grd", package="raster"))
pts <- data.frame(x=c(17, 42, 85, 70, 20, 53, 26, 84), y=c(28, 73, 38,
56, 0, 29, 63, 22))
c1 <- circles(pts, lonlat=FALSE, d=9, dissolve=FALSE)
Karla,
You can do
library(raster)
slices <- bind(slice1, slice2)
Robert
On Sun, Apr 3, 2016 at 6:53 AM, Karla Shikev wrote:
> Dear all,
>
> This might be a newbie question, so I'd appreciate your patience with this.
>
> I'm obtaining climatic data from worldclim and
Here is a more direct (and safer) way:
library(raster)
set.seed(0)
r <- raster(nrows=22, ncols=20, xmn=-58, xmx=-48, ymn=-33, ymx=-22)
s <- stack(lapply(1:5, function(x) {setValues(r, round(runif(22 * 20,
min=0, max=600), digits=0))}))
intervals <- seq(0, 600, 100)
x <- cut(s, intervals,
How about this:
b <- brick(system.file("external/rlogo.grd", package="raster"))
classified <- b / 255
threshs <- c(.1, .3, .5)
x <- classified < threshs
y <- max(x, na.rm=TRUE)
z <- reclassify(y, cbind(0, NA))
Robert
On Tue, Dec 22, 2015 at 1:57 AM, Mathieu Rajerison
Mark,
Thanks for that clear report. This unexpected order of the layers
returned by stackApply is due to a bug which only reveals itself if
"unique(indices)" is not sorted from 1 to n.
This has been fixed in version 2.5-1 (you can now also use a factor
variable, but that should not matter). This
(x, fobj, ...) :
> 'ncol(x)' and 'nrow(fobj$par$modq)' should be eaqual
>
>
> Any way to circumvent this?
>
> Greetings,
> -- Thiago V. dos Santos
>
> PhD student
> Land and Atmospheric Science
> University of Minnesota
>
>
>
> On Saturday, Octobe
Thiago,
> Therefore, I need to load data as rasters and iterate through all individual
> gridcells to create a data frame containing:
> date1, cell1, cell2, cell3, ..., cell3600
> date2, cell1, cell2, cell3, ..., cell3600
> date3, cell1, cell2, cell3, ..., cell3600...
> date408, cell1, cell2,
Kevin,
I think you can do that like this:
library(raster)
b <- brick(system.file("external/rlogo.grd", package="raster"))
hsv <- overlay(b, fun=rgb2hsv)
Best, Robert
On Fri, Oct 16, 2015 at 3:52 PM, Kevin Wolz wrote:
> Does anyone know if there is any pre-existing
John
Thank you for reporting this. This has now been fixed in raster-devel
install.packages("raster", repos="http://R-Forge.R-project.org;) and
soon on CRAN.
The error (always using the first level on extraction of cell values)
occurred in ncdf files with "levels" as fourth dimension (rather than
Ashraf,
Here is an approach:
# some random points
x <- runif(1)
y <- runif(1)
xy <- cbind(x, y)
# a raster to specficy the extent and resolution
library(raster)
r <- raster(round(extent(xy)), res=0.1)
# find the distance of each point to the center of the cell it falls in
cell <-
Ana Carolina,
You say you are using ascii because:
> i am trying to process a raster image (the one i transformed to ASCII)
> but it is too big to work with it as a raster in R (i am having memory
> problems)...thats why i am trying to see if its simplier to process it
> in ASCII and then bring
Hi Agus,
Your example works for me without error.
Can you update.packages() and try this in a clean workspace? (perhaps
another package is interfering?)
Robert
On Wed, Oct 7, 2015 at 2:44 AM, Agustin Lobo wrote:
> According to the help page of raster::boxplot
> x: Raster*
You can also try this:
f <- function(lai) {
emiss_0 <- 0.95 + (0.01 * lai)
emiss_nb <- 0.97 + (0.0033 * lai)
i <- lai >= 1000
emiss_0[i] <- 0.95
emiss_nb[i] <- 0.98
cbind(emiss_0, emiss_nb)
}
library(raster)
rlai <- raster(ncols=360, nrows=180)
rlai[] <- 1:ncell(rlai)
x
There is no need to 'make a copy of the attribute table' of the sp
object. Instead, you should be able to do:
library(sp)
# From https://www.census.gov/geo/maps-data/data/cbf/cbf_state.html
states <- readOGR(dsn = "./cb_2014_us_state_5m.shp", layer =
"cb_2014_us_state_5m")
states <-
(3,3,4,4,3)),hole = F)), 2_1),
Polygons(list(Polygon(cbind(c(4,4,5,5,3,3,4),c(4,3,3,5,5,4,4)),hole = F)),
2_)))
for (i in 1:4){
plot(p4[i,],col=cols[i],axes=T,xlim=c(0,5),ylim=c(0,5))
}
print(Areas p4:)
print(gArea(p4, byid=TRUE))
On Wed, Aug 12, 2015 at 11:02 AM, Robert J. Hijmans r.hijm
Thomas,
I do not think it is wishful thinking. Au contraire, I think it is how
it should be done. That is, if you start with a longitude/latitude
raster with elevation values, and want slopes (or similar) also in
that coordinate reference system, then this should be the way to go,
as you skip two
geosphere functions makeLine and makePoly do this, but only for
lon/lat, not for planar coordinates.
Robert
On Fri, Aug 7, 2015 at 6:30 AM, Michael Sumner mdsum...@gmail.com wrote:
This is a nice idea with gBuffer, but testing on a simple case shows you
need explicit curvature to get any extra
I would think raster::union(polygons) should get you there.
Robert
On Tue, Aug 11, 2015 at 7:58 AM, Michael Sumner mdsum...@gmail.com wrote:
On Mon, 10 Aug 2015 at 17:52 nevil amos nevil.a...@gmail.com wrote:
I am attempting to combine overlapping polygons in a
single spatialPolygonsDataFrame
Josep,
I take it you have three variables, and want to create a raster for
the third variable, based on the other two, that are also represented
as rasters. If so, you can
# make a three column data.frame
d - data.frame( x=c(23,25,27), y=c(33,34,35) , z=c(0.1,0.2,0.3))
# your two rasters,
Jerome,
rasterize is indeed a bit slow, it is #1 on the list of functions that
need a rewrite for speed. However, I think your assumption is wrong.
You can rasterize all fields in one step, and it is pretty quick for
the example data:
library(raster)
polyg - shapefile(polyg.shp)
grain - 50
nsc -
Jim
You can try
library(raster)
x - crop(roads, polygons)
Robert
On Fri, Jul 10, 2015 at 11:17 AM, Jim Burke javajimbu...@gmail.com wrote:
Clipping a SpatialLinesDataFrame by an envelope SpatialPolygons results
in a bare bones SpatialLines with no @data slot. The out file is a
roads file
Hi Ben,
I would not think this has to do with memory limitations. The error
message suggest that you have a bad file, and, hence, that the problem
is with the software that created the file, or with an interrupted
download.
Robert
On Sat, Jul 4, 2015 at 6:24 PM, Ben Weinstein
Dominik,
The last part of your example does not run. If I understand you well,
this is what you are after (but it all looks good to me):
library(raster)
# raster data with long and lat values
r - raster(xmn=-112.25, xmx=-104.125, ymn=33, ymx=43.75, res=1/240)
lat - init(r, v='y')
lon - init(r,
Andrea,
One small addition. To get all layers (one for each day, in stead of
the single layer you get with 'raster'), use the brick function:
b - brick(tmin_1980.nc4)
Robert
On Fri, Jun 5, 2015 at 4:52 PM, Michael Sumner mdsum...@gmail.com wrote:
Just another short comment below
On Sat, 6
Jean-Luc.
It is as you say, intersect returns Spatial*DataFrame objects whereas
gIntersect does not the DataFrame bits.
This pattern is also true for raster functions aggregate, union,
erase, cover and crop (see section XIV in ?'raster-package') which all
have their analogues in rgeos that they
These would seem to be plausible, and correct, values. I do not think
there is anything wrong NA values. The extreme values are because you
divide by a fraction. How would you expect the results to be
non-negative if you divide by negative values?
Antonio's answer is incorrect, as division with
It works for me. I get:
library(raster)
Loading required package: sp
library(ncdf4)
raster(E:/downloads/201407291200, ncdf=T, varname='DSSF')
class : RasterLayer
dimensions : 651, 1701, 1107351 (nrow, ncol, ncell)
resolution : 1, 1 (x, y)
extent : 0.5, 1701.5, 0.5, 651.5
This suggest that most of the time is spend on reading data from disk.
It could be more efficient to do this in one step.
m - .colMeans(getValues(cmip), nrow(cmip), ncol(cmip), na.rm=FALSE)
I do not think there is much more you can do beyond that --- although
a solid state hard disk could help.
local zip file in Rgui). Just a tiny bit
of additional effort.
Robert
On Tue, May 5, 2015 at 2:20 PM, Michael Sumner mdsum...@gmail.com wrote:
On Wed, 6 May 2015 at 03:28 Robert J. Hijmans r.hijm...@gmail.com wrote:
Even better (renaming not necessary):
x -
raster(E:/downloads/OMI.L2
Even better (renaming not necessary):
x -
raster(E:/downloads/OMI.L2.CloudOMCLDO2Strip200kmAlongCloudSat.2015.05.05.020752Z.v003.he5,
var='Data Fields/ChiSquaredOfFit', ncdf=TRUE)
Best, Robert
On Tue, May 5, 2015 at 10:24 AM, Robert J. Hijmans r.hijm...@gmail.com wrote:
In which case you can
Kristin, I think you can do something like this:
lst - list()
for(i in 1:96) {
Predictors - stack(stackchl[[i]], stacksst[[i]], stackpar[[i]], lat, lon)
names(Predictos) - c('chl', 'sst', 'par', 'lat', 'lon')
lst[[i]] - predict(Predictors, gammodel, na.rm=TRUE, type=response)
}
s -
In which case you can change the extension to '.nc' and do
library(raster)
library(ncdf4)
x -
raster(E:/downloads/OMI.L2.CloudOMCLDO2Strip200kmAlongCloudSat.2015.05.05.020752Z.v003.nc,
var='Data Fields/ChiSquaredOfFit')
Robert
On Tue, May 5, 2015 at 5:28 AM, John Baumgartner
There is also a 'scalebar' function in the raster package (I have not
compared the two)
Robert
On Mon, Apr 27, 2015 at 7:59 AM, Gilles Benjamin Leduc g...@hi.is wrote:
Not to bad hint :p
So From this one, I modified the function to get it work correctly:
If you want to keep the raster cell values, you could do
shapefile(pol2, polygon2.shp)
and use that file.
On Sat, May 2, 2015 at 2:10 PM, sadaoui sadaouimah...@outlook.com wrote:
Thank you Robert Hijmans,
it works with this function ;
shapefile(pol3, polygon3.shp)
but I want to have
Luciano,
The extent you are using to crop is the same as the extent of the
entire extent, so it does not surprise me that there is no change.
Here is an example that works:
library(raster)
library(rgeos)
g - getData('GADM', country='ARG', level=1)
e - extent(-63.6, -55.1, -32.8, -27.6)
x -
Mark,
I had not considered the case where the constant is a factor. I need
to fix that. Here is a script that accomplishes what you want, I think
# known presence and absence points
p - matrix(c(48, 48, 48, 53, 50, 46, 54, 70, 84, 85, 74, 84, 95, 85,
66, 42, 26, 4, 19, 17, 7, 14,
Walter,
Next time, please try to give as a simple self contained example in R
showing what you have done, and where you are stuck.
Here is how you can intersect lines and polygons, keeping their attributes:
library(raster)
library(rgeos)
# example data
p -
Forrest, it seems to me that you can simplify and do
output$AC[i] - length(gIntersection(tmp, ac))
instead of
tmp2 - as.vector(gIntersects(tmp, ac, byid=TRUE))
output$AC[i] - length(tmp[tmp2 == TRUE])
Robert
On Tue, Mar 31, 2015 at 11:56 AM, Forrest Stevens forr...@ufl.edu wrote:
I'm
Walter,
I think that instead of
gIntersects(buffered_projects, census_blocks, byID=TRUE)
you want
library(raster)
x - intersect(buffered_projects, census_blocks, byID=TRUE)
and then Step 3
x$newarea - gArea(x, byid=TRUE)
x$relarea - x$newarea / x$area
Robert
On Fri, Mar 27, 2015
Are these really reasonable reasons? I do not think so, given that the
question had nothing to do with map navigation and the person asking
appears to live in the UK. Moreover, other projections have, or can
have, their units in meters as well (or feet or miles or whatever you
might fancy). UTM
The raster package 'enhances' as.data.frame for SpatialLines* and
SpatialPolygons*. I am not sure why there is also a function for
SpatialPoints* as it does not add anything, except for setting the
names to 'x' and 'y'. Perhaps that is what I did it for, I cannot
remember. But clearly it is not
Sean,
fun.CROP_AGWBC refers to objects that are not defined inside the
function (lm.final and lambda_DV). I assume that this is
intentional and that these represent constants; and that they are
available in your global environment. If so, you need to export these
objects to the cluster nodes.
= testbrick, fun = fun2.CROP_AGWBC)
[1] data should be numeric or logical
attr(,class)
[1] snow-try-error try-error
Error in clusterR(x = testbrick, fun = fun2.CROP_AGWBC) : cluster error
Any other thoughts? Many thanks,
sean
On Mar 17, 2015, at 8:14 AM, Robert J. Hijmans r.hijm...@gmail.com
Karl,
You are using a default RasterLayer which has lon/lat coordinates. In
that case the earth is considered spherical (or similar), not a plane.
The maximum possible distance in longitude is 180 degrees, and the
distance between -120 and 120 is not 240 degrees, but 60+60= 120
degrees, .
To get
The web-service that the function depends on has changed. It should
work with the development version of dismo (version 1.0-8). You should
be able to install it from R-Forge like this:
install.packages(dismo, repos=http://R-Forge.R-project.org;)
Robert
On Sun, Mar 8, 2015 at 11:42 AM, Ahmed
Leo, here is an approach that might work for you:
library(raster)
library(rgdal)
library(rgeos)
library(plyr)
# create some example data.
p - shapefile(system.file(external/lux.shp, package=raster))
p - p[, 'NAME_1']
p - aggregate(p, 'NAME_1', dissolve=FALSE)
# now we have 3 regions, each
Bastien,
This arises from a change in CRAN policy (the requirement to use
requireNamespace instead of require) which somehow creates a
problem for snow::recvOneData. This is all a bit mysterious to me. The
development version uses require again for the snow package such that
things work as they
MIke, I think you can use the 'calc' function for that:
library(raster)
# example data
set.seed(0)
s - stack(system.file(external/rlogo.grd, package=raster))
s - stack(s, s[[1]]*runif(ncell(s)), s[[2]]*runif(ncell(s))/10,
s[[3]]*runif(ncell(s))+10)
# example vector
v - 1:6
x - calc(s,
Jean-Luc
I think you can use the disaggregate method (in package sp) for that.
Robert
On Sat, Jan 31, 2015 at 3:17 AM, Jean-Luc DUPOUEY dupo...@nancy.inra.fr wrote:
I faced the same question recently: how to tranform a multipart polygon layer
into single polygons? Here is a little bit more
It seems there is a problem with my R !
It is for a good reason that you are requested to include your
sessionInfo()
information in messages to this list. But even more important is to
first make sure that you are using the current version of R and the
current versions of all relevant
Hi Pascal,
On Wed, Jan 14, 2015 at 11:52 AM, Pascal Title pti...@umich.edu wrote:
Hi,
I am creating interpolations of global marine diversity via thin plate
splines, using the interpolate() function in the raster package. The
problem I am having is that if I plot the spline interpolation and
P.S. you also need to do:
rf.predict - predict(rgb.rast, rf.mod)
Not
rf.predict - predict(rf.mod, rgb.rast)
Robert
On Tue, Jan 13, 2015 at 6:09 PM, Robert J. Hijmans r.hijm...@gmail.com wrote:
Dave,
The example works if you do
rf.mod - randomForest(color.frame[, c('red','green','blue
David,
I think you could also do this:
library(raster)
a - disaggregate(aggregate(pols))
ids - over(pts, a)
Now you have the aggregated polygons and for each point you know which
polygon it belongs to. Perhaps continue with something like this:
tab - table(ids, as.integer(names(ids)))
tab -
You can also do:
library(raster)
x - sp1 - sp2
y - sp2 - sp1
(equivalent to the erase function)
On Mon, Jan 5, 2015 at 5:43 AM, Roger Bivand roger.biv...@nhh.no wrote:
On Mon, 5 Jan 2015, Edzer Pebesma wrote:
On 01/05/2015 01:53 PM, Roger Bivand wrote:
On Mon, 5 Jan 2015, Edzer Pebesma
Wade,
I do not think you are doing anything wrong. projectRaster gets
confused because of the uncommon longitude coordinates used by climate
models (0 to 360, rather than -180 to 180)
You can use the 'rotate' function to fix that (ignore the warning), or
by setting the extent, and then proceed.
Aseem,
The problem is that you are trying to subset a raster using
latitude/longitude coordinates, while the raster has another CRS.
You can fix this, I think, by assigning the correct crs (you can find
these at http://www.spatialreference.org/)
and then, for example, adjusting your extent, or
From the traceback
8: .readCellsGDAL(x, uniquecells, layers)
it seems to me that the error occurs here:
extract(elev, points)
and that it has nothing to do with the size of the raster. I am not
sure what causes it.
Could you perhaps email me the points?
Thanks, Robert
On Wed, Dec 17, 2014
Peter,
This is a simplified version of your script untested, of course, given you
send you no data):
library(gstat)
library(raster)
dat71 - shapefile(d:/FireDanger/IDW/71stations.shp)
sample.grid - raster(rawsd_71Stations.tif)
#note that there are parameters you need to choose
m -
Juta,
I think you can do something along these lines:
library(raster)
library(rgeos)
x - union(districts, rivers)
a - gArea(x, byid=TRUE)
head(x)
head(a)
or
x - intersect(districts, rivers)
and compare to 'districts'
Robert
On Sun, Nov 30, 2014 at 2:59 PM, Juta Kawalerowicz
Nuno,
The hist function from the raster package uses a maximum of 100 000
values for generating the histogram
That is the default, but you do not have to use that. Did you read the
help file??
?raster::hist
Shows that you can set the maxpixels to any number you want. E.g.
maxpixels=Inf
if
large
rasters (not my case here since it gracefully succeeded), do you know what
is the limit of cells for that failure?
Once again, thank you all for the help!
Best of luck on everything for all!
Nuno
On 19 November 2014 15:14, Robert J. Hijmans r.hijm...@gmail.com wrote:
Nuno,
The hist
Steven,
Please do provide a self-contained example when you ask a question
(see my example below) and try to use correct terms. You are dealing
with SpatialPolygonDataFrame objects (shpA, shpB), these objects are
perhaps derived from shapefiles, but it is not what they are. Also,
providing a
Steven, I believe you can use something like the below
library(raster)
# example data (p, d)
p - shapefile(system.file(external/lux.shp, package=raster))
r - raster(p)
values(r) - 1:ncell(r)
d - as(r, 'SpatialPolygonsDataFrame')
# approach 1
x - intersect(p, d)
# approach 2
y - union(p,d)
y -
I think the below is a solution:
library(raster)
# create some lines
cds1 - rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60))
cds2 - rbind(c(-10,0), c(140,60), c(160,0), c(140,-55))
cds3 - rbind(c(-125,0), c(0,60), c(40,5), c(15,-45))
lns - SpatialLines(list(Lines(list(Line(cds1)), 1),
Ruari, You might be able to use gCrosses together with optim or
another optimization function to find the best route. Below is a very
simple example. For more complex polygons you may need to allow for
several intermediate points (perhaps following the polygon boundary at
times). Unless you want
Chane,
You can use b - brick(array)
# for example
library(raster)
r - raster(ncol=3, nrow=3)
r[] - 1:ncell(r)
s - stack(r,r*2,r*3)
a - as.array(s)
brick(a)
Robert
On Mon, Oct 13, 2014 at 3:00 PM, Chane zoeeeregis...@gmail.com wrote:
Dear list,
I have a multiple dimension array (9 x 9 x 7)
Tyler,
It is probably useful to study the vignette that comes with the raster
package if you have not done so. Also please provide a reproducible
example, if possible, and report the error message you get. Presumably
it is: Error in which.min(harvest_area) : not yet implemented for
large
Brian,
What you can do in a situation like this (clearly a bug; difficult to
reproduce) is with your list x:
y - sapply(x, raster) # remove all valus
save(y, file='mosaic.RData')
and send the file (and explanation of how you get the error) to the
package maintainer (i.e., me, in this case).
Barnabas, ,
You can try something like this:
b - brick(~sst.mnmean.nc, varname=sst)
# loop over species, or combine all species into one data.frame?
mydata - read.csv(~Species one.csv)
extract.mydata - extract(b, mydata[,5:6])
write.csv(extract.mydata, file = Species_one_extracted.csv)
Robert
Joseph,
The errors go away if you add ellipses to your functions, to let the
na.rm pass through (even if you ignore it).
r3 - focal (r,w=matrix.weights,fun = function(x,
...){sample(na.omit(x),size=1)},pad=T,padValue=NA,NAonly=T)
The perhaps surprising error with r3 occurs because when NAonly
Mark and Mike,
Thanks for reporting and clarifying. Fixed, I think, in raster version 2.2-45.
Robert
On Wed, Jul 30, 2014 at 1:13 AM, Michael Sumner mdsum...@gmail.com wrote:
Hello,
Thanks for clarifying, I get that problem too. If I get a chance I'll
have a closer look, but otherwise here's
Erin,
This is not a good approach:
min1 - min(a@data@values,b@data@values)
max1 - max(a@data@values,b@data@values)
Because many RasterLayer objects won't have any values there. It is
another example of why you should not poke inside of S4 objects if
there are functions to do that for you.
This
Frank,
I hope this issue has been solved in the development version.
install.packages(raster, repos=http://R-Forge.R-project.org;)
I would appreciate feedback.
Best, Robert
On Fri, Jul 25, 2014 at 12:40 PM, Frank Davenport
frank.davenp...@gmail.com wrote:
Sorry for the mutliple postings but I
Nevil,
Thanks for reporting and including an example file. The error occurs
when showing a RasterLayer with a RAT table that only has IDs (but no
attributes for these IDs). Did it otherwise affect anything? Either
way, this has been fixed for the next version.
Robert
On Mon, Jul 7, 2014 at 6:52
Damien,
The default setting is to write Real numbers, hence the
1.000 (which is needed to trick GDAL and ESRI to not
assume that the values are all integers when the first numbers have no
decimals).
If you want integers, you can do
writeRaster(r, filename = test.asc,
Helen,
This is a bug, thanks for reporting it. I have fixed it in
(development) version 2.2-43
Robert
On Fri, Aug 29, 2014 at 8:22 AM, Helen Sofaer he...@rams.colostate.edu wrote:
Thanks Pascal,
That's helpful.
I am curious about what happened in the second example, if anyone else
takes a
Gabriele,
I think you can do:
library(raster)
x - distanceFromPoints(ras, villages)
Robert
On Mon, Jul 28, 2014 at 6:56 AM, Gabriele Cozzi gab.co...@gmail.com wrote:
Dear list,
I want to calculate the distance between the centroid of each cell in a
raster ‘ras’ and the closest village
Alex,
Thanks for the clear example. I had not considered that case.
I have added an argument 'updateNA' to the mask function (version
2.2-43) such that you can do:
masked_image - mask(img, msk, updatevalue=2, updateNA=TRUE)
That is, if updateNA is TRUE, NA cells outside the mask are also
library(geosphere)
d - distCosine(df[, 1:2], df[,3:4])
On Thu, Aug 28, 2014 at 8:02 AM, Roger Bivand roger.biv...@nhh.no wrote:
On Thu, 28 Aug 2014, Roger Bivand wrote:
On Thu, 28 Aug 2014, Sarah Goslee wrote:
On Thu, Aug 28, 2014 at 9:32 AM, Michael Sumner mdsum...@gmail.com
wrote:
On
Justin,
The RasterStack approach is fine, but as you show, the layers do not
match. The resolution of NDVIStack is larger than the resolution of
rainStack; it seems that you did not resample the NDVI data correctly.
Robert
On Sat, Aug 30, 2014 at 4:31 AM, Justin Michell jwm...@gmail.com
Dave,
The code now works on both machines. Perhaps it works, but the
results are probably incorrect.
There always a check for non-regularly spaced values, but some cases
slipped through. This has now been fixed.
Robert
On Tue, Aug 19, 2014 at 12:42 PM, Chagaris, Dave
dave.chaga...@myfwc.com
Herry,
This is caused by a call to as.integer(cell numbers) which leads to NAs as
as.integer(ncell(rs)) returns NA
I have removed the call to as.integer in version 2.2-43 and this works now
(and it does not seem to mess up other things).
Thanks for reporting this,
Robert
On Thu, Jul 17, 2014 at
I think this is implemented as the destPoint function in the geosphere
package. Robert
On Mon, Aug 25, 2014 at 1:26 AM, Frede Aakmann Tøgersen
fr...@vestas.com wrote:
Hi
The following is based on http://www.movable-type.co.uk/scripts/latlong.html.
foo - function(origin, bearing, distance){
Carlos,
How about:
x - mean(y)
or
x - calc(y, mean)
Robert
On Fri, Jun 20, 2014 at 2:50 PM, Carlos Carroll
klamathconservat...@gmail.com wrote:
When I use aggregate (package raster) on a multi-layer stack, with a
function such as mean, it returns a second multi-layer stack at the
Jonathan,
I am not sure if this improves things, but it is an alternative route:
a - boundaries(t1, type='outer', classes=TRUE, directions=4)
f1 - freq(c.change, useNA='no')
f2 - freq(mask(c.change, a, maskvalue=0), useNA='no')
f - merge(f1, f2, by='value')
newpatches - f[f[,2] == f[,3]]
Robert
Vero,
Here is a simpler solution:
library(raster)
m - matrix(data = runif(n = 9216*506, min = 0, max = 1000), nrow =
9216, ncol = 506)
b - brick(nrows=96, ncols=96, xmn=-62, xmx=-58, ymn=-49, ymx=-45,
crs=+proj=longlat +datum=WGS84)
b - setValues(b, m)
Robert
On Tue, May 27, 2014 at 12:54 PM,
Zack,
You are using: dataType=INT2U
but it should be: datatype=INT2U # (or any other INT data type)
That fixes it. If the datatype is FLT* (the default), the first value
gets decimals to assure that GDAL and others treat the values as
floats, not integers.
Robert
On Thu, Apr 10, 2014
Jonathan,
You can go back and forth with (raster/sp) functions aggregate and disaggregate
Robert
On Tue, Apr 1, 2014 at 7:50 AM, Jonathan Greenberg j...@illinois.edu wrote:
This is a counter-question to the previous one: how would I go about
taking a multipart SpatialPolygon* and flattening it
Matt,
The x (longitude) coordinates are not valid for lat/lon. It looks like
they are using 0 to 360 instead of -180 to 180 which is what
climate modelers do. For global datasets you can use 'rotate' to fix
this, but that function does not (yet) work for smaller extents. In
this case you can
Aseem provided me with some more info. writeRaster fails when the
'z-value' cannot be converted to an integer. In his case:
head(getZ(ncdata.qtr))
[1] 1950 Q1 1950 Q2 1950 Q3 1950 Q4 1951 Q1 1951 Q2
The work around is to change these values using the setZ function.
This has been fixed (with a
Mark,
You would not be tell from the error message, but the error occurs
because you are using an invalid CRS.
It should be:
proj4string=CRS(+proj=longlat)
instead of this:
proj4string=CRS(longlat)
Robert
On Fri, Feb 21, 2014 at 6:59 AM, Mark Payne markpayneatw...@gmail.com wrote:
Hi,
I
1 - 100 of 507 matches
Mail list logo