Raster To DataFrame¶
A simple python module that converts a raster to a Pandas DataFrame.
from rastertodataframe import raster_to_dataframe raster_path = '/some/gdal/compatible/file.tif' vector_path = '/some/ogr/compatible/file.geojson' # Extract all image pixels (no vector). df = raster_to_dataframe(raster_path) # Extract only pixels the vector touches and include the vector metadata. df = raster_to_dataframe(raster_path, vector_path=vector_path)
- Free software: MIT license
- Documentation: https://rastertodataframe.readthedocs.io.
- Convert any GDAL compatible raster to a Pandas DataFrame.
- Optionally, if any OGR compatible vector file is given, only pixels touched by the vector are extracted from the raster. The output DataFrame includes these pixels as well as any attributes from the vector file.
pip install rastertodataframe
- A working GDAL/OGR installation is required. This is best accomplished with conda.
conda install -c conda-forge numpy gdal geopandas pandas pyproj