Hi. I’m on n8n 2.16.1, self-hosted, with docker, docker runners with geopandas installed.
I am pulling data from 3 Baserow tables (buildings, entrances, documents). I am making a compound JSON and I am pre-fetching all files.
Then, I want to use a Python node to use geopandas to export my geo data into a geo bundle (gpkg, and to a lesser extent gpx/geojson/…). My issue is, I don’t know how to access the binary blob data with Python, and geopandas is a Python lib. When I select subdicts of the binary object, I only ever get metadata, never the underlying data.
Thank you.
This is how I try to generate my “bundle”:
import base64
import io
import geopandas
from shapely.geometry import Point
FILENAME = "gpd_export.gpkg"
gdf_prep = []
def b64(bytes):
return base64.b64encode(bytes).decode("utf-8")
for building in _items:
prep_common = {
"name": building["json"].get("Name"),
...
}
for idx, bin in enumerate(building["binary"].items()):
prep_common[f"doc_{idx:02}"] = bin
# bin['binary]
# bin['binary]['...]
# bin['binary]['...]['data]
# only ever passes the metadata, not the actual binary blob
for entrance in building["json"]["entrances"]:
if not entrance.get("lon") or not entrance.get("lat"):
continue
prep_point = prep_common.copy()
prep_point["geometry"] = Point(
float(entrance["lon"]), float(entrance["lat"])
)
gdf_prep.append(prep_point)
gdf = geopandas.GeoDataFrame(gdf_prep, crs="EPSG:4326")
io_file = io.BytesIO()
gdf.to_file(io_file, driver="GPKG")
io_file.seek(0)
gpkg_bytes = io_file.read()
return [
{
"json": {
"filename": FILENAME,
"itemCount": 1,
},
"binary": {
"geo_bundle": {
"data": b64(gpkg_bytes),
"mimeType": "application/geopackage+sqlite3",
"fileName": FILENAME,
}
},
}
]