Code Monkey home page Code Monkey logo

Comments (3)

alguerre avatar alguerre commented on June 10, 2024

Using python some DEM info has been loaded, ilha das Flores and ilha do Corvo from Azores:
image

import tifffile as tiff
import matplotlib.pyplot as plt
import rasterio

tfile = tiff.imread('eu_dem_v11_E00N20.TIF')
tfile.shape
tiff.imshow(tfile)
plt.show()

Source: https://gis.stackexchange.com/questions/337343/altitude-extraction-from-a-dem-tiff-file-using-python

from trackeditor.

alguerre avatar alguerre commented on June 10, 2024

A deeper analysis of this can drive to the creation of an API to get elevation from given coordinates.

from trackeditor.

alguerre avatar alguerre commented on June 10, 2024

This small code allows to open 'one band' of the tiff file. However, when using a larger file a MemoryError is raised:

numpy.core._exceptions.MemoryError: Unable to allocate 5.96 GiB for an array with shape (1, 40000, 40000) and data type float32

import rasterio

# Which band are you interested. 
# 1 if there is only one band
band_of_interest = 1

# Row and Columns of the raster you want to know
# the value
row_of_interest = 30
column_of_interest = 50

# open the raster and close it automatically
# See https://stackoverflow.com/questions/1369526
with rasterio.open('eu_dem_v11/eu_dem_v11_E00N20.TIF') as dataset:
    band = dataset.read(band_of_interest)
    print(band)

value_of_interest = band[row_of_interest][column_of_interest]
print(value_of_interest)
print(len(band))

l_band = []
for b in band:
	l_band.append(len(b))
print(min(l_band), max(l_band))

Fortunately, there is some information on how the files are constructed:

Additional information
The EU-DEM is a 3D raster dataset with elevations captured at 1 arc second postings (2.78E-4 degrees) or about every 30 metre.
All three datasets are made available as tiles (5x5° or 1000x1000km) and as single files:

  • EU-DEM in ETRS89 geographic (EPSG code 4258)
  • EU-DEM in ETRS89-LAEA (EPSG code 3035)
  • Colour shaded relief image over Europe in ETRS89-LAEA (EPSG code 3035)
    The datasets are encoded as GeoTIFF with LZW compression (tiles) or DEFLATE compression (European mosaics as single files).

https://www.eea.europa.eu/data-and-maps/data/eu-dem

Therefore, the firsts steps to create an API would be:

  1. Read small tif file, such as eu_dem_v11_E10N20, and get altitude given coordinates.
  2. Read tif files by reduced chunks.
  3. Load data to a SQL database.

from trackeditor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.