h3-pyspark: Uber's H3 Hexagonal Hierarchical Geospatial Indexing System in PySpark
PySpark bindings for the H3 core library.
For available functions, please see the vanilla Python binding documentation at:
Installation
From PyPI
:
pip install h3-pyspark
From conda
conda config --add channels conda-forge
conda install h3-pyspark
Usage
>>> from pyspark.sql import SparkSession, functions as F
>>> import h3_pyspark
>>>
>>> spark = SparkSession.builder.getOrCreate()
>>> df = spark.createDataFrame([{"lat": 37.769377, "lng": -122.388903, 'resolution': 9}])
>>>
>>> df = df.withColumn('h3_9', h3_pyspark.geo_to_h3('lat', 'lng', 'resolution'))
>>> df.show()
+---------+-----------+----------+---------------+
| lat| lng|resolution| h3_9|
+---------+-----------+----------+---------------+
|37.769377|-122.388903| 9|89283082e73ffff|
+---------+-----------+----------+---------------+
Publishing
- Bump version in
setup.cfg
- Publish:
python3 -m build
python3 -m twine upload --repository pypi dist/*