polygon - Area calculation in R -
so haven been trying calculate total land loss due climate change. dataset use website link
this dataset consists of longitude , latitude of place lost. want calculate total area of such points. know geosphere packages has function calculate area of polygon created set of points. still worry using may overestimate result connecting points far away each other. link map if @ antarctica, connecting red points overestimated affected area.
my question areapolygon() function accounts fact? if not there way come more precise estimate area in question? thinking using distance between points criteria. don't know how implement in r.
thank
this code have been using far
library(rgdal) library(sp) library(geosphere) library(plyr) grid_file_6m <- new("gdalreadonlydataset","link_to_the_file") grid_6m <- assgdf_grod(grid_file_6m, output.dim=c(1000, 1000)) plot(grid_6m,bg="black") grid_6m_df <- as.data.frame(grid_6m) grid_6m_df=grid_6m_df[,-1] grid_6m_df$id= coords2country(grid_6m_df) grid_6m_df<-grid_6m_df[!(is.na(grid_6m_df$id)==true),] grid_6m_df<-grid_6m_df[!(is.na(grid_6m_df$x)==true),] grid_6m_df<-grid_6m_df[!(is.na(grid_6m_df$y)==true),] write.csv(grid_6m_df,"test.csv") grid_6m_df<- read.csv(file="test.csv", sep=",", header=true ) allname<-levels(grid_6m_df$id) country.df <- split(grid_6m_df[,-4],grid_6m_df$id) clean.up<- function(x) { x<-x[,2:3] } country.df <-lapply(country.df,clean.up) distm.km <-function (x) { distm(x)/1000 } dis.table <-lapply (country.df,distm.km)
the function coords2country() post here match country point belongs to.
thank you
Comments
Post a Comment