pinxau1000/Matlab-Google-Elevation-API

버전 1.0.0.0 (916 KB) 작성자: pinxau1000 (J. Rosa)
Get a area elevation profile easily. Efficient usage of Google Elevation API.
다운로드 수: 211
업데이트 날짜: 2021/1/13

Matlab Script to get a elevation profile along a path defined between two points with n resolution samples.
Check the Project on Github: https://github.com/pinxau1000/Matlab-Google-Elevation-API
Example Usage:
[elevation, resolution, latitudes, longitudes] =
getElevationsPath(latitude1, longitude1, latitude2, longitude2,
resolution, 'key', 'YOUR-API-KEY');
Returns <resolution> points of elevation, resolution, latitudes and
longitudes from the path from Point1(latitude1, longitude1) to Point2
(latitude2, longitude2).

------------------------------------------------------------------------
Example:
Get an area profile. Area vertex are:
VERTEX LAT LONG
Up Left Corner: 39.549937, -8.819350
Up Right Corner: 39.549937, -8.761150
Down Left Corner: 39.505018, -8.819350
Down Right Corner: 39.505018, -8.761150

clearvars;
clc;

SAMPLES = 100;
API_KEY = 'YOUR-API-KEY'; % Read https://developers.google.com/maps/documentation/elevation/get-api-key

Coord1 = [39.549937, -8.819350];
Coord2 = [39.505018, -8.761150];

try
load(['backup_' num2str(SAMPLES)]);

% Sucess loaded but the number of samples are different or the
% coordinates are different. Need to request elevations again.
if length(lat_map)~=SAMPLES || lat_map(1)~=Coord1(1) || lng_map(1)~=Coord1(2) ...
|| lat_map(length(lat_map),1)~=Coord2(1) || lng_map(1,length(lng_map))~=Coord2(2)

disp('Requesting Elevations to Google');

lat = linspace(Coord1(1), Coord2(1), SAMPLES); %Latitude Points

% Preallocating memory for speed improvement
elevation_map = NaN(SAMPLES, SAMPLES);
resolution_map = NaN(SAMPLES, SAMPLES);
lat_map = NaN(SAMPLES, SAMPLES);
lng_map = NaN(SAMPLES, SAMPLES);

% Gets the area elevations.
for r=1:length(lat)
[elevation_map(r,:), resolution_map(r,:), lat_map(r,:), lng_map(r,:)] = getElevationsPath(lat(r), Coord1(2), lat(r), Coord2(2), SAMPLES, 'key', API_KEY);
end

save(['backup_' num2str(SAMPLES)], 'elevation_map', 'resolution_map', 'lat_map', 'lng_map');
end
catch

disp('Requesting Elevations to Google');

lat = linspace(Coord1(1), Coord2(1), SAMPLES); %Latitude Points

% Preallocating memory for speed improvement
elevation_map = NaN(SAMPLES, SAMPLES);
resolution_map = NaN(SAMPLES, SAMPLES);
lat_map = NaN(SAMPLES, SAMPLES);
lng_map = NaN(SAMPLES, SAMPLES);

% Gets the area elevations.
for r=1:length(lat)
[elevation_map(r,:), resolution_map(r,:), lat_map(r,:), lng_map(r,:)] = getElevationsPath(lat(r), Coord1(2), lat(r), Coord2(2), SAMPLES, 'key', API_KEY);
end

save(['backup_' num2str(SAMPLES)], 'elevation_map', 'resolution_map', 'lat_map', 'lng_map');
end

disp('Displaying Data');

% Displays the data
figure('Name','Elevation');

subplot(2,1,1);
meshc(lng_map(1,:), lat_map(:,1), elevation_map);
title('Elevation profile from Serra de Aire e Candeeiros');
xlabel('Latitude (º)');
ylabel('Longitude (º)');
zlabel('Elevation (m)');
colorbar;

subplot(2,1,2);
meshc(lng_map(1,:), lat_map(:,1), resolution_map);
title('Resolution of the Elevation Data of Serra de Aire e Candeeiros');
xlabel('Latitude (º)');
ylabel('Longitude (º)');
zlabel('Resolution (m)');

------------------------------------------------------------------------

MAIN ADVANTAGES (compares to getElevations from Jarek Tuszynski):
- Only consumes one API request for n resolution points between the
path, instead of x API request from the n points from the request
of the original script;
- Easier to use in some cases, mainly when you need to get a
elevation profile of a big area (elevation profile line by line)

THIS SCRIPT IS A MODIFIED VERSION OF GetElevation Script from:
Author: Jarek Tuszynski (jaroslaw.w.tuszynski@leidos.com)
Documentation: https://developers.google.com/maps/documentation/elevation/

MODIFIED VERSION AUTHOR: José Rosa
Github: https://github.com/pinxau1000/Matlab-Google-Elevation-API
Tested on Matlab R2017a

A resolution value, indicating the maximum distance between data points
from which the elevation was interpolated, in meters. This property will
be missing if the resolution is not known. Note that elevation data becomes
more coarse (larger resolution values) when multiple points are passed.
To obtain the most accurate elevation value for a point, it should be queried
independently.

인용 양식

pinxau1000 (J. Rosa) (2025). pinxau1000/Matlab-Google-Elevation-API (https://github.com/pinxau1000/Matlab-Google-Elevation-API), GitHub. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2017a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Geology에 대해 자세히 알아보기
도움

도움 받은 파일: getElevations(latitude, longitude, varargin)

Community Treasure Hunt

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

Start Hunting!

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.0.0.0

Added more description about the function.

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.