I am attempting to perform a union on two rasters I pick from my postgis database using GeoAlchemy2.
I have a Raster table defined:
from geoalchemy2 import Raster
from sqlalchemy.sql import func
Base = declarative_base()
class RasterData(Base):
'''
Raster class
'''
__tablename__ = 'images'
__table_args__ = {"schema": "public"}
raster = Column(Raster)
Then I attempt to use ORM to union two raster tiles using
engine = create_engine(db_str, echo=False)
Session = sessionmaker(bind=engine)
session = Session(expire_on_commit=False)
rasters = session.query(RasterData.raster).limit(2).all()
merged = session.query(func.ST_Union(rasters)).all()
This unfortunately errors out with:
psycopg2.ProgrammingError: can't adapt type 'RasterElement'
The above exception was the direct cause of the following exception:
It seems I might need to cast this as something else but I am unsure what. Any ideas what the code above is missing to complete the union?