博文

目前显示的是 2026的博文

polars_st 绘制地图

  import polars as pl import polars_st as st import altair as alt import json alt . data_transformers . enable ( "vegafusion" ) luis = st . read_file ( '/mnt/c/Users/xuefliang/Downloads/tl_2023_22_prisecroads/tl_2023_22_prisecroads.shp' ) features = [     { "type" : "Feature" , "geometry" : json . loads (r. pop ( "geometry" )), "properties" : r}     for r in luis . st . to_geojson (). to_dicts () ] chart = alt . Chart ( alt . Data ( values = features )). mark_geoshape (     filled = False ,     stroke = 'steelblue' ,     strokeWidth = 1 ). properties (     width = 800 ,     height = 600 ,     title = "Louisiana Primary Roads Map" ). project (     type = 'mercator' ) chart # 使用命名空间名称 'map' @ pl . api . register_dataframe_namespace ( "map" ) class GeoPlotter :     def __init__ ( self , df : pl . DataFrame ):         self . _df = df    ...