Picon

Maintaining band names in multiband raster objects

Hi all,

I am trying to keep band names from imported netcdf files intact when I export them using the writeRaster()
function from the Raster package, but they are removed and replaced with "Band1, band2, band3, etc."

The .nc files I am importing are located at http://gdo-dcp.ucllnl.org/downscaled_cmip_projections/dcpInterface.html#Welcome

When I import the .nc files, names(raster object) yields band names such as x2006.01.15 (January 15 2006).
These names are interpretable and I would like to preserve them.

Is there a way to specify band names for exported raster objects in R? I have seen posts suggesting it is not
possible, but if they can be read, then they should be able to be written.

Wade A. Wall
US Army ERDC-CERL
P.O. Box 9005
Champaign, IL  61826-9005
1-217-373-4420
Wade.A.Wall <at> usace.army.mil<mailto:Wade.A.Wall <at> usace.army.mil>

	[[alternative HTML version deleted]]
Rachel Chocron | 20 Nov 11:31 2014
Picon
Picon

Re: difference in coeeficient variance calculated from the ANOVA table and from the imat covariance matrix

Just a small correction, I did *not *square root the std. error, I raised
it by power of 2.

2014-11-20 10:22 GMT+02:00 Rachel Chocron <rachel.saf <at> mail.huji.ac.il>:

> Hello!
> I used the function spdep.spautolm to calculate spatial regression:
>
> *text="arsin_species_num_proportion  ~
> I(POINT_X/100000)+I((POINT_X/100000)^2)+I(mean_400m/1000)+I((mean_400m/1000)^2)+I(summer_temperature)+I(sqr_temperature)+I(year_precipitation/1000)+I((year_precipitation/1000)^2)
> +I(RANGE_400m/1000)+I((RANGE_400m/1000)^2)+LandCoverNum_400m+sqr_LandCoverNum_400m"*
>
> *model400mSar <-spautolm(formula = as.formula(text), data = pointsDF,
> listw = weightsb,  family = "SAR", method = "eigen", verbose = TRUE,
> zero.policy = TRUE)*
> *Then I wanted to retrieve the coefficient covariance matrix.*
>
> So I did it using the imat object:
> *model400mSar$fit$imat*
>
> and I compared the variance of each coefficient according to the imat
> object,
> with the variance calculated from the ANOVA table extracted by:
>
> *summary(model400mSar)$Coef*
>
> and by square root the std. error of each coefficient
>
> and the results were different.
>
(Continue reading)

anne.reichmuth | 20 Nov 11:25 2014

Filter raster by threshold using focal and euclidean distance

Dear R users,

I have the issue of defining the right function for my task. For filtering 
an image I have set up a filter matrix eucdis with

refm=matrix(1,nrow=11,ncol=11)
M = dim(refm)[1]
N = dim(refm)[2]
eucdis = matrix(NaN, nrow=11, ncol=11)
for (i in -5:5){
      for (j in -5:5){
            eucdis[i+6,j+6] = 2*(sqrt(sum(abs(0-i)^2+abs(0-j)^2))) 
#euclidean distance of the moving matrix
            eucdis[6,6]=1
            eucdis[eucdis>10]=0
            eucdis[eucdis>0]=1
      }
}

Using the example raster 

f <- system.file("external/test.grd", package="raster")
f
r <- raster(f)

 
I want to filter all values of that raster that have a certain the value, 
say 200 within 10%  (=8) of the eucdis filter matrix

s=focal(x=r,w=eucdis,fun=function(w) {if (length(w[w==2])>=8) {s=1} else 
(Continue reading)

Rachel Chocron | 20 Nov 10:44 2014
Picon
Picon

difference in coeeficient variance calculated from the ANOVA table and from the imat covariance matrix

Hello!
I used the function spdep.spautolm to calculate spatial regression:

*text="arsin_species_num_proportion  ~
I(POINT_X/100000)+I((POINT_X/100000)^2)+I(mean_400m/1000)+I((mean_400m/1000)^2)+I(summer_temperature)+I(sqr_temperature)+I(year_precipitation/1000)+I((year_precipitation/1000)^2)
+I(RANGE_400m/1000)+I((RANGE_400m/1000)^2)+LandCoverNum_400m+sqr_LandCoverNum_400m"*

*model400mSar <-spautolm(formula = as.formula(text), data = pointsDF, listw
= weightsb,  family = "SAR", method = "eigen", verbose = TRUE, zero.policy
= TRUE)*
*Then I wanted to retrieve the coefficient covariance matrix.*

So I did it using the imat object:
*model400mSar$fit$imat*

and I compared the variance of each coefficient according to the imat
object,
with the variance calculated from the ANOVA table extracted by:

*summary(model400mSar)$Coef*

and by square root the std. error of each coefficient

and the results were different.

I also tried the fdHess covarianve matrix but it also gave different
results.

*model400mSar$fdHess*

(Continue reading)

Amit Boshale | 19 Nov 14:37 2014
Picon

runGdal in MODIS package overrides the default in MODISoptions "asIn" pixel size and output a smaller resoultion pixels

Dear MailLister,

I have a problem with runGdal function in MODIS package. At Nadir the resolution should be 250 m. The output
of the following code result are NDVI, EVI, composite day of the year and VI quality Tifs (resolution of 150 m)

> library(MODIS)
> runGdal( job="H12V12", product="MOD13Q1", tileH=12, tileV=12, begin="2000049", end="2000049",
SDSstring="111000000010", outProj="EPSG:4326 ,pixelSize="asIn" )

How to stop the re-sampling and keep the original 250 m resolution?

Any help is appreciate

Amit
> MODISoptions() All suggested packages are installed STORAGE:
_______________
localArcPath : E:/localArcPath/ 
outDirPath   : E:/outDirPath/  DOWNLOAD:
_______________
MODISserverOrder : LPDAAC, LAADS 
dlmethod         : auto 
stubbornness     : high  PROCESSING:
_______________
GDAL           : GDAL 1.10.1, released 2013/08/26 
MRT            : Version 4.1 (March 2011) 
pixelSize      : asIn 
outProj        : asIn 
resamplingType : NN 
dataFormat     : GTiff  DEPENDENCIES:
_______________ NULL
(Continue reading)

163 | 19 Nov 08:47 2014

About rgdal package

Hello!
Now,the package rgdal not work in OS X Yosemite,how to replace?

姜世强
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo <at> r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Nuno Sá | 18 Nov 18:56 2014
Picon

Question on histograms from Raster and RasterVIS packages

Hello!

My aim is to add a "Median" or a "Mean" line to an histogram plot in R.

The problem is the following:

The "hist" function from the raster package uses a maximum of 100 000
values for generating the histogram but allows me to edit the plot, so I
can easily add a line within the plot using abline.

The "histogram" function in rasterVIS uses all my dataset but does not
allow editing of the plot area, so I cannot use the abline function to add
this line (or I do not know how to do it).

If you have an alternative or a solution to work around this, I am all hears

Thank you for any help in advance!
Ciao!
--

-- 

Nuno César de Sá
+351 91 961 90 37

	[[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo <at> r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
(Continue reading)

Felipe Vaca | 17 Nov 16:43 2014
Picon

Waze traffic jams data

Hi all!  Has anybody used Waze data for modelling traffic (
https://www.waze.com/). If so, have you had good/bad experiences? What
advantages/ disadvantages have you found? Further comments appreciated.
Thanks in advance!.

Felipe

	[[alternative HTML version deleted]]
mkborregaard | 17 Nov 11:45 2014
Picon

shifting points in plot window

When I plot a raster image (package raster) and then plot points on top (type
SpatialPoints, package sp) everything aligns well. But if then resize the
window, the alignment disappears, and the points move around. Can I avoid
this behavior? The points and the raster are both defined as lat/long data.
proj4string is "+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs"
for both.

I am sorry for posting a very simple question that I should be able to find
the resolution of, but I have not been able to find this.

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/shifting-points-in-plot-window-tp7587439.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
Steven Ranney | 14 Nov 01:11 2014
Picon

"Merge" shapefiles

All -

I am slowly learning more about spatial data in R.  However, I am still a
relative neophyte.

What I want to do:

I have two shapefiles, shpA has ~401,000 individual polygons with
attributes.  shpB is a subset of those polygons with different attribute
data.  Even though shpB is a subset of those data, there may be multiple
rows for a given polyon, thus giving shpB more total rows (~780,000).

Effectively, I want to merge these two shapefiles.  With two dataFrame
objects in R, I would merge them like

merge(shpA, shpB, by = "APN_LABEL", all = TRUE)

but apparently, this doesn't work with shapefiles.  I have tried

merge(shpA <at> data, shpB <at> data, by = "APN_LABEL", all = TRUE)

which creates a dataFrame of the the two files but drops all of the spatial
geometries.

I've looked into gUnion() as it seems like that may be what I'm looking
for, but I get the following error:

tmp <- gUnion(shpA, shpB)
Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td,
"rgeos_union") :
(Continue reading)

Thiago Cesar Lima Silveira | 12 Nov 17:51 2014
Picon

Predict a gam model with factors to a raster

Hi,

I edited the same question to a better understanding.

I hope someone can help with the issue about a prediction using a model with factors in package ‘raster'.

I would like to do the same that shows this code  from BRT vignette:

    ####Example BRT

    library(dismo)
    data(Anguilla_grids)
    angaus.tc5.lr005 <- gbm.step(data=Anguilla_train, gbm.x = 3:13, gbm.y = 2,family = "bernoulli",
tree.complexity = 5, learning.rate = 0.005, bag.fraction = 0.5)

    Method <- factor('electric', levels = levels(Anguilla_train$Method)) 
    add <- data.frame(Method)
    str(add)

    p <- predict(Anguilla_grids, angaus.tc5.lr005, const=add,
n.trees=angaus.tc5.lr005$gbm.call$best.trees, type="response") 
    p <- mask(p, raster(Anguilla_grids, 1))
    plot(p, main='Angaus - BRT prediction’)

    #####

The code above uses in ‘predict ( )’ an argument “const” to handle with predictors that I have no
rasters, something like a method of capture.

As described in the package raster, "const" is used as a constant for which there is no Raster object for
(Continue reading)


Gmane