Skip to content

Commit

Permalink
Merge pull request #1 from DahnJ/feature/dj-kring-polyfill
Browse files Browse the repository at this point in the history
Feature/dj kring polyfill
  • Loading branch information
DahnJ authored Jun 24, 2021
2 parents 2fc85bc + 18c1f24 commit 9c1536a
Show file tree
Hide file tree
Showing 29 changed files with 4,604 additions and 654 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
[run]
branch = True
source = h3_pandas
omit =
setup.py
versioneer.py
h3pandas/_version.py

[report]

Expand Down
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[flake8]
max-line-length = 110
max-line-length = 88
ignore = E203
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
h3pandas/_version.py export-subst
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 21.6b0
hooks:
- id: black
language_version: python3

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
language_version: python3
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include README.md
include LICENSE
graft h3pandas
recursive-include * *.py[co]
include versioneer.py
include h3pandas/_version.py
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

372 changes: 0 additions & 372 deletions Pipfile.lock

This file was deleted.

36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
Integrates [H3](https://github.com/uber/h3-py) with [GeoPandas](https://github.com/geopandas/geopandas)
and [Pandas](https://github.com/pandas-dev/pandas).

[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DahnJ/H3-Pandas/blob/master/notebook/example.ipynb)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/DahnJ/H3-Pandas/HEAD?filepath=%2Fnotebook%2Fexample.ipynb)
[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/DahnJ/H3-Pandas/blob/master/notebook/00-intro.ipynb)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/DahnJ/H3-Pandas/HEAD?filepath=%2Fnotebook%2F00-intro.ipynb)
[![image](https://img.shields.io/pypi/v/h3pandas.svg)](https://pypi.python.org/pypi/h3pandas)
[![image](https://pepy.tech/badge/h3pandas)](https://pepy.tech/project/h3pandas)
[![Anaconda-Server Badge](https://anaconda.org/dahn/h3pandas/badges/downloads.svg)](https://anaconda.org/dahn/h3pandas)
Expand All @@ -20,12 +20,12 @@ and [Pandas](https://github.com/pandas-dev/pandas).
---

<h3 align="center">
⬢ <a href="https://mybinder.org/v2/gh/DahnJ/H3-Pandas/HEAD?filepath=%2Fnotebook%2Fexample.ipynb">Try it out</a> ⬢
⬢ <a href="https://mybinder.org/v2/gh/DahnJ/H3-Pandas/HEAD?filepath=%2Fnotebook%2F00-intro.ipynb">Try it out</a> ⬢
</h3>

---
<p align="center">
<a href=""><img src="https://i.imgur.com/FLeAqjL.gif" alt="example usage" width="450"></a>
<a href=""><img src="https://i.imgur.com/6XrsLOJ.gif" alt="example usage" width="450"></a>
</p>


Expand All @@ -49,11 +49,10 @@ conda install -c dahn h3pandas
>>> import h3pandas
>>> df = pd.DataFrame({'lat': [50, 51], 'lng': [14, 15]})
```
### H3 api
### H3 API
`h3pandas` automatically applies H3 functions to both Pandas Dataframes and GeoPandas Geodataframes



```python
>>> resolution = 10
>>> df = df.h3.geo_to_h3(resolution)
Expand All @@ -73,8 +72,9 @@ conda install -c dahn h3pandas
| 8a1e2659c2c7fff | 51 | 15 | POLYGON ((...)) |
```

### Aggregate functions
`h3pandas` also provides common aggregations in a simple API.
### H3-Pandas Extended API
`h3pandas` also provides some extended functionality out-of-the-box,
often simplifying common workflows into a single command.

```python
# Set up data
Expand All @@ -93,20 +93,20 @@ conda install -c dahn h3pandas
>>> df = df.h3.geo_to_h3_aggregate(3)
>>> df

| h3_03 | value |
|:----------------|--------:|
| 831e30fffffffff | 102 |
| 831e34fffffffff | 189 |
| 831e35fffffffff | 8744 |
| 831f1bfffffffff | 1040 |
| h3_03 | value | geometry |
|:----------------|--------:|:----------------|
| 831e30fffffffff | 102 | POLYGON ((...)) |
| 831e34fffffffff | 189 | POLYGON ((...)) |
| 831e35fffffffff | 8744 | POLYGON ((...)) |
| 831f1bfffffffff | 1040 | POLYGON ((...)) |

# Aggregate to a lower H3 resolution
>>> df.h3.h3_to_parent_aggregate(2)

| h3_02 | value |
|:----------------|--------:|
| 821e37fffffffff | 9035 |
| 821f1ffffffffff | 1040 |
| h3_02 | value | geometry |
|:----------------|--------:|:----------------|
| 821e37fffffffff | 9035 | POLYGON ((...)) |
| 821f1ffffffffff | 1040 | POLYGON ((...)) |
```

## API
Expand Down
6 changes: 4 additions & 2 deletions docs/build-docs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# /bin/bash
make clean
make html # behaves weirdly the first time, investigate later
# make html
cp -r ../notebook source/notebook
make html
rm -r source/notebook
xdg-open build/html/index.html
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ h3==3.6.*
geopandas==0.9.*
pandas==1.2.*
typing-extensions==3.10.*
numpy==1.20.*
67 changes: 36 additions & 31 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))

sys.path.insert(0, os.path.abspath("../../"))


# -- General configuration ------------------------------------------------
Expand All @@ -30,36 +31,41 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage',
'sphinx.ext.viewcode', 'numpydoc']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
"numpydoc",
"nbsphinx",
]

# numpydoc_show_class_members = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'h3pandas'
copyright = u'2021, Dahn'
author = u'Dahn'
project = u"h3pandas"
copyright = u"2021, Dahn"
author = u"Dahn"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.1'
version = u"0.1"
# The full version, including alpha/beta/rc tags.
release = u'0.1'
release = u"0.1"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -74,7 +80,7 @@
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -86,7 +92,7 @@
# a list of builtin themes.
#
html_theme = "pydata_sphinx_theme"
html_logo = '_static/logo-small.png'
html_logo = "_static/logo-small.png"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -99,25 +105,26 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
"**": [
"globaltoc.html",
"relations.html", # needs 'show_related': True theme option to display
"searchbox.html",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'h3pandasdoc'
htmlhelp_basename = "h3pandasdoc"


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -126,15 +133,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -144,19 +148,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'h3pandas.tex', u'h3pandas Documentation',
u'Dahn', 'manual'),
(master_doc, "h3pandas.tex", u"h3pandas Documentation", u"Dahn", "manual"),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'h3pandas', u'h3pandas Documentation',
[author], 1)
]
man_pages = [(master_doc, "h3pandas", u"h3pandas Documentation", [author], 1)]


# -- Options for Texinfo output -------------------------------------------
Expand All @@ -165,8 +165,13 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'h3pandas', u'h3pandas Documentation',
author, 'h3pandas', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"h3pandas",
u"h3pandas Documentation",
author,
"h3pandas",
"One line description of project.",
"Miscellaneous",
),
]

7 changes: 4 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ H3-Pandas

Welcome to the documentation of H3-Pandas!

Take a look at the :ref:`h3pandas`

.. toctree::
:hidden:
:titlesonly:

h3pandas
Notebook: Introduction <notebook/00-intro>
Notebook: Unified Data Layers <notebook/01-unified-data-layers>

19 changes: 12 additions & 7 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ name: h3pandas-env
channels:
- conda-forge
dependencies:
- python=3.8
- shapely=1.7.*
- h3-py=3.6.*
# Required
- python=3.9
- shapely
- h3-py=3.7.*
- geopandas=0.9.*
- pandas=1.2.*
- pytest=6.2.*
- pytest-cov=2.12.*
- matplotlib=3.3.*
- pandas
# For Python <3.8
# - typing_extensions
# Test
- pytest
- pytest-cov
# Notebooks
- matplotlib
6 changes: 5 additions & 1 deletion h3pandas/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
from ._version import __version__
from . import h3pandas # noqa: F401s

from ._version import get_versions

__version__ = get_versions()["version"]
del get_versions
Loading

0 comments on commit 9c1536a

Please sign in to comment.