为什么Shapely的捕捉(GEO捕捉)无法按预期工作?
我试图使用Shapely / Geopandas将两条线彼此对齐,但是对齐的结果非常奇怪。我试过了 : import geopandas as gpd from shapely.geometry import * from shapely.ops import snap lines1 = gpd.GeoDataFrame.from_file('lines1.shp') lines1 = lines1.to_crs({'init': 'epsg:2227'}) lines2 = gpd.GeoDataFrame.from_file('lines2.shp') lines2 = lines2.to_crs({'init': 'epsg:2227'}) res = lines1 lines2_union = lines2.geometry.unary_union res.geometry = res.geometry.apply(lambda x: snap(x, lines2_union, 14)) res.to_file('result.shp', driver="ESRI Shapefile") 并得到了这个结果: lines1 = 红色线 …