Agus Camacho | 23 Apr 18:33 2014
Picon

Find the two nearest locations for each raster cell in a raster layer.

Dear list,

Anyone would have a clue on how to find the two nearest locations included
within a dataframe for each raster cell in a raster layer? I reckon the two
locations might be even included within the raster cell. So it would me
most useful to me to select them as a function of each locations' distance
to each cell's centroid.

Here is a reference dataset, hope it is of help.

long=rnorm(50,10,3)
lat=rnorm(50,8,2)
TM=data.frame(long,lat)
coordinates(TM)=~long+lat
RL=raster(TM)
res(RL)=1

Many thanks in advance,

Agus
--

-- 

Agustín Camacho Guerrero.
Doutor em Zoologia.
Laboratório de Herpetologia, Departamento de Zoologia, Instituto de
Biociências, USP.
Rua do Matão, trav. 14, nº 321, Cidade Universitária,
São Paulo - SP, CEP: 05508-090, Brasil.

	[[alternative HTML version deleted]]
(Continue reading)

Barry Rowlingson | 23 Apr 16:37 2014
Picon

Re: projection of ggmap:get_map() output

On Wed, Apr 23, 2014 at 2:42 PM, Agustin Lobo <alobolistas <at> gmail.com> wrote:

> I think that the output of get_map commands, i.e.
>
> gmap <- get_map(location = rprobextLL <at> bbox, maptype = "hybrid", source
> = "google",
>     crop = FALSE, zoom = 5)
>
> is a raster (not in the sense of an object of the raster package) in
> gepgraphic coordinates
> (epsg:4326), but actually do not see it specified anywhere. Does
> anyone know for sure?
> The alternative would be google PseudoMercator (eps:3857)
>
> The bounding boxes generally just get passed through to the web service
that is providing the tiles - eg for google maps its getting:

http://maps.googleapis.com/maps/api/staticmap?center=29.763284,-95.363271&zoom=10&size=640x640&scale=
2&&maptype=terrain&&&&&&&sensor=false

 - I imagine the web services expect EPSG:4326.

> Also, I'm kind of confused with the get_map help page:
> "Value
> a data.frame with columns latitude, longitude, and fill"
>
> while in R we get:
> > str(gmap)
>  chr [1:1280, 1:1280] "#24392B" "#2E4832" "#3E583B" "#3E583B"
> "#55675F" "#5B6C52" "#656B58" ...
(Continue reading)

Agustin Lobo | 23 Apr 15:42 2014
Picon

projection of ggmap:get_map() output

I think that the output of get_map commands, i.e.

gmap <- get_map(location = rprobextLL <at> bbox, maptype = "hybrid", source
= "google",
    crop = FALSE, zoom = 5)

is a raster (not in the sense of an object of the raster package) in
gepgraphic coordinates
(epsg:4326), but actually do not see it specified anywhere. Does
anyone know for sure?
The alternative would be google PseudoMercator (eps:3857)

Also, I'm kind of confused with the get_map help page:
"Value
a data.frame with columns latitude, longitude, and fill"

while in R we get:
> str(gmap)
 chr [1:1280, 1:1280] "#24392B" "#2E4832" "#3E583B" "#3E583B"
"#55675F" "#5B6C52" "#656B58" ...
 - attr(*, "class")= chr [1:2] "ggmap" "raster"
 - attr(*, "bb")='data.frame':    1 obs. of  4 variables:
  ..$ ll.lat: num -38.2
  ..$ ll.lon: num -73.4
  ..$ ur.lat: num -13.2
  ..$ ur.lon: num -45.3

Agus
Agustin Lobo | 23 Apr 12:41 2014
Picon

Access WMS (and alike) services from R?

Hi!

Is there any project attempting to access remote geoservices such as
WMS in a similar way
as it is done with google maps (i.e. through ggmap:get_map()) ?

Agus
Cyrus Mohammadian | 22 Apr 22:32 2014
Picon

Errors with stConstruct() and STFDF()

Hey everyone, I’m new to R and this forum so I apologize in advance for any ambiguity in my question. What I
want to do is create a spatiotemporal object (class st) out of an esri shapefile with multiple features and
csv file containing data in long format (each row is one observation in space-time). So what I’ve done is
imported the shapefile into r using 

Library(rgdal)
# read in shape files
polygons.shp <- readOGR(“polygon.shp", layer=“polygon”)

# rgdal returns the .prj file associated with the shapefile
print(proj4string(polygon.shp))
[1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

# converted the csv file to a data.frame 
long_format.df <- as.data.frame(long_format.csv)

# converted time variable to proper date format in R
long_format.df$Date <- as.Date(as.character(long_format.df$Date), format= "%Y%m%d”) 

My long format table looks something like this: each location is associated with an ID (that matches the
polygon IDs in my shapefile) has a location name and   specific date and some variables. The variables
fluctuate between temporal and static. For example, X3 and X4 only change over space but not time while X1 
and X2 vary over space and time. The dates are the time at which the space-time variables were collected
(the last day of each month). 

   ID   LocationName    Date 	X1 X2 X3 X4...
	1		California		2013-03-28	1  1  3	 0
	2		Washington	2013-03-28	0  1  9  9
	3		Oregon		2013-03-28	1  3  0	 8
	1		California		2013-04-30	0  4  3	 0
(Continue reading)

Cyrus Mohammadian | 22 Apr 22:32 2014
Picon

errors with stConstruct() and STFDF()

Hey everyone, I’m new to R and this forum so I apologize in advance for any ambiguity in my question. What I
want to do is create a spatiotemporal object (class st) out of an esri shapefile with multiple features and
csv file containing data in long format (each row is one observation in space-time). So what I’ve done is
imported the shapefile into r using 

Library(rgdal)
# read in shape files
polygons.shp <- readOGR(“polygon.shp", layer=“polygon”)

# rgdal returns the .prj file associated with the shapefile
print(proj4string(polygon.shp))
[1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

# converted the csv file to a data.frame 
long_format.df <- as.data.frame(long_format.csv)

# converted time variable to proper date format in R
long_format.df$Date <- as.Date(as.character(long_format.df$Date), format= "%Y%m%d”) 

My long format table looks something like this: each location is associated with an ID (that matches the
polygon IDs in my shapefile) has a location name and   specific date and some variables. The variables
fluctuate between temporal and static. For example, X3 and X4 only change over space but not time while X1 
and X2 vary over space and time. The dates are the time at which the space-time variables were collected
(the last day of each month). 

   ID   LocationName    Date 	X1 X2 X3 X4...
	1		California		2013-03-28	1  1  3	 0
	2		Washington	2013-03-28	0  1  9  9
	3		Oregon		2013-03-28	1  3  0	 8
	1		California		2013-04-30	0  4  3	 0
(Continue reading)

Guillermo E. Ponce-Campos | 22 Apr 20:09 2014
Picon

writeRaster issue

Hi:

Is there any known issue on using writeRaster under Windows vs Linux?

I have been trying to write a rasterlayer as a geotif in a Linux
(centos) machine with no success...

I have this raster layer:

> varTmpRaster
class       : RasterLayer
dimensions  : 720, 1440, 1036800  (nrow, ncol, ncell)
resolution  : 0.25, 0.25  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +ellps=WGS84 +datum=WGS84
+no_defs +towgs84=0,0,0
data source : in memory
names       : layer
values      : 0, 0.9132664  (min, max)

>plot(varTmpRaster)
It shows everything right...

When I run the writeRaster the resulting file only have NA's:

>tf <- writeRaster(varTmpRaster, "testGeoTif", format="GTiff", overwrite=TRUE)
>plot(tf)
Just blank plot...

>length(tf)
(Continue reading)

M.E. | 22 Apr 18:09 2014
Picon
Picon

Package "genalg". Function "rbga.bin"

I am using the "genalg" Package (Function rgba.bin)
(http://cran.r-project.org/web/packages/genalg/genalg.pdf) for some
calculations in R. For me it isn't very clear, how to set the
"zeroToOneRatio" for the "rbga.bin" function. Does anybody has some
suggestions for me? 
Many Thanks in advance!!

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Package-genalg-Function-rbga-bin-tp7586247.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
Hodgess, Erin | 21 Apr 17:05 2014

time units with plotKML

Hello everyone!

I'm trying to use the plotKML on an STFDF object.

I used the krigeST function and all was well.

But when I try to produce the kml plot, I get the following error:

Plotting the first variable on the list
KML file opened for writing...
Error in UseMethod("units<-") :
  no applicable method for 'units<-' applied to an object of class "c('POSIXct', 'POSIXt')"
>

Does this look familiar, please?  I'm using daily data, so it should be ok.

Thanks,
Erin

	[[alternative HTML version deleted]]
Dan Olsen | 20 Apr 07:56 2014
Picon

BRB AdehabitatLT help

Hello all,

  I would like to like to create UDs of each animal (killer whales) using
biased Brownian Bridge (adehabitatLT), then stack all the rasters to then
make UDs of the whole population, then compare volume overlap of subsets of
the population.

  Is this sequence correct?   Does anyone have any sample code that might
help with a section?  I am fairly new to R, but can adapt code.

Import data
Remove duplicate time entries
Change projection from WGS84 to AlaskaAlbers 3338
Create trajectory
Create UDs
Calculate UD areas, contours
# I have everything running until here

Create grid (asc)
Rasterize UDs
Stack rasters for individual tags
Create UDs from raster stacks for population subsets.
Use volume overlap to look at subset habitat use overlap

Thanks!

Dan

ps.  The following code seems to work so far with my data.  Any
recommendations are welcome!
(Continue reading)

Barry Rowlingson | 19 Apr 10:59 2014
Picon

Re: raster plotting problem

Try:

  plot(raster("flename"), useRaster=FALSE)

Its because the remote server supports raster graphics operations but the
client you are using to connect to the server (Windows Remote Session or
some RDP client) doesn't.

On Fri, Apr 18, 2014 at 12:49 PM, Ziyu Ma <paul.ziyu.ma <at> gmail.com> wrote:

>  Dear R-sig-geo,
>
>  I was having a problem of not being able to plot a raster, simply by:
>
>   plot(raster("somefilename"))
>
>  but the plot is blank (like the attached file). There was no error
> message, and apparently the plot function was reading the raster data
> because the scale was plotted.
>
>  I tried to plot several different data sets, even one raster generated
> from a matrix of all random numbers. They all turned out to be blank.
>
>  This is not my first time encountering this "blank raster plot" problem.
> I've seen this on other cases while working as a TA. It appeared on few
> computers while using completely the same data and codes as the others in
> the class.
>
>  I encountered this problem myself today while trying to remotely work on
> the lab's GIS server. The server was running on Windows 7 with an older
(Continue reading)


Gmane