shapelysmooth

2024-08-29  本文已影响0人  hehehehe
from shapely import LineString
from shapelysmooth import chaikin_smooth

from tools import geoutil

line = geoutil.from_wkt_safe(
    "LineString Z (116.58801699999999357 40.07140499999999861 0, 116.58801800000000526 40.07140799999999814 0, 116.58801800000000526 40.0714139999999972 0, 116.5880159999999961 40.07144900000000121 0, 116.58801400000000115 40.07157899999999984 0, 116.5880120000000062 40.07170700000000352 0, 116.58800800000000208 40.07190800000000053 0, 116.58800499999999545 40.07208899999999829 0, 116.5880030000000005 40.07217800000000096 0, 116.5879939999999948 40.07269000000000148 0, 116.58799100000000237 40.07281299999999646 0, 116.5879900000000049 40.07289999999999708 0, 116.58799100000000237 40.07293200000000155 0, 116.58799199999999985 40.07294900000000126 0, 116.58799799999999891 40.07298699999999769 0, 116.58800499999999545 40.07301700000000011 0, 116.58801300000000367 40.07304299999999841 0, 116.58802199999999516 40.07306799999999924 0, 116.58803399999999328 40.07309300000000007 0, 116.58804600000000562 40.07311899999999838 0, 116.5880470000000031 40.07311899999999838 0, 116.58806199999999365 40.07314399999999921 0, 116.58807899999999336 40.07316999999999751 0, 116.58809999999999718 40.07319799999999788 0, 116.58812000000000353 40.07322099999999665 0, 116.58812500000000512 40.07322599999999824 0, 116.58813800000000072 40.07323900000000094 0, 116.58814800000000389 40.07324799999999954 0, 116.58815800000000706 40.07325900000000019 0, 116.58816299999999444 40.07326299999999719 0, 116.58817700000000173 40.07327500000000242 0, 116.58818800000000238 40.07328400000000101 0, 116.58821600000000274 40.07330499999999773 0, 116.588247999999993 40.07332699999999903 0, 116.58827499999999588 40.07334300000000127 0, 116.58828300000000411 40.07334699999999827 0, 116.58830600000000288 40.07336000000000098 0, 116.58834099999999978 40.07337700000000069 0, 116.58835999999999444 40.07338500000000181 0, 116.58837099999999509 40.07338899999999882 0, 116.58838199999999574 40.0733940000000004 0, 116.58838599999999985 40.07339499999999788 0, 116.58840899999999863 40.07340399999999647 0, 116.58842799999999329 40.07341000000000264 0, 116.58844299999999805 40.07341499999999712 0, 116.58847299999999336 40.07342299999999824 0, 116.58850099999999372 40.07343000000000188 0, 116.58853600000000483 40.07343699999999842 0, 116.58856299999999351 40.07344200000000001 0, 116.58858399999999733 40.07344499999999954 0, 116.58859599999999546 40.07344700000000159 0, 116.58861199999999769 40.07344799999999907 0, 116.58861500000000433 40.07344799999999907 0, 116.58862299999999834 40.07344899999999654 0, 116.58863999999999805 40.0734509999999986 0, 116.58866799999999841 40.07345300000000066 0, 116.58869400000000383 40.07345600000000019 0, 116.58875600000000361 40.07346100000000177 0)")
print(f"{line.wkt=}")
print(f"{len(line.coords)=}")

simplified_line = line.simplify(tolerance=0.0000001)
print(f"{simplified_line.wkt=}")
print(f"{len(simplified_line.coords)=}")

smooth = chaikin_smooth(line.coords)
smooth_line = LineString(smooth)
print(f"{smooth_line.wkt=}")
print(f"{len(smooth_line.coords)=}")

simplified_smooth_line = smooth_line.simplify(tolerance=0.0000001)
print(f"{simplified_smooth_line.wkt=}")
print(f"{len(simplified_smooth_line.coords)=}")

上一篇 下一篇

猜你喜欢

热点阅读