Como corrigir "O buraco está fora da concha"

9

Eu obtive um conjunto de dados com formas poligonais, no qual a geometria foi atualizada pelo plug-in do QGIS " Geometry Updater ". Agora, tenho o problema de que, no PostGIS, obtenho geometrias inválidas com a mensagem de erro "O furo está fora do shell" . Porém, ao observar a geometria no QGIS, na verdade existem duas formas, onde uma é a geometria principal e a outra (provavelmente) o buraco.

insira a descrição da imagem aqui

Eu pensei que a razão para isso era que o tipo de geometria estava definido como ST_Polygon. Mas mesmo depois de alterá-lo para ST_MultiPolygon, o erro ainda permanece. Alguém tem uma idéia de como consertar isso? Também manualmente no QGIS seria bom.

EDITAR:

Este é o WKT original da forma na imagem (antes de alterá-la para 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 5312494.37629255,65125,5512565465428628528446282864462828428628628844628628628628628628628 de90959164 5312496.00535955,681389.15656464 5312487.38890554,681365.00476264 5312481.62211554,681327.726005639 5312490.52129555,681306.883836639 5312494.37629255,65125,5512565465428628528446282864462828428628628844628628628628628628628 de

JoeBe
fonte
3
Normalmente, isso ocorre devido à direção dos vértices. Se um dos polígonos está no sentido horário e o outro no sentido anti-horário, ele acha que o segundo é um buraco. É apenas uma idéia, infelizmente, eu não sei como corrigi-lo
ylka
se você copiar e colar o recurso em um editor de texto que você provavelmente pode alterá-lo para um multipolígono e reimportar usando QuickWKT
Ian Turton
Você pode postar o WKT do seu recurso?
thibautg
@thibautg Acabei de adicionar o WKT
JoeBe

Respostas:

10

de fato, no PostGIS ST_IsValidReason retornaHole lies outside shell[681306.938491638 5312528.24474655]

ST_MakeValid altera para 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)))
thibautg
fonte
3

Eu tentei com a ferramenta "Tornar as geometrias válidas" do OpenJUMP e ela retorna a geometria corrigida como um multipolígono. O OpenJUMP está usando sua própria função makeValid. Não sei se o QGIS tem uma função equivalente, mas como você já possui o PostGIS, você pode simplesmente usar ST_MakeValid http://postgis.net/docs/ST_MakeValid.html .

MULTIPOLYGON (((681.328,211640639 5.312.556,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.24474655))681365.00476264 5312481.62211554, 681327.726005639 5312490.52129555, 681306.883836639 5312494.37629255, 681298.999414638 5312496.84720955, 681306.938491638 5312528.24474655))

user30184
fonte
JTS / GEOS realmente não tem uma makeValidfunção. O do OpenJUMP é construído sob medida para esse aplicativo, assim como o PostGIS '.
dbaston
@ dbaston, obrigado, eu deveria ter verificado os fatos sourceforge.net/p/jts-topo-suite/mailman/message/34695185 .
user30184
Eu editei a resposta. O MakeValid parece estar na lista de desejos do JTS slideshare.net/jgarnett/state-of-jts-2017 .
user30184