Commit 98a628b8 authored by Wit, Allard de's avatar Wit, Allard de
Browse files

first grompy reader for S2

parent ce70df8a
\ No newline at end of file
\ No newline at end of file
- sentinel2
from .grompy import DataAccesProvider
\ No newline at end of file
from .dap import DataAccessProvider
\ No newline at end of file
......@@ -4,16 +4,21 @@ import pandas as pd
class DataAccessProvider:
def __init__(self, dsn=None, area_gt=None, pixcount_gt=None, provincie=None):
def __init__(self, dsn=None, area_gt=None, pixcount_gt=None, provincie=None, limit=None, gws_gewasc=None):
self.engine = sa.create_engine(dsn)
meta = sa.MetaData(self.engine)
self.tbl_perc_info = sa.Table('perceels_info', meta, autoload=True)
self.s2_observations = sa.Table("s2_observations", meta, autoload=True)
if limit is None:
limit = int(1e9)
self.limit = limit
self.perc_stmt =[self.tbl_perc_info])
if area_gt is not None:
self.perc_stmt.append_whereclause(self.tbl_perc_info.c.area == area_gt)
self.perc_stmt.append_whereclause(self.tbl_perc_info.c.area_ha > area_gt)
if gws_gewasc is not None:
self.perc_stmt.append_whereclause(self.tbl_perc_info.c.gws_gewasc == gws_gewasc)
if pixcount_gt is not None:
self.perc_stmt.append_whereclause(self.tbl_perc_info.c.pixcount > pixcount_gt)
if provincie is not None:
......@@ -24,7 +29,7 @@ class DataAccessProvider:
def __iter__(self):
r = self.perc_stmt.execute()
r = self.perc_stmt.limit(self.limit).execute()
rows = r.fetchmany(100)
while rows:
for row in rows:
......@@ -38,9 +43,6 @@ class DataAccessProvider:
rows = r.fetchmany()
def __len__(self):
return self.count
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment