sandboxed-api/oss-internship-2020/gdal
Christian Blichmann dbaf95c724 Move utility code into sandboxed_api/util
This change should make it less confusing where utility code comes from.
Having it in two places made sense when we were debating whether to publish
Sandbox2 separately, but not any longer.

Follow-up changes will move `sandbox2/util.h` and rename the remaining
`sandbox2/util` folder.

PiperOrigin-RevId: 351601640
Change-Id: I6256845261f610e590c25e2c59851cc51da2d778
2021-01-13 09:25:52 -08:00
..
raster_to_gtiff Move utility code into sandboxed_api/util 2021-01-13 09:25:52 -08:00
CANYrelief1-geo.tif GDAL good version 2020-09-23 15:39:49 +00:00
CMakeLists.txt Merge pull request #53 from doinachiroiu:master 2020-09-24 06:57:28 -07:00
raster.cc Move utility code into sandboxed_api/util 2021-01-13 09:25:52 -08:00
README.md Merge pull request #53 from doinachiroiu:master 2020-09-24 06:57:28 -07:00

GDAL Raster GeoTIFF Workflow

Build Tools: CMake/Ninja
OS: Linux

For installing GDAL:

sudo apt-get install python3.6-dev
sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev

Dependencies:

PNG: sudo apt-get install libpng-dev

PCRE: sudo apt-get install libpcre3 libpcre3-dev

PROJ: sudo apt-get install libproj-dev

OBS! You may need to set export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib. It is required for libproj.so to be found into /usr/local/lib/. You can also fix this by typing locate libproj.so which will give you <the_absolute_libproj.so_path> and then cp <the_absolute_libproj.so_path> /usr/local/lib/.

Initializing GDAL submodule:

git submodule add https://github.com/OSGeo/gdal/tree/master/gdal

Building GDAL statically

GNUmakefile from gdal/gdal can handle building the static library.

cd gdal/gdal && make static-lib

cd ../.. && mkdir lib

cp gdal/gdal/libgdal.a lib/

OBS! The file is huge! It may take a while.

For testing:

mkdir build && cd build

cmake .. -G Ninja

ninja

./raster <your_absolute_tiff_file_path>

About the project

GDAL is a translator library for raster and vector geospatial data format. The project consist in rastering a GeoTIFF file format using GDAL functionalities and sandboxed methods.

Implementation

Sandboxing...

The purpose of sandboxing is to limit the permissions and capabilities of librarys methods, in order to secure the usage of them. After obtaining the sandbox, the functions will be called through an Sandbox API (being called api in the current test) and so, the operations, system calls or namspaces access may be controlled.

Raster process...

Useful functions from the gdal.h header are added to the SAPI library built with CMake.

One .tiff file is manipulated with GDALOpen functionality, which extracts a pointer to the data set containg a list of raster bands, all pertaining to the same area. Metadata, a coordinate system, a georeferencing transform, size of raster and various other information are kept into the data set that corresponds to the image.

To create an array containing the image information, the dimentions needed are extracted using some specific GDAL(X/Y)Size functions applied to the block. GDALRasterBand function takes care of data type conversion, one more step following: placing the converted data (with RasterIO method) into the created and well allocated structure.