jcoyle | 28 Feb 17:32 2015
Picon

Create listw or nb object from binary edge matrix

I am trying to create an nb or listw object for use with spdep functions from
a binary matrix with 1 indicating that two 'regions' are neighbors. However,
the following code does not produce a neighbors list as I think it should
after reading  this previous post
<https://stat.ethz.ch/pipermail/r-sig-geo/2009-February/005070.html>  :mat =
matrix(0, 4, 4)mat[1,2] = 1mat[2,1] = 1mat[3,4] = 1mat[4,3] = 1lw =
mat2listw(mat)lw$neighborsWhat am I doing wrong?Thanks!Jes

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Create-listw-or-nb-object-from-binary-edge-matrix-tp7587849.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
Cyrus Mohammadian | 28 Feb 09:45 2015
Picon

still having problems installing rgdal on osx mavericks

Hey Everyone,

I’m having problems installing and loading rgal on mavericks. I know there is a lot written on the net
about it but I have not been able to successfully install the package. I downloaded the .tgz file and I
installed the package from source but every time I attempt to load the library my R workspace crashes. Any
help would be fantastic. If upgrading to Yosemite solves the problem I’m willing to upgrade but only if I
can be sure. Thanks everyone!

Best,

Cyrus Mohammadian
Bastien.Ferland-Raymond | 27 Feb 15:26 2015
Picon

Problem with using multicore resample in Raster package

Dear all,

I wrote a code last year that was running well.  I've retried the same code this month and it's not working
anymore.  The problem arise from using cluster to do resampling in the raster package on multiple threads. 
I've tried on two computers, both have the problem.

Here is a reproducible example :

###

library(raster)
#Loading required package: sp
 ## prepare the test rasters
r1 <- raster(nrows=1000, ncols=1000, xmn=0, xmx=1000)
set.seed(123)
values(r1) <- round(rnorm(1000000,100,20))
r2 <- raster(nrows=1000, ncols=1000, xmn=.2, xmx=1000.2)
 ## testing resample without multicore
resamp.single <- resample(r1, r2)
 ## testing resample with multicore
beginCluster(11)
#Loading required namespace: snow
resamp.multi <- resample(r1, r2)
#Using cluster with 11 nodes
#Error in UseMethod("recvOneData") :
# no applicable method for 'recvOneData' applied to an object of class "c('SOCKcluster', 'cluster')"
endCluster()
#Error in UseMethod("stopCluster") :
# no applicable method for 'stopCluster' applied to an object of class "c('SOCKcluster', 'cluster')"
 sessionInfo()
(Continue reading)

Zilefac Elvis via R-sig-Geo | 26 Feb 22:43 2015

Visualize negative/poitive data using levelplot in R

Hello,
I need your insigts on how to visualize/map data that spans negative and positive values. I have 6 rasters
which have been stacked together (s) and will subsequently be plotted via levelplotfunction in R.
Below are the max and min values for each raster.39.2887, 53.09207  (min, max) # r1

-32.4956, -27.25534  (min, max)# r2

-14.37683, -11.37742  (min, max)# r3

 9.512934, 13.60197  (min, max)# r4

-4.993901, -1.851784  (min, max)# r5

-8.190711, -5.104764  (min, max)# r6At the moment, I am able to produce my map via:library(raster)
library(rasterVis)
library(colorRamp)
    s <- stack(r1,r2,r3,r4,r5,r6)
    themes2 <- colorRampPalette(c("darkred", "red3", "orange", "yellow", "lightskyblue",
"royalblue3", "darkblue"))(19)
    myat =unique(seq(floor(min(s)) ,ceiling(max(s)),length.out=20))
    myat=round(myat,digits = 0)#     
    #themes <- rasterTheme(region=rev(brewer.pal(11,'RdYlBu')))
    myColorkey <- list(at=myat,space = "right",labels=list(cex=1,at=myat))

    if (dev.cur() == 1) x11(width=18,height=18)

    levelplot(s, layout=c(3, 2), index.cond=list(c(1, 3, 5, 2, 4, 6)),col.regions=themes2,  
              margin=FALSE,xlab=NULL,at =unique(seq(floor(min(s)) ,ceiling(max(s)),length.out=20)),
              par.strip.text=list(cex=0),colorkey=myColorkey,scales=list(alternating=F))NOTE: I need a
single colorkeyProblem: rasters with smaller vs larger values get suppressed and the information on the
(Continue reading)

Paul Woods | 26 Feb 14:50 2015
Picon
Picon

Integrating a trajectory

Hi everyone,

Perhaps this is a little removed from strict geography, but you seem to be a clever bunch.

I’m looking for a method in R or Python to integrate along a trajectory, through a regular grid. So,
imagine an aeroplane flying from London to New York… I want to calculate how much material in the
atmosphere the aeroplane comes into contact with. I have a regular grid with the density of the atmosphere
at each lon, lat, altitude grid point, but of course the plane does not travel along grid lines, so some
interpolation would be needed. Any ideas on where to start in calculating how much atmosphere a plane
would scoop up from London to New York?

Thanks,

Paul.
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo <at> r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Mathieu Rajerison | 26 Feb 14:24 2015
Picon

Generate N points along a SpatialLines object

Hi List,

I try to generate N points along a a continental coastline with
spatstat::pointsOnLines

If I give a small number of points (like N = 10), then 931 points are
returned. That's because 931 segments are generated from my initial
coastline data.

I'd like to know how to generate exactly N points, equally spaced, from a
SpatialLines object, without GRASS, nor QGIS

Thanks in advance for any answer,

Mathieu

	[[alternative HTML version deleted]]
Yuster Ronoh | 26 Feb 07:35 2015
Picon

Same code line for graph with different output messages

Dear r-geo members
Iam using example from creating maps with R by Robin Lovelace example  and
 I tried to plot map of active sport participant using the two codes, line
one gave me the error messages and line two gave me plot of active sport
partcipation in londe
1.plot(lnd_sport[lnd_sport$Partic_per > 25, ])
2.plot(lnd_sport[lnd_sport$Partic_Per > 25, ])
R-output
code for line 1
 > plot(lnd_sport[lnd_sport$Partic_per > 25, ])
Error in plot(lnd_sport[lnd_sport$Partic_per > 25, ]) :
  error in evaluating the argument 'x' in selecting a method for function
'plot': Error in if (is.numeric(i) && i < 0) { :
  missing value where TRUE/FALSE needed
code for line 2
 > plot(lnd_sport[lnd_sport$Partic_Per > 25, ]) # plotted actual graph
could some one explain what is happening

	[[alternative HTML version deleted]]
Gregovich, Dave P (DFG | 25 Feb 22:50 2015

Replacing values in large rasters using conditional statements


Hello,
I often replace values in a raster based on values of another raster, like this:

n.row <- n.col <- 100
a <-raster(nrows=n.row,ncols=n.col)
b <- a
a[]<-rnorm(ncell(a))
b[]<-rnorm(ncell(b))
a[b > 0] <- 1

What would analogous code be that works for large rasters without running into vector size allocation problems?

Thanks kindly for any time you spend!

Dave.
__________________________________
Dave Gregovich
Research Analyst
Alaska Department of Fish and Game
Wildlife Conservation Division
Douglas, AK 99821
(907) 465-4291
dave.gregovich <at> alaska.gov
__________________________________

	[[alternative HTML version deleted]]
Wesley Roberts | 25 Feb 07:35 2015
Picon

Re: Generate a multi-ring buffer - Windows 8 - R 3.1.1

Many thanks Robert,

Your suggestions worked a treat.

Wesley

On Wed, Feb 25, 2015 at 6:37 AM, Robert J. Hijmans <r.hijmans <at> gmail.com>
wrote:

> Wesley,
>
> Your code should work if you change:
>
>   row.names(x.2 <at> data)<-i
> to
>   row.names(x.2) <- as.character(i)
>
>
> Alternatively you can use raster::bind
> library(raster)
> buff.out <- do.call(bind, buff.list)
>
> Which also allows you to use a much simplified loop:
>
> buff.list <- list()
> for (i in 1:18) {
>     buff.list[i] <- gBuffer(p,width=i*10)
> }
> buff.out <- do.call(bind,buff.list)
>
(Continue reading)

Sascha | 24 Feb 21:29 2015
Picon
Picon

How can I set an xts Attribut to STFDF?

Hello,

I'm using spacetime in R. This is my STFDF: PM10.02:

str(PM10.02)
Formal class 'STFDF' [package "spacetime"] with 4 slots
  .. <at>  data   :'data.frame':	129210 obs. of  1 variable:
  .. ..$ values: num [1:129210] NA 18 21 26 36 17 14 15 20 NA ...
  .. <at>  sp     :Formal class 'SpatialPointsDataFrame' [package "sp"] with 5
slots
  .. .. .. <at>  data       :'data.frame':	354 obs. of  4 variables:
  .. .. .. ..$ names: Factor w/ 354 levels "DEBB001","DEBB006",..: 1 2 3 4 5
6 7 8 9 10 ...
  .. .. .. ..$ code : Factor w/ 354 levels "DEBB001","DEBB006",..: 1 2 3 4 5
6 7 8 9 10 ...
  .. .. .. ..$ name : Factor w/ 354 levels "\x8a\xbehringen",..: 58 67 94
251 289 292 343 285 253 153 ...
  .. .. .. ..$ area : Factor w/ 3 levels "rural","suburban",..: 2 3 2 3 3 2
2 2 2 2 ...
  .. .. .. <at>  coords.nrs : int [1:2] 5 6
  .. .. .. <at>  coords     : num [1:354, 1:2] 14.1 14.3 14.6 13.1 14 ...
  .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. ..$ : NULL
  .. .. .. .. ..$ : chr [1:2] "x" "y"
  .. .. .. <at>  bbox       : num [1:2, 1:2] 6.38 47.55 14.99 54.92
  .. .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. .. ..$ : chr [1:2] "x" "y"
  .. .. .. .. ..$ : chr [1:2] "min" "max"
  .. .. .. <at>  proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. .. .. .. <at>  projargs: chr "+proj=longlat +datum=WGS84 +ellps=WGS84
(Continue reading)

Guido Schulz | 24 Feb 19:41 2015
Picon
Picon

Modeling SAR Origin-Destination flows with R?

Hi there,

I would like to model SAR Origin-Destination (migration) flows using the
model specification proposed by LeSage & Pace
(http://www4.fe.uc.pt/spatial/doc/lecture7.pdf, page8, equation [10]):

y = rho1*W_o*y + rho2*W_d*y + rho3*W_w*y + alpha*iota + X_d*beta_d +
X_o*beta_o + D*gamma + epsilon

Where "o" stands for origin and "d" for destination.

What is crucial about the model is, that we have the spatially lagged
responses of the origin AND the destination, as well as the spatially
lagged predictors of the origin AND the destination in the SAR equation.
-----------------------------------------
Do you have any ideas how to implement such a model in R?

Is there a way to specify a spdep::lagsarlm in that way or should I use
a different package/function? As far as I can see there spdep::lagsarlm
allows only for ONE "listw".

Best & thx,

Guido

Gmane