gpt4 book ai didi

Python + MySQL : Insert geojson polygon value to mysql sptial column

转载 作者:行者123 更新时间:2023-11-29 18:18:06 24 4
gpt4 key购买 nike

我有一个包含多边形数据的 geojson 文件。下面是它的示例。

[[[127.00733253963132, 37.583203339216226], 
[127.00884131783923, 37.58045263873488],
[127.00861398800201, 37.57670881432089],
[127.00783306341832, 37.57663511179821],
[126.99967765278153, 37.57589728327857],
[126.9971834726848, 37.57693224535312],
[126.99675796489285, 37.578422160319896],
[126.99660663904614, 37.579345394336194],
[126.99641172469617, 37.580645880422686],
[126.99649978451932, 37.581022567729896],
[126.99823026308687, 37.581266540341],
[127.00180462191403, 37.58253031283794],
[127.00172112834049, 37.583133635452405],
[127.00272082947205, 37.583723680505784],
[127.00580459526145, 37.584756278282704],
[127.00618219538146, 37.58396129485959],
[127.00733253963132, 37.583203339216226]]]

我在 mysql 中有空间表。我正在尝试使用行 sql 将此多边形数据插入到多边形列中,但是始终失败。后来,我发现插入mysql数据库中的多边形数据看起来和我的有点不同。这是我从网上教程中看到的数据。

((126.97688884274817 37.575650779448786,  
126.9770344988775 37.569194530054546,
126.97597472821249 37.569336299425764,
126.97537470991254 37.569315567021562,
126.97433193562325 37.569261800517531,
126.96904837001854 37.568194417708312,
126.96854493603384 37.568427679612753,
126.9666499598212 37.569491655206569,
126.96628175024485 37.569700734798701,
126.9660973270804 37.569856509723699,
126.96572852922577 37.570183936115114,
126.96592699822128 37.570318805686199,
126.96601094018429 37.57154839557748,
126.96365922052196 37.575174660660359,
126.96308600434513 37.576485920015529,
126.96284099051198 37.576661586092726,
126.96281041047263 37.579448809656768,
126.96742431584332 37.579601537124489,
126.96742176302651 37.579263521441646,
126.9674300601846 37.579192577998612,
126.96745709009561 37.578975250585444,
126.96806604699626 37.578246780467865,
126.96895511695477 37.577935262340283,
126.96921284296906 37.577935299309395,
126.96941453886579 37.578121124142172,
126.96966442669471 37.578531136682209,
126.96966721914872 37.578736205134923,
126.96966877353309 37.578992879009881,
126.96966949910363 37.579112526749597,
126.96990457361626 37.579301753628719,
126.97135197544759 37.579513277939817,
126.97381925784454 37.579372140302631,
126.97391736338342 37.578487073041011,
126.97393961998088 37.578240429978088,
126.97433153835757 37.575749906299862,
126.97580378997804 37.575649468824203,
126.97688884274817 37.575650779448786 ))'

所以我的想法是将多边形数据转换为字符串,然后使用正则表达式替换括号。然而这种方法会花费很多时间。所以,我想知道是否有任何解决方案可以将此数据插入到mysql多边形字段中。

最佳答案

如果您使用 PostgreSQL 和 PostGIS,则可以使用 GeoAlchemy2图书馆。但我认为目前不支持MySQL,如果我错了,有人纠正我。

关于Python + MySQL : Insert geojson polygon value to mysql sptial column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46830650/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com