geosphere

Understanding the output of `areaPolygon()` from package geosphere

徘徊边缘 提交于 2019-12-30 10:52:07
问题 From this Question I obtained the great function areaPolygon() which gives me the area within a polygon of coordinates. however, when I experiment with the function the calculations seem odd: I start by creating a set of two points require(fields) coords <- c(11.3697193956209, 47.233380520521, 11.3723606043791, 47.235179479479) coords <- matrix(coords, nrow=2, ncol=2, byrow=TRUE) then I check the distance between these two: rdist.earth(coords,coords,miles=FALSE)[1,2] obtaining: 0.2827821

How to compute big geographic distance matrix

醉酒当歌 提交于 2019-12-13 07:24:32
问题 I have a dataframe of ids and coordinates. I need to calculate the geographic distance between all my ids, drop the ones that are too far from each other, and then go on with my analysis. I have 30k ids, which would generate a 30k x 30k matrix. Here is a sample: latitude longitude id -23.52472 -46.47785 917_62346 -23.62010 -46.69345 244_42975 -23.61636 -46.48148 302_75289 -23.53826 -46.46756 917_96304 -23.58266 -46.54495 302_84126 -23.47005 -46.70921 233_97098 -23.49235 -46.49342 917_62953

How to efficiently calculate distance between GPS points in one dataset and GPS points in another data set using data.table

霸气de小男生 提交于 2019-12-11 06:09:46
问题 I am facing a coding (optimization) problem in R. I have a long data set with GPS coordinates (lon, lat, timestamp) and for every row I need to check whether the location is near a bus stop. I have a .csv file with all the bus stops (in the Netherlands). The GPS coordinates file is millions of entries long, but could be split if necessary. The bus stop dataset is around 5500 entries long. Using the code and tips given on, inter alia, these pages: 1) How to efficiently calculate distance

Matrix of distances with Geosphere: avoid repeat calculus

帅比萌擦擦* 提交于 2019-12-10 19:23:01
问题 I want to compute the distance among all points in a very large matrix using distm from geosphere . See a minimal example: library(geosphere) library(data.table) coords <- data.table(coordX=c(1,2,5,9), coordY=c(2,2,0,1)) distances <- distm(coords, coords, fun = distGeo) The issue is that due to the nature of the distances I am computing, distm gives me back a symmetric matrix, therefore, I could avoid to calculate more than half of the distances: structure(c(0, 111252.129800202, 497091

R: Distm for big data? Calculating minimum distances between two matrices

偶尔善良 提交于 2019-12-10 10:11:16
问题 I have two matrices, one is 200K rows long, the other is 20K. For each row (which is a point) in the first matrix, I am trying to find which row (also a point) in the second matrix is closest to the point in the first matrix. This is the first method that I tried on a sample dataset: #Test dataset pixels.latlon=cbind(runif(200000,min=-180, max=-120), runif(200000, min=50, max=85)) grwl.latlon=cbind(runif(20000,min=-180, max=-120), runif(20000, min=50, max=85)) #calculate the distance matrix

R: Distm for big data? Calculating minimum distances between two matrices

别说谁变了你拦得住时间么 提交于 2019-12-05 20:18:21
I have two matrices, one is 200K rows long, the other is 20K. For each row (which is a point) in the first matrix, I am trying to find which row (also a point) in the second matrix is closest to the point in the first matrix. This is the first method that I tried on a sample dataset: #Test dataset pixels.latlon=cbind(runif(200000,min=-180, max=-120), runif(200000, min=50, max=85)) grwl.latlon=cbind(runif(20000,min=-180, max=-120), runif(20000, min=50, max=85)) #calculate the distance matrix library(geosphere) dist.matrix=distm(pixels.latlon, grwl.latlon, fun=distHaversine) #Pick out the

Mapping the shortest flight path across the date line in R leaflet/Shiny, using gcIntermediate [duplicate]

。_饼干妹妹 提交于 2019-11-30 08:46:31
问题 This question already has answers here : Plotting routes that cross the international dateline using leaflet library in R (2 answers) Closed 10 months ago . I'm creating a map of Australian airports and their international destinations using R-Leaflet. Here is my sample data: df<-data.frame("Australian_Airport" = "Brisbane", "International" = c("Auckland", "Bandar Seri Begawan","Bangkok","Christchurch","Denpasar","Dunedin","Hamilton","Hong Kong","Honiara","Kuala Lumpur"), "Australian_lon" = c

How can I calculate the distance between latitude and longitude along rows of columns in R?

别等时光非礼了梦想. 提交于 2019-11-29 12:43:50
My df looks like this: bid ts latitude longitude 1 827566 1999-10-07 42.40944 -88.17822 2 827566 2013-04-11 41.84740 -87.63126 3 1902966 2012-05-02 45.52607 -94.20649 4 1902966 2013-03-25 41.94083 -87.65852 5 3211972 2012-08-14 43.04786 -87.96618 6 3211972 2013-08-02 41.88258 -87.63760 I want to create a new df that calculates the difference in time and distance from each successive point. I would like to calculate down the rows grouped by bid's that are the same. I used the following for loop to accomplish this: library(geosphere) lengthdata <- nrow(twopoint) twopointdata <- data.frame(matrix

Mapping the shortest flight path across the date line in R leaflet/Shiny, using gcIntermediate [duplicate]

妖精的绣舞 提交于 2019-11-29 07:56:08
This question already has an answer here: Plotting routes that cross the international dateline using leaflet library in R 2 answers I'm creating a map of Australian airports and their international destinations using R-Leaflet. Here is my sample data: df<-data.frame("Australian_Airport" = "Brisbane", "International" = c("Auckland", "Bandar Seri Begawan","Bangkok","Christchurch","Denpasar","Dunedin","Hamilton","Hong Kong","Honiara","Kuala Lumpur"), "Australian_lon" = c(153.117, 153.117,153.117,153.117,153.117,153.117, 153.117, 153.117, 153.117, 153.117), "Australian_lat" = c(-27.3842,-27.3842,

How can I calculate the distance between latitude and longitude along rows of columns in R?

北城余情 提交于 2019-11-28 06:25:34
问题 My df looks like this: bid ts latitude longitude 1 827566 1999-10-07 42.40944 -88.17822 2 827566 2013-04-11 41.84740 -87.63126 3 1902966 2012-05-02 45.52607 -94.20649 4 1902966 2013-03-25 41.94083 -87.65852 5 3211972 2012-08-14 43.04786 -87.96618 6 3211972 2013-08-02 41.88258 -87.63760 I want to create a new df that calculates the difference in time and distance from each successive point. I would like to calculate down the rows grouped by bid's that are the same. I used the following for