Re: [R-sig-Geo] Distance between two points

2012-12-07 Thread Michael Sumner
Reproject the points to the coordinate system of thr grid, do the overlay
then copy the attributes back. No need to warp a raster just for over(lay).



On Saturday, December 8, 2012, Roger Bivand wrote:

> On Fri, 7 Dec 2012, Sarah Goslee wrote:
>
>  Hi Simon,
>>
>> I've copied this back to the list, as is encouraged.
>>
>> On Fri, Dec 7, 2012 at 9:41 AM, O'Hanlon, Simon J
>>  wrote:
>>
>>> Hi Sarah, thank you.
>>>
>>> My data points are located in West Africa, so I think a good projection
>>> would be Lambert Azimuthal Equal Area.
>>>
>>> This does raise one more question for me. I also have some raster data
>>> that I wish to use as covariates which is also in geographic coordinates.
>>> If I try to simply reproject a raster, I think it would screw up the
>>> regular grid. Does it make sense if I convert the lat-long raster to a
>>> SpatialPointsDataFrame and transform this to LAEA so I could then create a
>>> grid in the desired planar coordinates from scratch and use over() to
>>> assign values from the reprojected spatial points onto the raster?
>>>
>>
>> A reprojected raster is still a raster, and thus a regular grid. Or am
>> I missing something?
>>
>
> Yes, a warped raster is a raster, but a reprojected raster will in general
> be a set of irregular points. So resampling is invoved one way or the
> other. Whether one queries the raster as-is with spatial points, and then
> projects the output, or warps the raster doing spatial query with projected
> points will depend a bit on the support(s) of the data sets. Maybe see:
> ?projectRaster in raster for warping.
>
> Roger
>
>
>> Sarah
>>
>>
>>  Thanks again for your help.
>>>
>>> Cheers,
>>>
>>> Simon
>>>
>>> -Original Message-
>>> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
>>> Sent: 07 December 2012 14:18
>>> To: O'Hanlon, Simon J
>>> Cc: r-sig-geo@r-project.org
>>> Subject: Re: [R-sig-Geo] Distance between two points
>>>
>>> Precisely. You should use great-circle distances with lat-lon
>>> coordinates, rather than Euclidean distance, because the actual length
>>> varies with position on the globe.
>>>
>>> Converting to UTM or something similar is one solution if your points
>>> are not too far apart.
>>>
>>> There are many other R solutions: searching for "great circle distance"
>>> at rseek.org will get you quite a list.
>>>
>>> Sarah
>>>
>>> On Fri, Dec 7, 2012 at 8:10 AM, O'Hanlon, Simon J <
>>> simon.ohan...@imperial.ac.uk> wrote:
>>>
 Dear list,
 I am using the package geoRglm to do some predictive mapping. There is
 a function that calculates the distance between observed data points and
 the prediction locations using a .C call to a function which eventually
 calculates the length of the hypotenuse between one location and the other
 given the vertical and horizontal separation distance of those points.

 My question is, is this method of distance-finding incompatible with
 long-lat style coordinates? Should I first transform my data and prediction
 locations into something where the unit of measurement is in metres rather
 than decimal degrees?

 Many thanks,

 Simon


>>
>> --
>> Sarah Goslee
>> http://www.**functionaldiversity.org 
>>
>> __**_
>> R-sig-Geo mailing list
>> R-sig-Geo@r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo
>>
>>
> --
> Roger Bivand
> Department of Economics, NHH Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: roger.biv...@nhh.no
>
> __**_
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo
>


-- 
Michael Sumner
Hobart, Australia
e-mail: mdsum...@gmail.com

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] trying to pass a grid to kernelkc

2012-12-07 Thread Corrie Curtice
Hi folks. 

I have a question about how to supply a grid to the kernelkc method in
adehabitatHR.  I've clipped my area and saved as an ASC file from ArcGIS.
The kernelkc help says the parameter should be of class asc. I've read it in
as both an asc and a SpatialGridDataFrame, but get an error from kernelkc
regardless of which one I use.

ASC:

library(SDMTools)
> antpen_asc <- read.asc('shapefiles/antpen500m.asc')
> class(antpen_asc)
[1] "asc"
> uu <- kernelkc(t699_b2, h = c(5000,5000,5*3600*24),grid=antpen_asc, tcalc=
as.POSIXct("2012-01-27"))
Error in `gridded<-`(`*tmp*`, value = TRUE) :
  gridded<- only works for SpatialPoints[DataFrame] or
SpatialGrid[DataFrame]
 
SGDF:

> antpen_sgdf <- read.asciigrid('shapefiles/antpen500m.asc', as.image = FALSE,
+proj4string = CRS('+proj=utm +zone=20 +south
+datum=WGS84'))
> class(antpen_sgdf)
[1] "SpatialGridDataFrame"
attr(,"package")
[1] "sp"
> uu <- kernelkc(t699_b2, h = c(5000,5000,5*3600*24),grid=antpen_sgdf,  tcalc=
as.POSIXct("2012-01-27"))
Error in as.vector(gr) : no method for coercing this S4 class to a vector

The vignette example uses a SpatialPixelsDataFrame for the kernelUD method
but doesn't show an example with kernelkc.  I made an ltraj out of the data
and tried to pass in the supplied map, but I get the same error as when
using a SGDF.  Below is code that should reproduce what I'm seeing.

> data(puechabonsp)
> # regular kernel w/ grid
> kudm <- kernelUD(puechabonsp$relocs[,1], grid=puechabonsp$map)
> 
> # Try product kernel w/ grid. Need to get ltraj
> class(puechabonsp$relocs)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"
> puechData<-puechabonsp$relocs@data
> puechData$X <- puechabonsp$relocs@coords[,1]
> puechData$Y <- puechabonsp$relocs@coords[,2]
> puechTraj 
<-as.ltraj(cbind(puechData$X,puechData$Y),as.POSIXct(strptime(puechData$Date,for
mat="%y%m%d")), id=puechData$Name)
> uu <- kernelkc(puechTraj, h = c(1000,1000,72*3600), tcalc=
as.POSIXct("1993-07-20"), grid=puechabonsp$map)
Error in as.vector(gr) : no method for coercing this S4 class to a vector


Here's my session info...

> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C/en_US.UTF-8/C/C/C/C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
 [1] SDMTools_1.1-9 adehabitatHR_0.3   adehabitatLT_0.3.4
CircStats_0.2-4boot_1.3-2 MASS_7.3-13
 [7] adehabitatMA_0.3.2 ade4_1.4-17tripack_1.3-4  gpclib_1.5-1
sp_0.9-84 

loaded via a namespace (and not attached):
[1] grid_2.13.1 lattice_0.19-30 tools_2.13.1

Am I just too out of date on something(s), or am I completing missing
something obvious in how I should be proceeding?

Thanks for any guidance.

--corrie

---
Corrie Curtice
Research Analyst
Marine Geospatial Ecology Lab
Nicholas School of the Environment, Duke University
http://mgel.env.duke.edu
em: corrie.curt...@duke.edu




[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Distance between two points

2012-12-07 Thread Roger Bivand

On Fri, 7 Dec 2012, Sarah Goslee wrote:


Hi Simon,

I've copied this back to the list, as is encouraged.

On Fri, Dec 7, 2012 at 9:41 AM, O'Hanlon, Simon J
 wrote:

Hi Sarah, thank you.

My data points are located in West Africa, so I think a good projection 
would be Lambert Azimuthal Equal Area.


This does raise one more question for me. I also have some raster data 
that I wish to use as covariates which is also in geographic 
coordinates. If I try to simply reproject a raster, I think it would 
screw up the regular grid. Does it make sense if I convert the lat-long 
raster to a SpatialPointsDataFrame and transform this to LAEA so I 
could then create a grid in the desired planar coordinates from scratch 
and use over() to assign values from the reprojected spatial points 
onto the raster?


A reprojected raster is still a raster, and thus a regular grid. Or am
I missing something?


Yes, a warped raster is a raster, but a reprojected raster will in general 
be a set of irregular points. So resampling is invoved one way or the 
other. Whether one queries the raster as-is with spatial points, and then 
projects the output, or warps the raster doing spatial query with 
projected points will depend a bit on the support(s) of the data sets. 
Maybe see: ?projectRaster in raster for warping.


Roger



Sarah



Thanks again for your help.

Cheers,

Simon

-Original Message-
From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
Sent: 07 December 2012 14:18
To: O'Hanlon, Simon J
Cc: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] Distance between two points

Precisely. You should use great-circle distances with lat-lon coordinates, 
rather than Euclidean distance, because the actual length varies with position 
on the globe.

Converting to UTM or something similar is one solution if your points are not 
too far apart.

There are many other R solutions: searching for "great circle distance" at 
rseek.org will get you quite a list.

Sarah

On Fri, Dec 7, 2012 at 8:10 AM, O'Hanlon, Simon J 
 wrote:

Dear list,
I am using the package geoRglm to do some predictive mapping. There is a 
function that calculates the distance between observed data points and the 
prediction locations using a .C call to a function which eventually calculates 
the length of the hypotenuse between one location and the other given the 
vertical and horizontal separation distance of those points.

My question is, is this method of distance-finding incompatible with long-lat 
style coordinates? Should I first transform my data and prediction locations 
into something where the unit of measurement is in metres rather than decimal 
degrees?

Many thanks,

Simon




--
Sarah Goslee
http://www.functionaldiversity.org

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Distance between two points

2012-12-07 Thread Sarah Goslee
Hi Simon,

I've copied this back to the list, as is encouraged.

On Fri, Dec 7, 2012 at 9:41 AM, O'Hanlon, Simon J
 wrote:
> Hi Sarah, thank you.
>
> My data points are located in West Africa, so I think a good projection would 
> be Lambert Azimuthal Equal Area.
>
> This does raise one more question for me. I also have some raster data that I 
> wish to use as covariates which is also in geographic coordinates. If I try 
> to simply reproject a raster, I think it would screw up the regular grid. 
> Does it make sense if I convert the lat-long raster to a 
> SpatialPointsDataFrame and transform this to LAEA so I could then create a 
> grid in the desired planar coordinates from scratch and use over() to assign 
> values from the reprojected spatial points onto the raster?

A reprojected raster is still a raster, and thus a regular grid. Or am
I missing something?

Sarah


> Thanks again for your help.
>
> Cheers,
>
> Simon
>
> -Original Message-
> From: Sarah Goslee [mailto:sarah.gos...@gmail.com]
> Sent: 07 December 2012 14:18
> To: O'Hanlon, Simon J
> Cc: r-sig-geo@r-project.org
> Subject: Re: [R-sig-Geo] Distance between two points
>
> Precisely. You should use great-circle distances with lat-lon coordinates, 
> rather than Euclidean distance, because the actual length varies with 
> position on the globe.
>
> Converting to UTM or something similar is one solution if your points are not 
> too far apart.
>
> There are many other R solutions: searching for "great circle distance" at 
> rseek.org will get you quite a list.
>
> Sarah
>
> On Fri, Dec 7, 2012 at 8:10 AM, O'Hanlon, Simon J 
>  wrote:
>> Dear list,
>> I am using the package geoRglm to do some predictive mapping. There is a 
>> function that calculates the distance between observed data points and the 
>> prediction locations using a .C call to a function which eventually 
>> calculates the length of the hypotenuse between one location and the other 
>> given the vertical and horizontal separation distance of those points.
>>
>> My question is, is this method of distance-finding incompatible with 
>> long-lat style coordinates? Should I first transform my data and prediction 
>> locations into something where the unit of measurement is in metres rather 
>> than decimal degrees?
>>
>> Many thanks,
>>
>> Simon
>>


--
Sarah Goslee
http://www.functionaldiversity.org

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] Distance between two points

2012-12-07 Thread Sarah Goslee
Precisely. You should use great-circle distances with lat-lon
coordinates, rather than Euclidean distance, because the actual length
varies with position on the globe.

Converting to UTM or something similar is one solution if your points
are not too far apart.

There are many other R solutions: searching for "great circle
distance" at rseek.org will get you quite a list.

Sarah

On Fri, Dec 7, 2012 at 8:10 AM, O'Hanlon, Simon J
 wrote:
> Dear list,
> I am using the package geoRglm to do some predictive mapping. There is a 
> function that calculates the distance between observed data points and the 
> prediction locations using a .C call to a function which eventually 
> calculates the length of the hypotenuse between one location and the other 
> given the vertical and horizontal separation distance of those points.
>
> My question is, is this method of distance-finding incompatible with long-lat 
> style coordinates? Should I first transform my data and prediction locations 
> into something where the unit of measurement is in metres rather than decimal 
> degrees?
>
> Many thanks,
>
> Simon
>
--
Sarah Goslee
http://www.functionaldiversity.org

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


[R-sig-Geo] Distance between two points

2012-12-07 Thread O'Hanlon, Simon J
Dear list,
I am using the package geoRglm to do some predictive mapping. There is a 
function that calculates the distance between observed data points and the 
prediction locations using a .C call to a function which eventually calculates 
the length of the hypotenuse between one location and the other given the 
vertical and horizontal separation distance of those points.

My question is, is this method of distance-finding incompatible with long-lat 
style coordinates? Should I first transform my data and prediction locations 
into something where the unit of measurement is in metres rather than decimal 
degrees?

Many thanks,

Simon

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] installing rgdal on Debian

2012-12-07 Thread Raffaele Morelli
2012/12/7 Eduardo Bieñkowski 

> Hi all.
> For those who had the same problem:
> The solution was:
> In Ubuntu / Debian
> sudo apt-get install-dev libgdal1
> sudo apt-get install-dev libproj
>
> Eduardo
>
>
"install-dev" it's not an apt-get option...

He's on Debian and according to the release he's using he needs libgdal-dev
(testing/wheezy) or libgdal1-dev (stable/squeeze)

Keep in mind that ubuntu it's debian based but it's not Debian...

regards
-r

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] installing rgdal on Debian

2012-12-07 Thread Joseph Bechara
Hello, 

 I'm not able to use the crop function for a raster Stack. I read that this
problem was corrected in the CRAN version v 2.0-08.
But it still not working for me also I modified the CRAN.
Can somebody advise me.

JOSEPH BECHARA
Mapping Specialist
8th floor, Olivetti building, Mathaf, Beirut, Lebanon
Tel. : +961 (1) 426630-1-2
Fax: +961 (1) 426631 
Mail: jbech...@lri-lb.org
www.lri-lb.org


-Original Message-
From: r-sig-geo-boun...@r-project.org
[mailto:r-sig-geo-boun...@r-project.org] On Behalf Of Eduardo Bieñkowski
Sent: Friday, December 07, 2012 12:43 PM
To: Hodgess, Erin
Cc: r-sig-geo@r-project.org
Subject: Re: [R-sig-Geo] installing rgdal on Debian

Hi all.
For those who had the same problem:
The solution was:
In Ubuntu / Debian
sudo apt-get install-dev libgdal1
sudo apt-get install-dev libproj

Eduardo


2012/12/6 Hodgess, Erin 

> Hello!
>
> I'm trying to install rgdal on Debian.
>
> I keep getting the  "checking for gdal.h...no" error.
>
> I have updated libgdal1.dev.
>
> I also put the /usr/include and /usr/include/gdal in my PATH.
>
> Any ideas as to what is wrong, please?
>
> I have a feeling that it is something very simple.
>
> Thanks,
> Erin
> PS on R-2.15.2
>
>
> Erin M. Hodgess, Ph.D.
> Associate Professor
> Department of Computer and Mathematical Sciences University of Houston 
> - Downtown
> mailto: hodge...@uhd.edu
>
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



--
Eduardo

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


Re: [R-sig-Geo] installing rgdal on Debian

2012-12-07 Thread Eduardo Bieñkowski
Hi all.
For those who had the same problem:
The solution was:
In Ubuntu / Debian
sudo apt-get install-dev libgdal1
sudo apt-get install-dev libproj

Eduardo


2012/12/6 Hodgess, Erin 

> Hello!
>
> I'm trying to install rgdal on Debian.
>
> I keep getting the  "checking for gdal.h...no" error.
>
> I have updated libgdal1.dev.
>
> I also put the /usr/include and /usr/include/gdal in my PATH.
>
> Any ideas as to what is wrong, please?
>
> I have a feeling that it is something very simple.
>
> Thanks,
> Erin
> PS on R-2.15.2
>
>
> Erin M. Hodgess, Ph.D.
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: hodge...@uhd.edu
>
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Eduardo

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo