1*ec63e07aSXin Li# GDAL Raster GeoTIFF Workflow 2*ec63e07aSXin Li 3*ec63e07aSXin Li``` 4*ec63e07aSXin LiBuild Tools: CMake/Ninja 5*ec63e07aSXin LiOS: Linux 6*ec63e07aSXin Li``` 7*ec63e07aSXin Li 8*ec63e07aSXin Li### For installing GDAL: 9*ec63e07aSXin Li 10*ec63e07aSXin Li``` 11*ec63e07aSXin Lisudo apt-get install python3.6-dev 12*ec63e07aSXin Lisudo add-apt-repository ppa:ubuntugis/ppa && sudo apt update 13*ec63e07aSXin Lisudo apt-get install gdal-bin 14*ec63e07aSXin Lisudo apt-get install libgdal-dev 15*ec63e07aSXin Li``` 16*ec63e07aSXin Li 17*ec63e07aSXin Li### Dependencies: 18*ec63e07aSXin Li 19*ec63e07aSXin LiPNG: `sudo apt-get install libpng-dev` 20*ec63e07aSXin Li 21*ec63e07aSXin LiPCRE: `sudo apt-get install libpcre3 libpcre3-dev` 22*ec63e07aSXin Li 23*ec63e07aSXin LiPROJ: `sudo apt-get install libproj-dev` 24*ec63e07aSXin Li 25*ec63e07aSXin LiOBS! You may need to set `export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib`. 26*ec63e07aSXin LiIt is required for libproj.so to be found into /usr/local/lib/. You can also fix 27*ec63e07aSXin Lithis by typing `locate libproj.so` which will give you 28*ec63e07aSXin Li<the_absolute_libproj.so_path> and then `cp <the_absolute_libproj.so_path> 29*ec63e07aSXin Li/usr/local/lib/`. 30*ec63e07aSXin Li 31*ec63e07aSXin Li### Initializing GDAL submodule: 32*ec63e07aSXin Li 33*ec63e07aSXin Li`git submodule add https://github.com/OSGeo/gdal/tree/master/gdal` 34*ec63e07aSXin Li 35*ec63e07aSXin Li### Building GDAL statically 36*ec63e07aSXin Li 37*ec63e07aSXin LiGNUmakefile from gdal/gdal can handle building the static library. 38*ec63e07aSXin Li 39*ec63e07aSXin Li`cd gdal/gdal && make static-lib` 40*ec63e07aSXin Li 41*ec63e07aSXin Li`cd ../.. && mkdir lib` 42*ec63e07aSXin Li 43*ec63e07aSXin Li`cp gdal/gdal/libgdal.a lib/` 44*ec63e07aSXin Li 45*ec63e07aSXin LiOBS! The file is huge! It may take a while. 46*ec63e07aSXin Li 47*ec63e07aSXin Li### For testing: 48*ec63e07aSXin Li 49*ec63e07aSXin Li`mkdir build && cd build` 50*ec63e07aSXin Li 51*ec63e07aSXin Li`cmake .. -G Ninja` 52*ec63e07aSXin Li 53*ec63e07aSXin Li`ninja` 54*ec63e07aSXin Li 55*ec63e07aSXin Li`./raster <your_absolute_tiff_file_path>` 56*ec63e07aSXin Li 57*ec63e07aSXin Li## About the project 58*ec63e07aSXin Li 59*ec63e07aSXin LiGDAL is a translator library for raster and vector geospatial data format. The 60*ec63e07aSXin Liproject consist in rastering a GeoTIFF file format using GDAL functionalities 61*ec63e07aSXin Liand sandboxed methods. 62*ec63e07aSXin Li 63*ec63e07aSXin Li## Implementation 64*ec63e07aSXin Li 65*ec63e07aSXin Li*Sandboxing...* 66*ec63e07aSXin Li 67*ec63e07aSXin LiThe purpose of sandboxing is to limit the permissions and capabilities of 68*ec63e07aSXin Lilibrary’s methods, in order to secure the usage of them. After obtaining the 69*ec63e07aSXin Lisandbox, the functions will be called through an Sandbox API (being called api 70*ec63e07aSXin Liin the current test) and so, the operations, system calls or namspaces access 71*ec63e07aSXin Limay be controlled. 72*ec63e07aSXin Li 73*ec63e07aSXin Li*Raster process...* 74*ec63e07aSXin Li 75*ec63e07aSXin LiUseful functions from the `gdal.h` header are added to the SAPI library built 76*ec63e07aSXin Liwith CMake. 77*ec63e07aSXin Li 78*ec63e07aSXin LiOne .tiff file is manipulated with GDALOpen functionality, which extracts a 79*ec63e07aSXin Lipointer to the data set containg a list of raster bands, all pertaining to the 80*ec63e07aSXin Lisame area. Metadata, a coordinate system, a georeferencing transform, size of 81*ec63e07aSXin Liraster and various other information are kept into the data set that corresponds 82*ec63e07aSXin Lito the image. 83*ec63e07aSXin Li 84*ec63e07aSXin LiTo create an array containing the image information, the dimentions needed are 85*ec63e07aSXin Liextracted using some specific GDAL(X/Y)Size functions applied to the block. 86*ec63e07aSXin LiGDALRasterBand function takes care of data type conversion, one more step 87*ec63e07aSXin Lifollowing: placing the converted data (with RasterIO method) into the created 88*ec63e07aSXin Liand well allocated structure. 89