Skip to content

Commit

Permalink
remove pandas dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestfwilliams committed Sep 24, 2024
1 parent 604eb77 commit c5837e2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ dependencies:
- sqlite
- shapely
- pyproj
- pandas
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies = [
# "sqlite3", Not sure why including this breaks installs
"shapely",
"pyproj",
"pandas",
]
dynamic = ["version", "readme"]

Expand Down
25 changes: 13 additions & 12 deletions src/opera_disp_tms/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pathlib import Path
from typing import Iterable, Optional, Union

import pandas as pd
import requests
from shapely import from_wkt
from shapely.geometry import Polygon, box
Expand All @@ -23,15 +22,15 @@ class Frame:
geom: Polygon

@classmethod
def from_record(cls, record):
def from_row(cls, row):
return cls(
frame_id=record['frame_id'],
epsg=record['epsg'],
relative_orbit_number=record['relative_orbit_number'],
orbit_pass=record['orbit_pass'],
is_land=record['is_land'],
is_north_america=record['is_north_america'],
geom=from_wkt(record['wkt']),
frame_id=row[0],
epsg=row[1],
relative_orbit_number=row[2],
orbit_pass=row[3],
is_land=row[4],
is_north_america=row[5],
geom=from_wkt(row[6]),
)


Expand Down Expand Up @@ -81,7 +80,7 @@ def intersect(
orbit_pass: Optional[str] = None,
is_north_america: Optional[bool] = None,
is_land: Optional[bool] = None,
) -> pd.DataFrame:
) -> Iterable[Frame]:
"""Query for frames intersecting a given bounding box or WKT geometry, optionally filtering by orbit pass."""
if orbit_pass and orbit_pass not in ['ASCENDING', 'DESCENDING']:
raise ValueError('orbit_pass must be either "ASCENDING" or "DESCENDING"')
Expand Down Expand Up @@ -133,7 +132,9 @@ def intersect(
with sqlite3.connect(DB_PATH) as con:
con.enable_load_extension(True)
con.load_extension('mod_spatialite')
df_intersecting_frames = pd.read_sql_query(query, con, params=params)
cursor = con.cursor()
cursor.execute(query, params)
rows = cursor.fetchall()

intersecting_frames = df_intersecting_frames.apply(Frame.from_record, axis=1)
intersecting_frames = [Frame.from_row(row) for row in rows]
return intersecting_frames
1 change: 0 additions & 1 deletion src/opera_disp_tms/generate_frame_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def burn_frame(frame: Frame, tile_path: Path):
frame_ds = None
tile_band.FlushCache()
tile_ds = None
# tmp_tiff.unlink()


def create_empty_frame_tile(bbox: Iterable[int], out_path: Path) -> Path:
Expand Down

0 comments on commit c5837e2

Please sign in to comment.