This article describes importing and reading in GeoTIFF files from a user's desktop into the EarthAI Notebook environment.
Above the notebook file browser on the lefthand side of the screen just below the Run dropdown menu, click on the up arrow icon. If you hover over it an Upload Files label pops up. Click on this and a browser window opens up. You can then navigate to the GeoTIFF file on your desktop or wherever you have it stored. Click the file and select Open. You may get a "Large file size warning" message. Click Upload and the GeoTIFF file should now appear in your notebook browser in the left side bar.
The file can now be read into the notebook in a number of ways. The following code reads it in as a RasterFrame. The GeoTIFF file was uploaded to the current working directory of EarthAI Notebook. You should be able to simply "tab autocomplete" the file name unless you changed directories.
from earthai.init import *
rf = spark.read.raster('<filename>.tiff')
The GeoTIFF has now been read into the notebook as a RasterFrame with the arbitrary name rf.
Alternatively, it you are familiar with the rasterio library EarthAI Notebook fully supports that. Simply import rasterio and read in the .tiff file. Rasterio is pre-installed in EarthAI Notebook, so only an import statement is needed.
import rasterio as rio
raster = rio.open('<filename>.tiff')
If we check the type of raster it is of type "DatasetReader" which means the .tiff file is now open and can be read. You have the full suite of rasterio operations at your disposal in EarthAI Notebook, including:
# check coordinate reference system
# check the dimensions
# check number of bands
# confirm the file format
Please sign in to leave a comment.