Skip to content

Geospatial Python library for geospatial grid-based analyses

License

Notifications You must be signed in to change notification settings

Colleoni/rectifiedgrid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RectifiedGrid

RectifiedGrid is a Python package which, combining into a single class several pythonpackages (e.g. Numpy, SciPy, shapely, rasterio, fiona, geopandas, owslib, matplotlib-basemaps), simplifies geospatial grid-based analyses. Numpy is a notable package for scientific computing with a support for large, multi-dimensional arrays and matrices: RectifiedGrid extends the numpy MaskedArray class by adding geospatial functionalities (i.e. projection awareness, boundingboxes, raster algebra). RectifiedGrid employs rasterio and fiona under the hood for raster and vector I/O and owslibto access data through OGC interoperable services.

RectifiedGrid has been initialy developed to support Integrated Coastal Management and Maritime Spatial Planning analyses.

Usage

Reading and plot GeoTIFF

import rectifiedgrid as rg
grid = rg.read_raster('test/data/adriatic_ionian.tiff', masked=True)
grid.plotmap()

Alt text

Plotting options

RectifiedGrid wraps Matplotlib Basemap Toolkit functions.

grid.plotmap(rivers=True, countries=True,
             grid=True, coast=True)

Alt text

Map algebra: Ndvi calculation

import rectifiedgrid as rg

b4 = rg.read_raster('test/data/b04.tiff', masked=True)
b8 = rg.read_raster('test/data/b08.tiff', masked=True)

ndvi = (b8 - b4)/(b8 + b4)
ndvi.plotmap(cmap=cmap_ndvi, legend=True, vmin=-1, vmax=1)

Alt text

Wrapping array-wise functions: distance from coast

RectifiedGrid implements a function wrapper (wrap_func) to apply array-wise functions.

In this example we use the distance_transform_bf (from scipy.ndimage,morphology) to calculate the distance from the coast for the Adriatic-Inonian region.

from scipy.ndimage.morphology import distance_transform_bf
distances = grid.wrap_func(distance_transform_bf)

# plotting
plt.figure(figsize=[10, 8])
distances.plotmap(rivers=True, countries=True,
             grid=True, coast=True, legend=True)

Alt text

How to Cite

Please, when you use rectifiedgrid cite as:

Menegon S, Sarretta A, Barbanti A, Gissi E, Venier C. (2016) Open source tools to support Integrated Coastal Management and Maritime Spatial Planning. PeerJ Preprints 4:e2245v2. doi: [10.5334/jors.106] (https://doi.org/10.7287/peerj.preprints.2245v2)

About

Geospatial Python library for geospatial grid-based analyses

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%