Skip to content

GIS Integration

GeoPandas and pandas DataFrame helpers. These functions let you convert a GeoDataFrame or a plain DataFrame into cesiumkit Entity objects with a single call.

Install the optional dependencies with:

pip install cesiumkit[gis]

gis

GeoPandas / pandas integration for cesiumkit.

Convert GeoDataFrame and plain DataFrame objects into lists of Entity in one call. GeoPandas and shapely are optional dependencies — install with pip install cesiumkit[gis].

geodataframe_to_entities(gdf, *, name_column=None, description_column=None, color=None, color_column=None, fill_alpha=0.5, stroke=None, stroke_width=2.0, height=0.0, height_column=None, extruded_height_column=None, point_pixel_size=8.0)

Convert a geopandas.GeoDataFrame to a list of Entity objects.

The GeoDataFrame is reprojected to EPSG:4326 (WGS84 lon/lat) if a CRS is set and it is not already 4326.

Parameters:

Name Type Description Default
gdf Any

The geopandas.GeoDataFrame to convert.

required
name_column str | None

Column to use for each entity's name.

None
description_column str | None

Column to use for each entity's description.

None
color Any

Default color for all entities. Accepts a Color, a CSS/hex string, or a named-color string (e.g. "RED").

None
color_column str | None

Column with a per-feature color (same types as color). Overrides color on a per-row basis.

None
fill_alpha float

Alpha value for polygon fill (default 0.5).

0.5
stroke Any

Outline color for polygons / line color for polylines.

None
stroke_width float

Outline / polyline width in pixels (default 2).

2.0
height float

Base height for polygons if no column is specified.

0.0
height_column str | None

Column with per-row polygon base heights.

None
extruded_height_column str | None

Column with per-row polygon extruded heights. Use this to extrude polygons into 3D volumes (e.g. building footprints).

None
point_pixel_size float

Size in pixels for Point entities.

8.0

Returns:

Type Description
list[Entity]

A list of Entity objects ready to add to a Viewer.

Raises:

Type Description
ImportError

if geopandas is not installed.

ValueError

if the GeoDataFrame contains an unsupported geometry type.

dataframe_to_entities(df, lon_col, lat_col, *, height_col=None, name_column=None, description_column=None, color=None, color_column=None, point_pixel_size=8.0)

Convert a plain pandas.DataFrame with lon/lat columns to point entities.

This is a convenience wrapper for the most common case — a CSV of points — that avoids requiring GeoPandas. Only produces Point entities.

Parameters:

Name Type Description Default
df Any

A pandas.DataFrame.

required
lon_col str

Name of the longitude column.

required
lat_col str

Name of the latitude column.

required
height_col str | None

Optional column for point heights (meters above ellipsoid).

None
name_column str | None

Column to use for each entity's name.

None
description_column str | None

Column to use for each entity's description.

None
color Any

Default color for all points.

None
color_column str | None

Column for per-feature color.

None
point_pixel_size float

Point size in pixels.

8.0

Returns:

Type Description
list[Entity]

A list of Entity objects with PointGraphics attached.