[R-sig-Geo] Distance between two points
O'Hanlon, Simon J
simon.ohanlon at imperial.ac.uk
Sat Dec 8 12:22:42 CET 2012
Dear Sarah, Roger and Michael,
Thank you very much for your help. So in summary if I understand correctly;
If I have a raster in long-lat which has some values and I would like to reproject this data to planar coordinates. A good way to proceed would be to:
- make spatial points from the lat-long raster
- transform these spatial points to desired planar coordinates
- over(lay) the transformed spatial points on a planar raster with desired extent and resolution (ideally the resolution would be close to the original raster) and assign values to the new raster (in a sensible way)
Alternatively I could use raster::reprojectRaster and crop the edges of the new raster to a desired bounding box if I require a rectangular grid (which I do)?
Thanks again.
Simon
-----Original Message-----
From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Michael Sumner
Sent: 07 December 2012 19:33
To: Roger.Bivand at nhh.no
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] Distance between two points
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
>> <simon.ohanlon at imperial.ac.uk> 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.goslee at gmail.com]
>>> Sent: 07 December 2012 14:18
>>> To: O'Hanlon, Simon J
>>> Cc: r-sig-geo at 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.ohanlon at 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
>> <http://www.functionaldiversity.org>
>>
>> ______________________________**_________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.c
>> h/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.Bivand at nhh.no
>
> ______________________________**_________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch
> /mailman/listinfo/r-sig-geo>
>
--
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com
[[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
More information about the R-sig-Geo
mailing list