# how can I get the distance between two points in geoscatter

3 visualizaciones (últimos 30 días)
flashpode el 1 de Feb. de 2022
Respondida: Divit el 18 de Sept. de 2023
Hello, so I got a variable of latitud and another of longitud and a latitud and langitud from a point in the map. What I want is to calculate the distance between each point of the variables to the point I got in geoscatter. How can I do it?
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Divit el 18 de Sept. de 2023
Hi,
I understand that you would like to calculate distance between a reference point and a list of points in geoscatter.
% Define latitude and longitude arrays for your points
lat_array = [latitude1, latitude2, latitude3, ...]; % Replace with your values
lon_array = [longitude1, longitude2, longitude3, ...]; % Replace with your values
% Define the latitude and longitude of your reference point
ref_lat = reference_latitude; % Replace with your value
ref_lon = reference_longitude; % Replace with your value
% Convert latitude and longitude values to radians
% Radius of the Earth in kilometers (mean value)
% Initialize an array to store distances
distances_km = zeros(size(lat_array));
% Calculate distances using the Haversine formula
for i = 1:length(lat_array)
c = 2 * atan2(sqrt(a), sqrt(1-a));
end
The distances_km array contains the distances between the reference point and each point in your lat_array and lon_array.
To understand more, refer to the following documentation links:
I hope you find it useful.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Map Display en Help Center y File Exchange.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by