SQL Server无法识别多边形

时间:2017-04-02 19:49:48

标签: geospatial sql-server-2016 polygons geography

我从openstreetmap中提取了一堆区域的多边形坐标。令我惊讶的是,当我运行它时,它不会将其识别为多边形,而当我通过线串绘制它时,它会正确地绘制它。谁能告诉我为什么以及如何解决它?

我正在使用SQL Server 2016

declare @poly geography
declare @linestring geography
set @poly=geography::STPolyFromText('POLYGON((-3.7251721 40.3346954,-3.7211547 40.3654057,-3.7190862 40.3649337,-3.7160496 40.3645544,-3.711698 40.3641097,-3.7059412 40.3638936,-3.7022824 40.3635865,-3.6997332 40.3640443,-3.6977591 40.3643909,-3.6961026 40.3645347,-3.6927981 40.3645086,-3.6915554 40.364468,-3.6903977 40.3642285,-3.6886353 40.3637042,-3.6830306 40.3617095,-3.6819717 40.3614412,-3.6814057 40.3600219,-3.6806572 40.3595494,-3.6792339 40.3581255,-3.6785129 40.3577919,-3.6778348 40.3575499,-3.6773971 40.357151,-3.6771124 40.3566378,-3.6768833 40.3557292,-3.6766677 40.3550021,-3.676415 40.3542448,-3.6758092 40.3537694,-3.6747621 40.3535601,-3.674187 40.3533181,-3.6738523 40.3530892,-3.6736806 40.3528145,-3.6736034 40.3521342,-3.6734648 40.3514367,-3.6732923 40.3509194,-3.6729425 40.3504859,-3.6725305 40.3502111,-3.6719211 40.3499822,-3.670256 40.3495178,-3.6697974 40.3492625,-3.6694766 40.3489478,-3.668994 40.3474553,-3.6690075 40.3468868,-3.6690911 40.3463332,-3.6692012 40.3459511,-3.6693869 40.3456349,-3.6694909 40.3454513,-3.6693897 40.3452304,-3.6689857 40.3449649,-3.6684603 40.3447916,-3.6680641 40.344684,-3.6666032 40.3443162,-3.6651576 40.3440622,-3.6646598 40.3438528,-3.6642958 40.3434826,-3.6640332 40.3427015,-3.6636899 40.3422435,-3.6631578 40.3412164,-3.6628402 40.3391622,-3.66272 40.3388874,-3.6622308 40.3385734,-3.6617983 40.3382015,-3.6615613 40.3379977,-3.661424 40.3375986,-3.6613982 40.3370556,-3.6612094 40.3363882,-3.6605485 40.3354265,-3.6596387 40.3346545,-3.6587804 40.3337254,-3.6585229 40.3332674,-3.6584628 40.3324953,-3.6582568 40.3316317,-3.657816 40.3307174,-3.6576732 40.3304212,-3.657359 40.3290369,-3.6592657 40.3282873,-3.660041 40.3281207,-3.6606531 40.3281172,-3.6612437 40.328321,-3.662074 40.328965,-3.6628079 40.3293842,-3.663539 40.3295061,-3.6662634 40.3276346,-3.6669148 40.3268381,-3.6676037 40.3262755,-3.6686923 40.3256476,-3.6693252 40.3253737,-3.6704523 40.3250789,-3.67128 40.3254525,-3.674173 40.3263726,-3.6755624 40.3264096,-3.6776978 40.3268926,-3.6786043 40.3269053,-3.6794497 40.3266931,-3.6799414 40.32642,-3.6804064 40.3258407,-3.6808917 40.3249369,-3.681206 40.3245837,-3.6830826 40.323915,-3.6834104 40.3237328,-3.6848 40.3226345,-3.6859754 40.3224744,-3.6876934 40.3224282,-3.6889852 40.3221322,-3.693432 40.3207453,-3.6964539 40.3227452,-3.7014914 40.3227148,-3.7037032 40.3226113,-3.7044926 40.3226876,-3.7099055 40.3236726,-3.712603 40.3238632,-3.7130333 40.3256084,-3.7135981 40.326704,-3.7148182 40.3285524,-3.7161782 40.3291476,-3.7201193 40.3311322,-3.7228013 40.3328939,-3.723 40.3330242,-3.7235589 40.3335523,-3.7251721 40.3346954))',4326)
set @linestring=geography::STLineFromText('LINESTRING(-3.7251721 40.3346954,-3.7211547 40.3654057,-3.7190862 40.3649337,-3.7160496 40.3645544,-3.711698 40.3641097,-3.7059412 40.3638936,-3.7022824 40.3635865,-3.6997332 40.3640443,-3.6977591 40.3643909,-3.6961026 40.3645347,-3.6927981 40.3645086,-3.6915554 40.364468,-3.6903977 40.3642285,-3.6886353 40.3637042,-3.6830306 40.3617095,-3.6819717 40.3614412,-3.6814057 40.3600219,-3.6806572 40.3595494,-3.6792339 40.3581255,-3.6785129 40.3577919,-3.6778348 40.3575499,-3.6773971 40.357151,-3.6771124 40.3566378,-3.6768833 40.3557292,-3.6766677 40.3550021,-3.676415 40.3542448,-3.6758092 40.3537694,-3.6747621 40.3535601,-3.674187 40.3533181,-3.6738523 40.3530892,-3.6736806 40.3528145,-3.6736034 40.3521342,-3.6734648 40.3514367,-3.6732923 40.3509194,-3.6729425 40.3504859,-3.6725305 40.3502111,-3.6719211 40.3499822,-3.670256 40.3495178,-3.6697974 40.3492625,-3.6694766 40.3489478,-3.668994 40.3474553,-3.6690075 40.3468868,-3.6690911 40.3463332,-3.6692012 40.3459511,-3.6693869 40.3456349,-3.6694909 40.3454513,-3.6693897 40.3452304,-3.6689857 40.3449649,-3.6684603 40.3447916,-3.6680641 40.344684,-3.6666032 40.3443162,-3.6651576 40.3440622,-3.6646598 40.3438528,-3.6642958 40.3434826,-3.6640332 40.3427015,-3.6636899 40.3422435,-3.6631578 40.3412164,-3.6628402 40.3391622,-3.66272 40.3388874,-3.6622308 40.3385734,-3.6617983 40.3382015,-3.6615613 40.3379977,-3.661424 40.3375986,-3.6613982 40.3370556,-3.6612094 40.3363882,-3.6605485 40.3354265,-3.6596387 40.3346545,-3.6587804 40.3337254,-3.6585229 40.3332674,-3.6584628 40.3324953,-3.6582568 40.3316317,-3.657816 40.3307174,-3.6576732 40.3304212,-3.657359 40.3290369,-3.6592657 40.3282873,-3.660041 40.3281207,-3.6606531 40.3281172,-3.6612437 40.328321,-3.662074 40.328965,-3.6628079 40.3293842,-3.663539 40.3295061,-3.6662634 40.3276346,-3.6669148 40.3268381,-3.6676037 40.3262755,-3.6686923 40.3256476,-3.6693252 40.3253737,-3.6704523 40.3250789,-3.67128 40.3254525,-3.674173 40.3263726,-3.6755624 40.3264096,-3.6776978 40.3268926,-3.6786043 40.3269053,-3.6794497 40.3266931,-3.6799414 40.32642,-3.6804064 40.3258407,-3.6808917 40.3249369,-3.681206 40.3245837,-3.6830826 40.323915,-3.6834104 40.3237328,-3.6848 40.3226345,-3.6859754 40.3224744,-3.6876934 40.3224282,-3.6889852 40.3221322,-3.693432 40.3207453,-3.6964539 40.3227452,-3.7014914 40.3227148,-3.7037032 40.3226113,-3.7044926 40.3226876,-3.7099055 40.3236726,-3.712603 40.3238632,-3.7130333 40.3256084,-3.7135981 40.326704,-3.7148182 40.3285524,-3.7161782 40.3291476,-3.7201193 40.3311322,-3.7228013 40.3328939,-3.723 40.3330242,-3.7235589 40.3335523,-3.7251721 40.3346954)',4326)

select @poly as polygon, @linestring as linestring

1 个答案:

答案 0 :(得分:1)

如果你改变了 declare @poly geographyset @poly=geography::STPolyFromText...declare @poly geometryset @poly=geometry ::STPolyFromText...

您将在空间结果标签中看到多边形。