-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
206 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
API | ||
=== | ||
|
||
.. autosummary:: | ||
:toctree: generated | ||
|
||
scalenav |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "plaintext" | ||
} | ||
}, | ||
"source": [ | ||
"# A OOP approach to hierarchically indexed data tables \n", | ||
"This notebook defines the schema and relations that will be implemented to facilitate the workflows projecting global data sets on a hierarchical index and manipulating different layers together. \n", | ||
"Mainly, this approach aims to solve the following challenges:\n", | ||
"- User friendly : ideally have a familiar sytax to pandas users\n", | ||
"- Scalable : be able to work with national, continetal and even global data sets of fine spatial resolution (ex: 100m,1000m grids)\n", | ||
"- Flexible : it should provide a easily exportable type of data to use across different types of processes and analyses.\n", | ||
"\n", | ||
"The main tools chosen to do this are : \n", | ||
"\n", | ||
"* Using H3 : https://uber.github.io/h3-py/\n", | ||
"* Using DuckDB : https://duckdb.org/docs/guides/python/execute_sql \n", | ||
"* Using ibis : https://ibis-project.org \n", | ||
"\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Base workflow\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"One of the main contributions of this workflow is a method to efficiently project raster grids of any size into a format that is more efficient to work with and perform geometric operations with other types. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Minimal input\n", | ||
"\n", | ||
"[ polars.DataFrame, pyarrow.Table, pandas.DataFrame, geopandas.GeoDataFrame(not recommended), ibis.table ]\n", | ||
"\n", | ||
"WIth non ambiguous columns for the coordinates, ex ('x','y'), ('lon','lat') etc .... and variables containing numeric values with a suffix *var* or containing categorical values with suffix *cat* preceding the actual column name *{band}*." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n", | ||
"| lon | lat | {band}_var | ... |\n", | ||
"|-------|-------|-------------|---------------|\n", | ||
"| float | float | [float,int] | ... |\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\n", | ||
"| lon | lat | {band}_cat | ... |\n", | ||
"|-------|-------|----------|-----|\n", | ||
"| float | float | str | ... |" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Minimal output\n", | ||
"\n", | ||
"The data is projected to the h3 grid for a resolution which is refered to later on as the native resolution. It should be the highest possible resolution that makes sense for a given data layer. For example for points data, any resolution is possible, and the choise will most likely depend on the type of processing that is done with it. \n", | ||
"In the case of polygons, a resolution high enough to give a good description of the original shape, but coarse enough to be efficient to work with. Once again, this is context specific and will most likely depend on the type of analysis.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"| lon | lat | {band}_cat | ... | h3_id |\n", | ||
"|-------|-------|----------|-----|-----------|\n", | ||
"| float | float | str | ... | [str,int] |" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"| lon | lat | {band}_var | ... | h3_id |\n", | ||
"|-------|-------|-------------|--------|-----------|\n", | ||
"| float | float | [float,int] | ... | [str,int] |\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"A mix of the two previous tyopes of numeric or categorical variables can be present as long as the *coordinates* and *h3_id* columns are unambiguiously identified. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The object to which the data is associated contains additional attributes and methods descrbed next:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Class" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Attributes\n", | ||
"- base_res : base resolution, the original resolution into which the data was projected on the h3 grid\n", | ||
"- current_res : current resolution, the resolution in which the data currently is after potential processing. \n", | ||
"### Methods\n", | ||
"- set_res(res) : int(4,18), set the resolution of the data to a specifed one.\n", | ||
"- change_res(level) : int, change the resolution of the data by a value provided. the reuslting resolution will be equal to *current_res*+*level*\n", | ||
"- add_layer()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from pathlib import Path | ||
import os | ||
|
||
configs = { | ||
"size_lim" : "500MB" | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
class Layer: | ||
|
||
base_res : int | ||
current_res : int | ||
src : str | ||
|
||
def __init__(self) -> None: | ||
"""Validation of the input source goes here. What is the schema ? """ | ||
pass | ||
|
||
def change_res(): | ||
pass | ||
|
||
def set_res(): | ||
pass | ||
|
||
def restore(): | ||
pass | ||
|
||
def get_data(): | ||
pass | ||
|
||
geom_column = ["x","lon","lng","longitude","y","lat","ltd","latitude","geom","geometry"] | ||
|
||
class DataLayer(Layer): | ||
def __init__(self) -> None: | ||
super().__init__() |