@@ -201,7 +201,7 @@ def write_geoparquet(
201201
202202 def to_geoarrow (
203203 self ,
204- geometry_name : List [str ]| str = ["geometry" ],
204+ geometry_name : List [str ] | str = ["geometry" ],
205205 ):
206206 r"""
207207 Converts the dataframe to geoarrow table.
@@ -260,7 +260,7 @@ def to_geoarrow(
260260 )
261261
262262 pa_table = self ._df .drop (geometry_name ).to_arrow ()
263-
263+
264264 for this_g_name in geometry_name :
265265 crs = pyproj .CRS (self ._df [this_g_name ].struct .field ("crs" )[0 ]).to_wkt (
266266 version = "WKT1_GDAL"
@@ -654,6 +654,7 @@ def viz(
654654
655655 """
656656 from lonboard import viz
657+
657658 geoarrow_table = self .to_geoarrow (geometry_name )
658659
659660 return viz (
@@ -698,7 +699,7 @@ def to_scatterplotlayer(
698699 visible : bool = True ,
699700 antialiasing : bool = True ,
700701 billboard : bool = False ,
701- ** kwargs
702+ ** kwargs ,
702703 ) -> ScatterplotLayer :
703704 """
704705 Makes a Lonboard [ScatterplotLayer][lonboard.ScatterplotLayer] from the SpatialFrame.
@@ -927,7 +928,7 @@ def to_scatterplotlayer(
927928 radius_units = radius_units ,
928929 stroked = stroked ,
929930 visible = visible ,
930- ** kwargs
931+ ** kwargs ,
931932 )
932933 return layer
933934
@@ -954,7 +955,7 @@ def to_pathlayer(
954955 width_max_pixels : Optional [float ] = None ,
955956 width_scale : float = 1 ,
956957 width_units : Literal ["meters" , "common" , "pixels" ] = "meters" ,
957- ** kwargs
958+ ** kwargs ,
958959 ) -> PathLayer :
959960 """
960961 Makes a Lonboard [PathLayer][lonboard.PathLayer] from the SpatialFrame.
@@ -1041,7 +1042,6 @@ def to_pathlayer(
10411042 from lonboard import PathLayer
10421043 from lonboard .colormap import apply_continuous_cmap , apply_categorical_cmap
10431044
1044-
10451045 validate_cmap_input (
10461046 self ._df , cmap_col , cmap_type , cmap , alpha , normalize_cmap_col
10471047 )
@@ -1094,7 +1094,7 @@ def to_pathlayer(
10941094 width_max_pixels = width_max_pixels ,
10951095 width_scale = width_scale ,
10961096 width_units = width_units ,
1097- ** kwargs
1097+ ** kwargs ,
10981098 )
10991099 return layer
11001100
@@ -1130,7 +1130,7 @@ def to_polygonlayer(
11301130 pickable : bool = True ,
11311131 visible : bool = True ,
11321132 wireframe : bool = False ,
1133- ** kwargs
1133+ ** kwargs ,
11341134 ) -> PolygonLayer :
11351135 """
11361136 Makes a Lonboard [PolygonLayer][lonboard.PolygonLayer] from the SpatialFrame.
@@ -1354,7 +1354,7 @@ def to_polygonlayer(
13541354 stroked = stroked ,
13551355 visible = visible ,
13561356 wireframe = wireframe ,
1357- ** kwargs
1357+ ** kwargs ,
13581358 )
13591359 return layer
13601360
@@ -1502,6 +1502,14 @@ def from_WKB(df: pl.DataFrame, wkb_col: str, crs: Any = 4326):
15021502 """
15031503 crs_wkt = pyproj .CRS .from_user_input (crs ).to_wkt ()
15041504
1505+ if wkb_col == "geometry" :
1506+ return df .with_columns (
1507+ pl .struct (
1508+ c (wkb_col ).alias ("wkb_geometry" ),
1509+ pl .lit (crs_wkt , dtype = pl .Categorical ).alias ("crs" ),
1510+ ).alias ("geometry" )
1511+ )
1512+
15051513 return df .with_columns (
15061514 pl .struct (
15071515 c (wkb_col ).alias ("wkb_geometry" ),
@@ -1573,6 +1581,15 @@ def from_WKT(df, wkt_col: str, crs: Any = 4326):
15731581 geoms = shapely .from_wkt (df .select (wkt_col ).to_series ().to_numpy ().copy ())
15741582 wkb_array = shapely .to_wkb (geoms )
15751583 crs_wkt = pyproj .CRS .from_user_input (crs ).to_wkt ()
1584+
1585+ if wkt_col == "geometry" :
1586+ return df .with_columns (
1587+ pl .struct (
1588+ pl .Series ("wkb_geometry" , wkb_array , dtype = pl .Binary ),
1589+ pl .lit (crs_wkt , dtype = pl .Categorical ).alias ("crs" ),
1590+ ).alias ("geometry" )
1591+ )
1592+
15761593 return df .with_columns (
15771594 pl .struct (
15781595 pl .Series ("wkb_geometry" , wkb_array , dtype = pl .Binary ),
0 commit comments