Motivation
This is an idea that has been hitching my brain for some times now. I grow frustrated seeing people running toward FME for very simple data transformations. Nothing against that in itself, but having alternatives is always good.
There are obviously the amazing geopandas and polars-st. But these libraries take sometimes to learn and I feel there is too much friction for someone using FME regularly to even consider using them.
So I experimented a sort of ETL API that would be approached the same way you would construct a FME workspace: start with a reader, chain transformations and write the result.
Example
This would look like :
from papotch import Reader
r = Reader("path/to/data.shp")
d = r.extract()
d.head()
ββββββ¬ββββββββββ¬ββββββββββ¬βββββββββββ¬ββββββββββββββββββββββββββββββ
βid βvalue_intβvalue_txtβvalue_boolβgeometry β
β--- β--- β--- β--- β--- β
βi64 βi64 βstr βbool βstr β
ββββββͺββββββββββͺββββββββββͺβββββββββββͺββββββββββββββββββββββββββββββ‘
β0 β0 βtest βtrue βPOLYGON ((2532293.4834 11600β¦β
β1 β1 βΓ©jwefw βfalse βPOLYGON ((2548329.787 115443β¦β
β2 β2 βkjprg βfalse βPOLYGON ((2538461.2386 11469β¦β
βnullβnull βnull βfalse βPOLYGON ((2532026.1 1159262.β¦β
βnullβnull βnull βfalse βPOLYGON ((2530319.7138 11547β¦β
ββββββ΄ββββββββββ΄ββββββββββ΄βββββββββββ΄ββββββββββββββββββββββββββββββ
# Buffer, calculate the resulting area, then the bounding coordinates.
_ = d.buffer(distance=2).area(column_name="calc_area").bounds()
d.head()
ββββββ¬ββββββββββ¬ββββββββββ¬βββββββββββ¬ββββββββββββββββ¬ββββββββββ¬βββββββββββββββββββββββββ
βid βvalue_intβvalue_txtβvalue_boolβgeometry βcalc_areaβ_bounds β
β--- β--- β--- β--- β--- β--- β--- β
βi64 βi64 βstr βbool βbinary βf64 βarray[f64, 4] β
ββββββͺββββββββββͺββββββββββͺβββββββββββͺββββββββββββββββͺββββββββββͺβββββββββββββββββββββββββ‘
β0 β0 βtest βtrue βb"\x01\x03\x08β¦β112.79491β[2.5323e6,1.16e6,β¦1.16eβ¦β
β1 β1 βΓ©jwefw βfalse βb"\x01\x03\x08β¦β112.79491β[2.5483e6,1.15e6,β¦1.15eβ¦β
β2 β2 βkjprg βfalse βb"\x01\x03\x08β¦β112.79491β[2.5385e6,1.14e6,β¦1.14eβ¦β
βnullβnull βnull βfalse βb"\x01\x03\x08β¦β112.79491β[2.5320e6,1.15e6,β¦1.15eβ¦β
βnullβnull βnull βfalse βb"\x01\x03\x08β¦β112.79491β[2.5303e6,1.15e6,β¦1.15eβ¦β
ββββββ΄ββββββββββ΄ββββββββββ΄βββββββββββ΄ββββββββββββββββ΄ββββββββββ΄βββββββββββββββββββββββββ
d.write("PG:service=my_service", layer="my_layer")All the heavy lifting is done by polars-st, papotch would just be an opiniated abstraction simplifying operations for someone who wants a quick pipeline. At the cost of flexibility of course.
Installation
You can install papotch from the pypi index.
pip install papotchRepository
The code is hosted on Codeberg.
Documentation
The API documentation is accessible at papotch.jujube.ch.