googlesat package
Submodules
googlesat.downloader module
googlesat.sentinel module
- googlesat.sentinel.geometry_from_file(geometry: str) list
Gets a path of any valid geographic file format and returns the overlaping tile names.
- Parameters:
geometry (str) – Path to geographic file
- Returns:
List of tile names
- Return type:
list
- googlesat.sentinel.get_metadata(level: str = 'L2A', store: str | None = None, force_update: bool = False) str
Downloads and updates index files from GCP. Also, creates/updates a database with the same data.
- Parameters:
level (str, optional) – Sentinel 2 data level (L2A->BOA, L1C->TOA). Defaults to ‘L2A’
store (str, optional) – Store to save database. If None then a directory is being created in cache. Defaults to None
force_update (bool, optional) – Force to update index file. Defaults to False
- Returns:
Path to database file
- Return type:
str
- googlesat.sentinel.query(db_file: str, table: str, cc_limit: float, date_start: datetime, date_end: datetime, tile: str) DataFrame
Querying Sentinel-2 index database.
- Parameters:
db_file (str) – Path to database
table (str) – Name of the table in database
cc_limit (float) – Cloud coverage percentage
date_start (dt.datetime) – Starting date
date_end (dt.datetime) – Ending date
tile (str, list) – Grid tile name
- Returns:
Result of the query
- Return type:
pd.DataFrame
googlesat.utils module
- googlesat.utils.clear_cache()
- googlesat.utils.create_connection(db_file: str)
Create a database connection to a SQLite database.
- Parameters:
db_file (str) – Path to SQLite database
- googlesat.utils.create_index(connection: <module 'sqlite3' from '/home/docs/.asdf/installs/python/3.9.18/lib/python3.9/sqlite3/__init__.py'>, name: str = 'Fill')
Create index for the table.
- Parameters:
connection (sqlite3) – Connection to database
name (str, optional) – Name of the table. Defaults to “Fill”.
- googlesat.utils.create_table(connection: <module 'sqlite3' from '/home/docs/.asdf/installs/python/3.9.18/lib/python3.9/sqlite3/__init__.py'>, name: str = 'Fill', force=False)
Create table to database.
- Parameters:
connection (sqlite3) – Connection to database
name (str, optional) – Name of the table. Defaults to “Fill”
force (bool, optional) – Force table creation. Defaults to False
- googlesat.utils.delete_dublicates(connection: <module 'sqlite3' from '/home/docs/.asdf/installs/python/3.9.18/lib/python3.9/sqlite3/__init__.py'>, name: str = 'Fill')
Delete dublicates from table.
- Parameters:
connection (sqlite3) – Connection to database
name (str, optional) – Name of the table. Defaults to “Fill”.
- googlesat.utils.downloader(url: str, name: str, verbose=True) str
Download method with urllib library.
- Parameters:
url (str) – Link to file
name (str) – Saving path with name of the downloaded file
- Returns:
Path to file
- Return type:
file (str)
- googlesat.utils.extract(file: str, chunksize: int = 100000) DataFrame
Extracts a compressed CSV file and stores it into a pandas DataFrame as chunks.
- Parameters:
file (str) – Path and name of the CSV file
chunksize (int, optional) – Chunk size. Defaults to 10**4
- Returns:
Pandas DataFrame into chunks
- Return type:
pd.DataFrame
- googlesat.utils.fill_db(connection: <module 'sqlite3' from '/home/docs/.asdf/installs/python/3.9.18/lib/python3.9/sqlite3/__init__.py'>, data: ~pandas.core.frame.DataFrame, name: str = 'Fill')
Fill an SQL database from pandas dataframe chunks.
- Parameters:
connection (sqlite3) – SQLite3 database path
data (pd.DataFrame) – Data in chunks
name (str, optional) – Name of the created table. Defaults to “Fill”.
- googlesat.utils.get_cache_dir(subdir: str | None = None) str
Function for getting cache directory to store reused files like kernels, or scratch space for autotuning, etc.
- Parameters:
subdir (str, optional) – Directory to save data. Defaults to None
- Returns:
Path to package cache directory
- Return type:
str
- googlesat.utils.get_links(data: DataFrame) DataFrame
Converts google cloud storage links to simple http links
- Parameters:
data (pd.DataFrame) – DataFrame with the result from querying the database
- Returns:
New DataFrame with http links
- Return type:
pd.DataFrame
- googlesat.utils.update_db(connection: <module 'sqlite3' from '/home/docs/.asdf/installs/python/3.9.18/lib/python3.9/sqlite3/__init__.py'>, data: ~pandas.core.frame.DataFrame, name: str = 'Fill')
Updates database with new entries. #BUG: Updating is slower than recreating database from scratch.
- Parameters:
connection (sqlite3) – SQLite3 database path
data (pd.DataFrame) – Data in chunks
name (str, optional) – Name of the created table. Defaults to “Fill”.