-
Notifications
You must be signed in to change notification settings - Fork 2
Usage and Example
Welcome to the srtm-reader wiki!
Before you can use the srtm-reader, you first have to download the SRTM data.
SRTM1 data can be downloaded from here.
SRTM3 data can be downloaded from here.
These databases are organized by latitude and longitude. For example, if you wish to read elevation data at Yellowstone National Part (44°36′N 110°30′W) then you would download N44W111.hgt
.
After you've downloaded the .hgt
files, store them in a folder that is accessible by the program.
Download the library files into your working directory. In this implementation, there is a single header and a .c
file.
In the header file srtm_reader.h
you can configure the library. The following configurations are available.
-
#define SRTM_AUTO_CHECK_DATABASE
- This line enables the auto check feature. This feature automatically identifies if you are using an SRTM1 or SRTM3 database. If you remove this line, you must manually assign the database type.
-
#define SRTM_BLOCK_SIZE 3601
- This line determines the block size of the database. SRTM1 uses a block size of 3601, SRTM3 uses a block size of 1201. If you have the auto check feature enabled, this line will be ignored.
-
const char* SRTM_folder = ".";
- This line describes relative path to the folder in which your
.hgt
files are stored.
- This line describes relative path to the folder in which your
After you've configured the library, you can use it by calling the SRTM_get_elevation
function.
srtm_reader.h
...
/* Enable the auto check feature */
#define SRTM_AUTO_CHECK_DATABASE
/* Because auto check is enabled, this line is irrelevant */
#define SRTM_BLOCK_SIZE 3601
const char* SRTM_folder = "C:\\srtm";
...
test.c
#include <stdio.h>
#include "srtm_reader.h"
int main() {
int elevation = SRTM_get_elevation(44.6, -110.5);
printf("The elevation at 44°36′N 110°30′W is %d(m)", elevation);
}
Compiling (gcc):
gcc test.c srtm_reader.c -o test.exe
./test.exe