Cara memperbaiki "Lubang terletak di luar cangkang"


9

Saya mendapat dataset dengan bentuk poligon, di mana geometri diperbarui oleh plugin QGIS " Geometry Updater ". Sekarang saya memiliki masalah bahwa di PostGIS saya mendapatkan geometri yang tidak valid dengan pesan kesalahan "Hole terletak di luar shell" . Tetapi ketika mengamati geometri dalam QGIS, sebenarnya ada dua bentuk, di mana satu adalah geometri utama dan yang lainnya (mungkin) lubangnya.

masukkan deskripsi gambar di sini

Saya pikir alasannya adalah karena jenis geometrinya ditetapkan ST_Polygon. Tetapi bahkan setelah mengubahnya ST_MultiPolygon, kesalahan masih tetap ada. Seseorang punya ide bagaimana cara memperbaikinya? Juga secara manual di QGIS akan baik-baik saja.

EDIT:

Ini adalah WKT asli dari bentuk dalam gambar (sebelum mengubahnya menjadi ST_MultiPolygon):

Polygon ((681328,211640639 5312556.84866055,681333.876018639 5312566.85338355,681344.126811639 5312584.17146655,681360.13777864 5312605.81168455,681368.571629639 5312620.16794654,681375.15817664 5312633.84801255,681380.74133464 5312647.74367554,681384.01769064 5312658.41482554,681392.01169764 5312694.63471254,681393.07199764 5312701.83700354,681389.16681464 5312705.85459254,681379.79126564 5312704.26135554,681393.93193764 5312715.39845154,681401.81727164 5312723.43382354,681398.09962564 5312710.95653254,681395.19739764 5312693,68448654 , 681387.20535464 5312657.40285554,681383.87846764 5312644.38168654,681378.69327164 5312632.35257854,681367.00831364 5312610.47778954,681346.401239639 5312581.83289054,681336.365640639 5312564.27437955,681340.423191639 5312560.69415655,681365.23709764 5312567.84133655,681374.16498264 5312570.47104354,681390.52225764 5312565.30077054,681395.29993964 5312563.90629854,681410.98915364 5312545.67508754,681413.79585564 5312536.98783954,681415.77221864 5312530.93185454,681416.991529641 5312523.86320254,681406.38747164 5312515.12414654,681403.96790864 5312507.57002154,681395.94924164 5312514.30082354,681394.08765664 5312516.71419154,681390.91027864 5312518.71529654,681387.07111564 5312520.63375054,681381.90838164 5312522.38690354,681376.13571264 5312525.04785255,681366.362498639 5312530.79640254,681349.071127639 5312540.57236955,681332.287335639 5312550,05537054 , 681.321,992430639 5312555.23135255,681328.211640639 5.312.556,84866055), (681306,938491638 5312528.24474655,681318.811081639 5312521.75881455,681324.059996639 5312518.58690655,681330.950098639 5312514.72509155,681336.554227639 5312510.82277555,681341.802513639 5312506.35305054,681352.668573639 5312497.54885354,681356.654879639 5312493.59559054,681360.976303639 5312488.23147354,681363.302624639 5312486.88334655,681366.15656264 5312485.92264755,681369.80127664 5312486.22287554,681375.12800564 5312488.49191954,681382.62287464 5312493.11590554,681385.88903564 5312494.88743254,681387.74606564 5312495.25494754,681393.90959164 5312496.00535955,681389.15656464 5312487.38890554,681365.00476264 5312481.62211554,681327.726005639 5312490.52129555,681306.883836639 5312494.37629255,681298.999414638 5312496.84720955,681306.938491638 5312528,24474655) )90959164 5312496.00535955,681389.15656464 5312487.38890554,681365.00476264 5312481.62211554, 681327.726005639 5312490.52129555, 681306.883836639 531249830830890959164 5312496.00535955,681389.15656464 5312487.38890554,681365.00476264 5312481.62211554, 681327.726005639 5312490.52129555, 681306.883836639 5312498308308


3
Biasanya ini karena arah simpul. Jika salah satu poligon searah jarum jam dan yang lainnya berlawanan arah jarum jam maka ia berpikir yang kedua adalah lubang. Itu hanya sebuah ide, sayangnya saya tidak tahu bagaimana cara memperbaikinya
ylka

jika Anda menyalin dan menempelkan fitur tersebut ke dalam editor teks, Anda mungkin dapat mengubahnya ke multipoligon dan mengimpor kembali menggunakan QuickWKT
Ian Turton

Bisakah Anda memposting WKT fitur Anda?
thibautg

@ thibautg Saya baru saja menambahkan WKT
JoeBe

Jawaban:


10

memang, dalam postGIS ST_IsValidReason kembaliHole lies outside shell[681306.938491638 5312528.24474655]

ST_MakeValid mengubahnya menjadi MULTIPOLYGON:

MULTIPOLYGON(((681306.938491638 5312528.24474655,681318.811081639 5312521.75881455,681324.059996639 5312518.58690655,681330.950098639 5312514.72509155,681336.554227639 5312510.82277555,681341.802513639 5312506.35305054,681352.668573639 5312497.54885354,681356.654879639 5312493.59559054,681360.976303639 5312488.23147354,681363.302624639 5312486.88334655,681366.15656264 5312485.92264755,681369.80127664 5312486.22287554,681375.12800564 5312488.49191954,681382.62287464 5312493.11590554,681385.88903564 5312494.88743254,681387.74606564 5312495.25494754,681393.90959164 5312496.00535955,681389.15656464 5312487.38890554,681365.00476264 5312481.62211554,681327.726005639 5312490.52129555,681306.883836639 5312494.37629255,681298.999414638 5312496.84720955,681306.938491638 5312528.24474655)),((681328.211640639 5312556.84866055,681333.876018639 5312566.85338355,681344.126811639 5312584.17146655,681360.13777864 5312605.81168455,681368.571629639 5312620.16794654,681375.15817664 5312633.84801255,681380.74133464 5312647.74367554,681384.01769064 5312658.41482554,681392.01169764 5312694.63471254,681393.07199764 5312701.83700354,681389.16681464 5312705.85459254,681379.79126564 5312704.26135554,681393.93193764 5312715.39845154,681401.81727164 5312723.43382354,681398.09962564 5312710.95653254,681395.19739764 5312693.68448654,681387.20535464 5312657.40285554,681383.87846764 5312644.38168654,681378.69327164 5312632.35257854,681367.00831364 5312610.47778954,681346.401239639 5312581.83289054,681336.365640639 5312564.27437955,681340.423191639 5312560.69415655,681365.23709764 5312567.84133655,681374.16498264 5312570.47104354,681390.52225764 5312565.30077054,681395.29993964 5312563.90629854,681410.98915364 5312545.67508754,681413.79585564 5312536.98783954,681415.77221864 5312530.93185454,681416.991529641 5312523.86320254,681406.38747164 5312515.12414654,681403.96790864 5312507.57002154,681395.94924164 5312514.30082354,681394.08765664 5312516.71419154,681390.91027864 5312518.71529654,681387.07111564 5312520.63375054,681381.90838164 5312522.38690354,681376.13571264 5312525.04785255,681366.362498639 5312530.79640254,681349.071127639 5312540.57236955,681332.287335639 5312550.05537054,681321.992430639 5312555.23135255,681328.211640639 5312556.84866055)))

3

Saya sudah mencoba dengan alat "Make Geometries Valid" dari OpenJUMP dan mengembalikan geometri yang dikoreksi sebagai multipoligon. OpenJUMP menggunakan fungsi makeValid itu sendiri. Saya tidak tahu apakah QGIS memiliki fungsi yang setara tetapi karena Anda sudah memiliki fitur di PostGIS, Anda dapat menggunakan ST_MakeValid http://postgis.net/docs/ST_MakeValid.html .

MULTIPOLYGON (((681328,211640639 5312556,84866055, 681.333,876018639 5.312.566,85338355, 681.344,126811639 5.312.584,17146655, 681.360,13777864 5.312.605,81168455, 681.368,571629639 5.312.620,16794654, 681.375,15817664 5.312.633,84801255, 681.380,74133464 5.312.647,74367554, 681.384,01769064 5.312.658,41482554, 681.392,01169764 5.312.694,63471254, 681.393,07199764 5.312.701,83700354, 681.389,16681464 5.312.705,85459254, 681.379,79126564 5.312.704,26135554, 681.393,93193764 5.312.715,39845154, 681.401,81727164 5.312.723,43382354, 681.398,09962564 5.312.710,95653254, 681.395,19739764 5312693.68448654, 681387.20535464 5312657.40285554,681383.87846764 5312644.38168654, 681378.69327164 5312632.35257854, 681367.00831364 5312610.47778954, 681.346,401239639 5.312.581,83289054, 681.336,365640639 5.312.564,27437955, 681.340,423191639 5.312.560,69415655, 681.365,23709764 5.312.567,84133655, 681.374,16498264 5.312.570,47104354, 681.390,52225764 5.312.565,30077054, 681.395,29993964 5.312.563,90629854, 681.410,98915364 5.312.545,67508754, 681.413,79585564 5.312.536,98783954, 681.415,77221864 5.312.530,93185454, 681.416,991529641 5.312.523,86320254, 681.406,38747164 5.312.515,12414654, 681.403,96790864 5.312.507,57002154, 681.395,94924164 5.312.514,30082354 , 681394.08765664 5312516.71419154, 681390.91027864 5312518.71529654, 681387.07111564 5312520.63375054, 681381.90838164 5312522.38690354, 681376.13571264 5312525.04785255, 681.366,362498639 5.312.530,79640254, 681.349,071127639 5.312.540,57236955, 681.332,287335639 5.312.550,05537054, 681.321,992430639 5.312.555,23135255, 681.328,211640639 5.312.556,84866055)), ((681.306,938491638 5.312.528,24474655, 681.318,811081639 5.312.521,75881455, 681.324,059996639 5.312.518,58690655, 681.330,950098639 5.312.514,72509155, 681.336,554227639 5.312.510,82277555, 681.341,802513639 5312506.35305054, 681352.668573639 5312497.54885354, 681356.654879639 5312493.59559054, 681.360,976303639 5.312.488,23147354, 681.363,302624639 5.312.486,88334655, 681.366,15656264 5.312.485,92264755, 681.369,80127664 5.312.486,22287554, 681.375,12800564 5.312.488,49191954, 681.382,62287464 5.312.493,11590554, 681.385,88903564 5.312.494,88743254, 681.387,74606564 5.312.495,25494754, 681.393,90959164 5.312.496,00535955, 681.389,15656464 5.312.487,38890554, 681.365,00476264 5.312.481,62211554, 681.327,726005639 5.312.490,52129555, 681.306,883836639 5.312.494,37629255, 681.298,999414638 5.312.496,84720955, 681.306,938491638 5.312.528,24474655)))681.363,302624639 5.312.486,88334655, 681.366,15656264 5.312.485,92264755, 681.369,80127664 5.312.486,22287554, 681.375,12800564 5.312.488,49191954, 681.382,62287464 5.312.493,11590554, 681.385,88903564 5.312.494,88743254, 681.387,74606564 5.312.495,25494754, 681.393,90959164 5.312.496,00535955, 681.389,15656464 5.312.487,38890554, 681.365,00476264 5.312.481,62211554, 681.327,726005639 5.312.490,52129555, 681.306,883836639 5.312.494,37629255, 681.298,999414638 5.312.496,84720955, 681.306,938491638 5.312.528,24474655)))681.363,302624639 5.312.486,88334655, 681.366,15656264 5.312.485,92264755, 681.369,80127664 5.312.486,22287554, 681.375,12800564 5.312.488,49191954, 681.382,62287464 5.312.493,11590554, 681.385,88903564 5.312.494,88743254, 681.387,74606564 5.312.495,25494754, 681.393,90959164 5.312.496,00535955, 681.389,15656464 5.312.487,38890554, 681.365,00476264 5.312.481,62211554, 681.327,726005639 5.312.490,52129555, 681.306,883836639 5.312.494,37629255, 681.298,999414638 5.312.496,84720955, 681.306,938491638 5.312.528,24474655)))681375.12800564 5312488.49191954, 681382.62287464 5312493.11590554, 681385.88903564 5312494.88743254, 681387.74606564 5312495.25494754, 681393.90959164 5312496.00535955, 681389.15656464 5312487.38890554, 681365.00476264 5312481.62211554, 681.327,726005639 5.312.490,52129555, 681.306,883836639 5.312.494,37629255, 681.298,999414638 5.312.496,84720955, 681.306,938491638 5.312.528,24474655)))681375.12800564 5312488.49191954, 681382.62287464 5312493.11590554, 681385.88903564 5312494.88743254, 681387.74606564 5312495.25494754, 681393.90959164 5312496.00535955, 681389.15656464 5312487.38890554, 681365.00476264 5312481.62211554, 681.327,726005639 5.312.490,52129555, 681.306,883836639 5.312.494,37629255, 681.298,999414638 5.312.496,84720955, 681.306,938491638 5.312.528,24474655)))681365.00476264 5312481.62211554, 681327.726005639 5312490.52129555, 681306.883836639 5312494.37629255, 681298.999414638 5312496.84720955, 681306.938491638 5312528.24465)681365.00476264 5312481.62211554, 681327.726005639 5312490.52129555, 681306.883836639 5312494.37629255, 681298.999414638 5312496.84720955, 681306.938491638 5312528.24465)


JTS / GEOS sebenarnya tidak memiliki makeValidfungsi. Yang ada di OpenJUMP dibuat khusus untuk aplikasi itu, seperti halnya PostGIS '.
dbaston

@dbaston, terima kasih, saya seharusnya memeriksa fakta sourceforge.net/p/jts-topo-suite/mailman/message/34695185 .
user30184

Saya mengedit jawabannya. MakeValid tampaknya berada di wishlist JTS slideshare.net/jgarnett/state-of-jts-2017 .
user30184
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.