- globalmapper.GetLocationElevation(GM_LayerHandle_t32 aLayer, float aXCoord, float aYCoord) GM_Error_t32, float
Retrieves the elevation at a given location from a provided layer or from the list of currently loaded elevation layers (topmost elevation layer first).
- Parameters:
aLayer (GM_LayerHandle_t32) – Layer to get elevation from or gm.NULL for topmost
aXCoord (float) – X coord in current projection
aYCoord (float) – Y coord in current projection
- Returns:
Error Code
- Return type:
GM_Error_t32
- Returns:
Elevation at location in meters
- Return type:
float
Example
The following is an example of GetLocationElevation.
import os
import globalmapper as gm
import_dir = "Z:/GM-20069/single_function_sample_data/"
# Close all layers that may be open
layers_are_open = gm.GetLoadedLayerList()
if layers_are_open:
arr_ptr, arr_size = layers_are_open
initial_layers = gm.GM_LayerHandle_array_frompointer(arr_ptr)
for i in range(arr_size):
gm.CloseLayer(initial_layers[i])
err_LoadLayerList, array_pointer, array_size_param = gm.LoadLayerList(
os.path.join(import_dir, "Depth_to_Water.tif"),
gm.GM_LoadFlags_HideAllPrompts,
)
# Get handle for the loaded layers
arr_ptr, arr_size = gm.GetLoadedLayerList()
layers_array = gm.GM_LayerHandle_array_frompointer(arr_ptr)
layers_list = gm.carray_to_list(layers_array, arr_size)
### START SAMPLE
err_GetLocationElevation, elevation = gm.GetLocationElevation(
gm.NULL, 1116798, 220547
)
### END SAMPLE
assert (
gm.GM_Error_None == err_LoadLayerList
), f"LoadLayerList: Expected {gm.GM_Error_None}, got {err_LoadLayerList}"
assert (
gm.GM_Error_None == err_GetLocationElevation
), f"GetLocationElevation: Expected {gm.GM_Error_None}, got {err_GetLocationElevation}"
assert os.path.isdir(import_dir), f"Import directory doesn't exist: {import_dir}"
assert os.path.exists(
os.path.join(import_dir, "Depth_to_Water.tif")
), "Sample data doesn't exist"
# These are the values they had when the sample was created
assert elevation == 76.0, "Elevation value is incorrect"