[R-sig-Geo] Center of mass of a SpatialPointsDataFrame object - Which projection?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sun Jun 10 21:03:58 CEST 2012


if gstat can figure out that data are not projected and
is.projected(obj) is FALSE, like in the following example:

library(sp)
x = SpatialPoints(cbind(0,0))
library(rgdal)
proj4string(x) = "+proj=longlat"
is.projected(x)
[1] FALSE

then it will use great-circle distances, as opposed to Euclidian
distances, when it computes a variogram.


On 06/10/2012 08:41 PM, PCB wrote:
> Yes, in this case I have one set of observations per year, so Time is
> discreet.
> 
> I did look at the Spatial Task View, but could not understand all that I
> read...
> I am using the gstat package, looks like it has all the features I want, but
> I still need to find out how to calculate the distances if I am using a
> lon-lat CRS. Anyway, I will try a go at using UTM, and will get back to the
> Spatial Task View. I am looking at an area between -5 and -25 Degrees, with
> a longitudinal extent of about 15 degrees longitude
> Since we are at this, is gstat the most appropriate package for doing this?
> or should I be trying one of the others? I am trying to work also with the
> "raster" package, for doing the cropping, but your mail suggests I could do
> it using gstat. I will find out how to do it there.
> Thanks a lot
> 
> .
> Barry Rowlingson wrote
>>
>> On Thu, Jun 7, 2012 at 2:10 PM, PCB <pedrocontebarros@> wrote:
>>
>>> I have a dataset that represents measurements of fish density at a number
>>> of
>>> sampling locations at sea, in several different occasions (the sampling
>>> locations are not always the same), stored as a a list of
>>> SpatialPointsDataFrame objects.
>>
>>  So your data is:
>>
>>  Lat, Long, Time, Mass
>>
>>> I want to calculate the center of mass of each distribution, to describe
>>> whether there is a trend in the overall distribution of the fish.
>>
>>  What do you mean by 'each distribution'? Your second sentence makes
>> me think that Time is discreet, or can be grouped into discreet
>> 'Occasions'.
>>
>>> I have three main questions:
>>> a) Should I use the original points for calculating the centre of mass,
>>> or
>>> should I interpolate them first to a grid? I assume doing it on the
>>> original
>>> points will make the result dependent on the location of these points,
>>> that
>>> is really not linked to the underlying fish distribution
>>
>>  Your data are samples from an underlying distribution of mass, so you
>> want to do something like Kriging to get an interpolated surface over
>> a grid.
>>
>>> b) Should I reproject the data before calculating the center of mass
>>> (they
>>> are in lon-lat). If so, which projection should I use?
>>
>>  If the Kriging package you use (and there's about 4 in R - gstat,
>> geoR, et al - read the Spatial Task View) can work out distances from
>> lat-long on the sphere (or ellipsoid) then you don't need to. However
>> computing distances from lat-long can be slower than from x-y
>> cartesian coords.. so...
>>
>>  If your data are over a relatively small area then convert to a
>> cartesian coordinate system in metres for units and then all the
>> Kriging packages will work, and they'll compute distances using
>> Pythagoras.
>>
>>  Now, which projection? Depends on the region you have data for. UTM
>> is a fairly safe bet, unless you're close to the poles, in which case
>> I think there must be polar projections. Check
>> www.spatialreference.org and see what turns up.
>>
>>
>>> c) A rectangular grid will include many locations on land, where no fish
>>> could have been recorded anyway. How do I get a grid I can use to
>>> meaningfully calculate the center of mass?
>>
>>  I think most of the Kriging packages can mask the output region by a
>> polygon, or you can mask raster objects with rasters or clip them to
>> polygons.
>>
>>> Thanks for your time, and any pointers will be highly appreciated.
>>
>>  The Spatial Task View is the place to start!
>>
>> Barry
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo@
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> 
> 
> --
> View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Center-of-mass-of-a-SpatialPointsDataFrame-object-Which-projection-tp7580128p7580149.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list