geosphere

Difference (angle) between two bearings

蹲街弑〆低调 提交于 2021-02-10 06:27:23
问题 Using geosphere::bearing I can calculate the bearing of two lines, but is it possible to calculate the angle between the two bearings ? Of course you can try and subtract or sum up the bearings but in specific cases where one is negative and the other is positive this doesn't work. For example if the ber1 = - 175 and ber2 = 175 the angle between should be 10. Any suggestions ? 回答1: I am not sure of a ready-made package but in case you are interested in a solution then you can try angle_diff <

Flatten nested list of lists with variable numbers of elements to a data frame

霸气de小男生 提交于 2021-02-07 10:57:41
问题 I've got a nested list of lists that I'd like to flatten into a dataframe with id variables so I know which list elements (and sub-list elements) each came from. > str(gc_all) List of 3 $ 1: num [1:102, 1:2] -74 -73.5 -73 -72.5 -71.9 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : NULL .. ..$ : chr [1:2] "lon" "lat" $ 2: num [1:102, 1:2] -74 -73.3 -72.5 -71.8 -71 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : NULL .. ..$ : chr [1:2] "lon" "lat" $ 3:List of 2 ..$ : num [1:37, 1:2] -74 -74.4 -74

Find closest points from data set B to point in data set A, using lat long in R

做~自己de王妃 提交于 2021-01-27 12:57:50
问题 I have two data sets, A and B, which give locations of different points in the UK as such: A = data.frame(reference = c(C, D, E), latitude = c(55.32043, 55.59062, 55.60859), longitude = c(-2.3954998, -2.0650243, -2.0650542)) B = data.frame(reference = c(C, D, E), latitude = c(55.15858, 55.60859, 55.59062), longitude = c(-2.4252843, -2.0650542, -2.0650243)) A has 400 rows and B has 1800 rows. For all the rows in A, I would like to find the shortest distance in kilometers between a point in A

Distance calculation optimization in R

 ̄綄美尐妖づ 提交于 2020-06-15 05:31:42
问题 I would like to know if there is any way to optimize the distance calculation process below. I left a small example below, however I am working with a spreadsheet with more than 6000 rows, and it takes considerable time to calculate the variable d. It would be possible to somehow adjust this to have the same results, but in an optimized way. library(rdist) library(tictoc) library(geosphere) time<-tic() df<-structure(list(Industries=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19), Latitude

Distance calculation optimization in R

点点圈 提交于 2020-06-15 05:30:58
问题 I would like to know if there is any way to optimize the distance calculation process below. I left a small example below, however I am working with a spreadsheet with more than 6000 rows, and it takes considerable time to calculate the variable d. It would be possible to somehow adjust this to have the same results, but in an optimized way. library(rdist) library(tictoc) library(geosphere) time<-tic() df<-structure(list(Industries=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19), Latitude

R measuring distance from a coastline

北城余情 提交于 2020-05-25 04:29:25
问题 I have a set of coordinates: d1 <- data_frame( title = c("base1", "base2", "base3", "base4"), lat = c(57.3, 58.8, 47.2, 57.8, 65.4, 56.7, 53.3), long = c(0.4, 3.4, 3.5, 1.2, 1.5, 2.6, 2.7)) I would like to know whether the coordinates fall on land, in the sea, or are 3 miles inside a coastline. The coordinates should fall somewhere within the UK, so I know that I need to draw a shape file of the UK and plot the points onto it. I just don't know how to measure whether the points fall in the

R Find the Distance between Two US Zipcode columns

谁说我不能喝 提交于 2020-04-30 07:24:26
问题 I was wondering what the most efficient method of calculating the distance in miles between two US zipcode columns would be using R. I have heard of the geosphere package for computing the difference between zipcodes but do not fully understand it and was wondering if there were alternative methods as well. For example say I have a data frame that looks like this. ZIP_START ZIP_END 95051 98053 94534 94128 60193 60666 94591 73344 94128 94128 94015 73344 94553 94128 10994 7105 95008 94128 I

Calculating distance between two GPS locations in a data frame using distm () in R

谁说胖子不能爱 提交于 2020-03-18 05:45:26
问题 This question has been asked previously but never with the following arrangement of the data. Below is a sample of it: > head(datagps) Date & Time [Local] Latitude Longitude 1: 2018-06-18 03:01:00 -2.434901 34.85359 2: 2018-06-18 03:06:00 -2.434598 34.85387 3: 2018-06-18 03:08:00 -2.434726 34.85382 4: 2018-06-18 03:12:00 -2.434816 34.85371 5: 2018-06-18 03:16:00 -2.434613 34.85372 6: 2018-06-18 03:20:00 -2.434511 34.85376 As you can see, I've a Date & Time [Local] column where GPS positions

In geosphere package in R, why aren't bearings in 0-360 degrees?

痴心易碎 提交于 2020-03-03 11:48:27
问题 When I calculated bearings between points using the bearing function in the geosphere package, the resulting bearings spanned -180 - 180 degrees. However, based on the geosphere package documentation, I expected the bearings to span 0-360 degrees. Here's a quote from the documentation: Directions are expressed in degrees (North = 0 and 360, East = 90, Sout = 180, and West = 270 degrees). What am I missing? Here's a small example: # set up library(geosphere) library(ggplot2) # create data

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

瘦欲@ 提交于 2019-12-30 10:53:20
问题 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