Help with Centroids

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with Centroids

SasaK
Dear All,

I am pretty new to R and  would appreciate a help how to calculate
centroids  from  the latitude and longitude of existing cells (e.g.  to get
centroid for a new cell I would need to combine  latitude and
9161,9162,9163,9164 to  9160  or 10152, 10154 to 10150 etc.)
Please see attached table.

Thank you very much!

Best,
Sasha


--

Dr Sasha Kosanic
Ecology Lab (Biology Department)
Room M644
University of Konstanz
Universitätsstraße 10
D-78464 Konstanz
Phone: +49 7531 883321

http://cms.uni-konstanz.de/vkleunen/
https://tinyurl.com/y8u5wyoj
https://tinyurl.com/cgec6tu
______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Help with Centroids

R help mailing list-2
Hi Sasha,

Your attached table did not come through, please see the posting guidelines:
"No binary attachments except for PS, PDF, and some image and archive
formats (others are automatically stripped off because they can contain
malicious software). Files in other formats and larger ones should
rather be put on the web and have only their URLs posted. This way a
reader has the option to download them or not."
https://www.r-project.org/posting-guide.html

It is not clear what you are trying to do. As a first step it looks like
you want something like:
 >>>>>>>>>>>>>>>>
lat <- c(9161,9162,9163,9164,10152,10154)
floor(lat/10)*10
<<<<<<<<<<<<<<<<

Please provide further details on what you are trying to do.

Rgds,

Robert


On 13/11/2018 09:51, sasa kosanic wrote:
> Dear All, I am pretty new to R and would appreciate a help how to
> calculate centroids from the latitude and longitude of existing cells
> (e.g. to get centroid for a new cell I would need to combine latitude
> and 9161,9162,9163,9164 to 9160 or 10152, 10154 to 10150 etc.) Please
> see attached table. Thank you very much! Best, Sasha

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Help with Centroids

R help mailing list-2
# construct the dataframe
`TK-QUADRANT` <- c(9161,9162,9163,9164,10152,10154,10161,10163)
LAT <-
c(55.07496,55.07496,55.02495,55.02496,54.97496,54.92495,54.97496,54.92496)
LON <-
c(8.37477,8.458109,8.37477,8.45811,8.291435,8.291437,8.374774,8.374774)
df <- data.frame(`TK-QUADRANT`=`TK-QUADRANT`,LAT=LAT,LON=LON)

# group the data and calculate means by group
df$group <- floor(df$TK.QUADRANT/10)*10
out <- aggregate(df[c('LAT','LON')],by=list(df$group),mean)
print(out)

# see also:
#
https://livefreeordichotomize.com/2018/06/27/bringing-the-family-together-finding-the-center-of-geographic-points-in-r/

Rgds,
Robert
On 14/11/2018 11:13, sasa kosanic wrote:

>  Dear Robert,
> Thank  you for your very much for your reply. Please see attached pdf 
> fille.
> I hope now it is more clear what I am trying to do:
> calculate new latitude and  longitude  of the centroids from the
> existing cells...
> as you can see from the attached pdf.  from Lat/ Long of
> 9161,9162,9163,9164 I need to calculate a single Lat/Long that could
> be fore example called 9160
> and then from lat/ long of 10152 and 10154 a  new single lat/long
> called 10150 .
> But guess I would need some kind of loop as this is just an example
> table  and the the whole table is covering whole Germany.
> Please let me know if it is still not clear what I am trying to do here.
>
> Best wishes,
> Sasha
>
> On Wed, 14 Nov 2018 at 07:58, Robert David Burbidge
> <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi Sasha,
>
>     Your attached table did not come through, please see the posting
>     guidelines:
>     "No binary attachments except for PS, PDF, and some image and archive
>     formats (others are automatically stripped off because they can
>     contain
>     malicious software). Files in other formats and larger ones should
>     rather be put on the web and have only their URLs posted. This way a
>     reader has the option to download them or not."
>     https://www.r-project.org/posting-guide.html
>
>     It is not clear what you are trying to do. As a first step it
>     looks like
>     you want something like:
>      >>>>>>>>>>>>>>>>
>     lat <- c(9161,9162,9163,9164,10152,10154)
>     floor(lat/10)*10
>     <<<<<<<<<<<<<<<<
>
>     Please provide further details on what you are trying to do.
>
>     Rgds,
>
>     Robert
>
>
>     On 13/11/2018 09:51, sasa kosanic wrote:
>     > Dear All, I am pretty new to R and would appreciate a help how to
>     > calculate centroids from the latitude and longitude of existing
>     cells
>     > (e.g. to get centroid for a new cell I would need to combine
>     latitude
>     > and 9161,9162,9163,9164 to 9160 or 10152, 10154 to 10150 etc.)
>     Please
>     > see attached table. Thank you very much! Best, Sasha
>
>
>
> --
>
> Dr Sasha Kosanic
> Ecology Lab (Biology Department)
> Room M644
> University of Konstanz
> Universitätsstraße 10
> D-78464 Konstanz
> Phone: +49 7531 883321 & +49 (0)175 9172503
>
> http://cms.uni-konstanz.de/vkleunen/
> https://tinyurl.com/y8u5wyoj
> https://tinyurl.com/cgec6tu
>
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.