Skip to content

Instantly share code, notes, and snippets.

View grovduck's full-sized avatar

Matt Gregory grovduck

  • Oregon State University
  • Corvallis, OR
View GitHub Profile
@grovduck
grovduck / _base.pxd
Last active November 15, 2017 21:31
[RAT support for rasterio (WIP)] Add raster attribute support to rasterio. The property raster_attributes is added to the DatasetReader object and the RAT is returned as an array of dictionaries, where each dictionary has a row's worth of field names/field values. One array is returned for each band in the dataset #rasterio #rat
# Add in _raster_attributes object
cdef class DatasetReader:
cdef public object _crs_wkt
cdef public object _transform
cdef public object _block_shapes
cdef public object _raster_attributes
@grovduck
grovduck / gdal_rat_to_pandas_df.py
Last active February 16, 2022 09:24
[RAT to pandas DF] Script for converting a GDAL RasterAttributeTable to a pandas DataFrame #pandas #gdal #rat
import sys
import pandas as pd
from osgeo import gdal
def rat_to_df(in_rat):
"""
Given a GDAL raster attribute table, convert to a pandas DataFrame
Parameters