R - Finding centroids of different id values -


I'm trying to find sandide for a SpellPointDataFrame. The following is a snippet of data frame called "spdf".

  Name XY 1 16 56 39 2 16 57 39 3 16 55 38 4 16 55 37 5 16 54 38 6 16 55 39 7 16 55 40 8 12 58 41 9 12 56 45 10 12 58 43 11 12 56 42 12 12 55 44 13 12 55 47  

I function "gCentroid"'m using Senkrods recognize "Rejojh" package for the I gCentroid (spdf, byid = FALSE) I am able to calculate the nucleus for the entire data frame with but when I tried to calculate the centroids by using the "code" "code" I am, then GCentroid (spdf, byid = TRUE, id = "name") . In other words, on the basis of the above figures, I want to get two centroids for the name "12" and "16". The document is sparse about the "id" field on gicentride. Does anyone have any suggestions on how I can calculate centroids for each "name"?

The document is a bit confusing, but you ID input are not specified, output specified Are there. In your example, it has its own ID in every point (the name of the Rewel for the data frame, which should be unique by definition). reduced its data frame df $ name in your values ​​and centroids calculated this way you can easily get your desired output from ...

  ctrs & Lt; - Lapli (unique (DF $ name), function (x) Jisisitroid (Spatl points (DF [DF $ name == X, C ( 'X', 'Y')]))) Setnem (CTRs, unique (DF $ name)) # $ `16` #SpatialPoints: # xy # 1 55.28571 38.57143 # Corodinet reference system (CRS) argument: NA # $` L2` # Spitial Rating: # Aksai # 1 56.33333 43.66667 # Corodinet reference system (CRS) logic : NA  

PS I always thought that you should be able to do this, I have SPECIAL Lekshns an object , but it seems that you can not have the same type of specified spatial objects list (Are Still document adds that category).


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -