gdalutils is a small library to handle GDAL-based raster files
Installation
Just run this line after installing all dependencies
pip install git+https://github.com/jsosa/gdalutils.git
Dependencies
Usage
The module is loaded via
To read a raster directly from disk it can be done by
It'll return a numpy.array object
Geographical information can be read via
it'll return a Pyhton list containing
- xmin
- ymin
- xmax
- ymax
- number of cells
xdirection - number of cells
ydirection - resolution
xdirection - resolution
ydirection - an array containing center coordiantes of
xcells - an array containing center coordiantes of
ycells - projection
- nodata value
Writing numpy.array object is posible by calling
gu.write_raster(myarray, myraster, geo, fmt, nodata)
Where myarray is a numpy.array object, myraster is a filename output, geo is a list with geographical information identical to the one obtained with gu.get_geo, fmt is the format output: 'Float32', 'Float64', etc and nodata is the NODATA value
Passing from a numpy.array object to a pandas.Dataframe object is posible by
array_to_pandas(dat, geo, val, symbol)
where dat is the numpy.array object, geo is the list containing geographical information, val is a value to be masked and symbol is the logical symbol to be applied
Passing from pandas to array is also possible via
pandas_to_array(df, geo, nodata)