moovida / geoimage

A dart test on hortonmachine bits and pieces.
Apache License 2.0
5 stars 5 forks source link

How exactly do i use it though? #1

Closed jesussmile closed 1 year ago

jesussmile commented 1 year ago

currently i use this python module to give me the elevation from the geotiff file

import rasterio

def get_elevation_from_geotiff(file_path, lon, lat):
    dataset = rasterio.open(file_path)
    transform = dataset.transform
    col, row = ~transform * (lon, lat)  # Inverse transform
    col = int(col)
    row = int(row)
    elevation = dataset.read(1)[row, col]
    dataset.close()
    return elevation

def count_coordinates_in_geotiff(file_path):
    dataset = rasterio.open(file_path)
    num_coordinates = dataset.width * dataset.height
    dataset.close()
    return num_coordinates

geotiff_file = '/Users/pannam/Desktop/EFB/python/nepal.tif'
# Biratnagar
longitude = 87.2662
latitude = 26.4840

num_coordinates = count_coordinates_in_geotiff(geotiff_file)
print("Number of coordinates in the GeoTIFF file:", num_coordinates)

altitude = get_elevation_from_geotiff(geotiff_file, longitude, latitude)
print('Altitude at ({}, {}): {} meters'.format(longitude, latitude, altitude))
print('Altitude at ({}, {}): {} feet'.format(longitude, latitude, altitude * 3.28084))

I want to do something similar in dart in my flutter project using flutter_map , how can I do it?

moovida commented 1 year ago

Have a look at the tests: https://github.com/moovida/geoimage/blob/master/test/geoimage_test.dart

For example "Test esri ascii grid" does what you need.