distance

Global Raster of geographic distances

删除回忆录丶 提交于 2019-12-04 16:31:54
Im wondering if someone has built a raster of the continents of the world where each cell equals the distance of that cell cell to the nearest shore. This map would highlight the land areas that are most isolated inland. I would imagine this would simply rasterize a shapefile of the global boundaries and then calculate the distances. You can do this with raster::distance , which calculates the distance from each NA cell to the closest non- NA cell. You just need to create a raster that has NA for land pixels, and some other value for non-land pixels. Here's how: library(raster) library

postgis distance between two points on a line

纵饮孤独 提交于 2019-12-04 15:58:07
问题 I have a route (as a LINESTRING) and two vehicles with a position (as a POINT). I need to calculate the distance between the two points over the route. As an added difficulty I think I also need to measure the distance from the point to the closest point on the line in the case that the vehicle is not on the route at that moment. I'm using this to find the closest point on the route: SELECT ST_AsText(ST_ClosestPoint(pt,line)) AS cp_pt_line, ST_AsText(ST_ClosestPoint(line,pt)) As cp_line_pt

Manhattan Distance for two geolocations

匆匆过客 提交于 2019-12-04 14:51:46
问题 Let's say I have two locations represented by latitude and longitude. Location 1 : 37.5613 , 126.978 Location 2 : 37.5776 , 126.973 How can I calculate the distance using Manhattan distance ? Edit : I know the formula for calculating Manhattan distance like stated by Emd4600 on the answer which is |x1-x2| - |y1-y2| but I think it's for Cartesian. If it is can be applied that straight forward |37.5613-37.5776| + |126.978-126.973| what is the distance unit of the result ? 回答1: Given a plane

Figuring out distance and course between two coordinates

我与影子孤独终老i 提交于 2019-12-04 14:49:21
I have 2 coordinates and would like to do something seemingly straightforward. I want to figure out, given: 1) Coordinate A 2) Course provided by Core Location 3) Coordinate B the following: 1) Distance between A and B (can currently be done using distanceFromLocation) so ok on that one. 2) The course that should be taken to get from A to B (different from course currently traveling) Is there a simple way to accomplish this, any third party or built in API? Apple doesn't seem to provide this but I could be wrong. Thanks, ~Arash EDIT: Thanks for the fast responses, I believe there may have been

Android: how to find total distance covered using GPS when continuously moving?

泪湿孤枕 提交于 2019-12-04 14:06:50
This is my code. Please tell me y it is not able to calculate the distance.. In this code res is a long variable which is supposed to store the total distance covered. This code is supposed to calculate distance based on GPS as soon as there is a change in the latitude and longitude.. String serviceString = Context.LOCATION_SERVICE; LocationManager locationManager; locationManager= (LocationManager)getSystemService(serviceString); String provider = LocationManager.GPS_PROVIDER; final Location loc1=locationManager.getLastKnownLocation(provider); //Location loc1=new Location(""); String

Use pdist() in python with a custom distance function defined by you

泄露秘密 提交于 2019-12-04 11:19:26
I have been interested in usage of scipy.spatial.distance.pdist(...) in python which has come to be useful and fast for some of the applications I have been working on. I need to use a pairwise distance function which are custom and not standard default distance metrics as defined by the metric. Let's make a simple example, suppose I do not want to use euclidean distance function as the following: Y = pdist(X, 'euclidean') Instead I want to define the euclidean function myself and pass it as a function or argument to pdist() . How can I pass the implementation of euclidean distance function to

Location and distance calculation using Wifi in android

江枫思渺然 提交于 2019-12-04 11:07:24
How to get the distance of our mobile device from a wifi hotspot kept inside a building? This is basically for navigational purposes inside the building.. Any help would be appreciated. If you want to use WiFi for indoor location (step 1 before navigation), then distance to the WiFi Access Points is not the correct approach. Instead use RSSI . With Android you would need to take WiFi fingerprint of a building by moving around every few meters and sample the RSSI strength . You need to provide a user interface that lets the user manually specify on an image of the building (e.g. a CAD drawing).

How to calculate distance between 2 coordinates below a certain threshold in R?

混江龙づ霸主 提交于 2019-12-04 10:39:25
I have 44,000 US Zip codes and it's corresponding centroid lat/long in R. This is from the package 'zipcode' in R. I need to calculate the distance between each zipcode and keep those distances that are less than 5 miles. The problem is to calculate all distances between the zipcodes I have to create a vector of size 44,000x44,0000 which I can't due to space issues. I checked through the posts in R, the closest to my requirement is one that spits out the minimum distance between 2 datasets with lat/long DB1 <- data.frame(location_id=1:7000,LATITUDE=runif(7000,min = -90,max = 90),LONGITUDE

Distance from Point To Line great circle function not working right.

久未见 提交于 2019-12-04 09:52:37
I need to get the distance from a lat/lng point to a line. Of course needs to follow the Great Circle. I found a great article on this at http://www.movable-type.co.uk/scripts/latlong.html but the code is not working right. Either I am doing something wrong or there is something missing. Here is the function in question. See the link for the other functions if needed. var R = 3961.3 LatLon.crossTrack = function(lat1, lon1, lat2, lon2, lat3, lon3) { var d13 = LatLon.distHaversine(lat1, lon1, lat3, lon3); var brng12 = LatLon.bearing(lat1, lon1, lat2, lon2); var brng13 = LatLon.bearing(lat1, lon1

choose n most distant points in R

百般思念 提交于 2019-12-04 05:16:05
Given a set of xy coordinates, how can I choose n points such that those n points are most distant from each other? An inefficient method that probably wouldn't do too well with a big dataset would be the following (identify 20 points out of 1000 that are most distant): xy <- cbind(rnorm(1000),rnorm(1000)) n <- 20 bestavg <- 0 bestSet <- NA for (i in 1:1000){ subset <- xy[sample(1:nrow(xy),n),] avg <- mean(dist(subset)) if (avg > bestavg) { bestavg <- avg bestSet <- subset } } This code, based on Pascal's code, drops the point that has the largest row sum in the distance matrix. m2 <- function