import geopandas as gpd
import fiona
import json
from shapely.geometry import shape
定义GeoJSONL文件和输出SHP文件的路径
geojsonl_file = “path/to/input.geojsonl”
shp_file = “path/to/output.shp”
读取GeoJSONL文件并提取地理坐标信息
features = []
with open(geojsonl_file, “r”) as f:
for line in f:
feature = json.loads(line)
geometry = shape(feature[‘geometry’])
feature[‘geometry’] = geometry
features.append(feature)
将GeoJSONL转换为GeoDataFrame
gdf = gpd.GeoDataFrame.from_features(features)
保存为SHP文件
gdf.to_file(shp_file, driver=“ESRI Shapefile”)
print(“转换完成!”)