Examples
The original point cloud and the alpha-shape share one comparison frame.
WITH data AS (
SELECT 'MULTIPOINT((63 84),(76 88),(68 73),(53 18),(91 50),(81 70),
(88 29),(24 82),(32 51),(37 23),(27 54),(84 19),(75 87),(44 42),(77 67),(90 30),(36 61),(32 65),
(81 47),(88 58),(68 73),(49 95),(81 60),(87 50),
(78 16),(79 21),(30 22),(78 43),(26 85),(48 34),(35 35),(36 40),(31 79),(83 29),(27 84),(52 98),(72 95),(85 71),
(75 84),(75 77),(81 29),(77 73),(41 42),(83 72),(23 36),(89 53),(27 57),(57 97),(27 77),(39 88),(60 81),
(80 72),(54 32),(55 26),(62 22),(70 20),(76 27),(84 35),(87 42),(82 54),(83 64),(69 86),(60 90),(50 86),(43 80),(36 73),
(36 68),(40 75),(24 67),(23 60),(26 44),(28 33),(40 32),(43 19),(65 16),(73 16),(38 46),(31 59),(34 86),(45 90),(64 97))'::geometry AS input_points
)
SELECT input_points AS input_points,
CG_AlphaShape(input_points, 80.2) AS alpha_shape
FROM data;
MULTIPOINT((63 84),(76 88),(68 73),(53 18),(91 50),(81 70),(88 29),(24 82),(32 51),(37 23),(27 54),(84 19),(75 87),(44 42),(77 67),(90 30),(36 61),(32 65),(81 47),(88 58),(68 73),(49 95),(81 60),(87 50),(78 16),(79 21),(30 22),(78 43),(26 85),(48 34),(35 35),(36 40),(31 79),(83 29),(27 84),(52 98),(72 95),(85 71),(75 84),(75 77),(81 29),(77 73),(41 42),(83 72),(23 36),(89 53),(27 57),(57 97),(27 77),(39 88),(60 81),(80 72),(54 32),(55 26),(62 22),(70 20),(76 27),(84 35),(87 42),(82 54),(83 64),(69 86),(60 90),(50 86),(43 80),(36 73),(36 68),(40 75),(24 67),(23 60),(26 44),(28 33),(40 32),(43 19),(65 16),(73 16),(38 46),(31 59),(34 86),(45 90),(64 97)) | MULTIPOLYGON(((89 53,88 58,85 71,83 72,75 84,76 88,72 95,64 97,57 97,52 98,49 95,45 90,39 88,34 86,26 85,24 82,27 77,24 67,23 60,27 54,26 44,23 36,28 33,30 22,37 23,43 19,53 18,65 16,73 16,78 16,84 19,88 29,90 30,87 42,91 50,89 53)))
01040000005100000001010000000000000000804F40000000000000554001010000000000000000005340000000000000564001010000000000000000005140000000000040524001010000000000000000804A40000000000000324001010000000000000000C056400000000000004940010100000000000000004054400000000000805140010100000000000000000056400000000000003D4001010000000000000000003840000000000080544001010000000000000000004040000000000080494001010000000000000000804240000000000000374001010000000000000000003B400000000000004B4001010000000000000000005540000000000000334001010000000000000000C052400000000000C05540010100000000000000000046400000000000004540010100000000000000004053400000000000C05040010100000000000000008056400000000000003E40010100000000000000000042400000000000804E40010100000000000000000040400000000000405040010100000000000000004054400000000000804740010100000000000000000056400000000000004D40010100000000000000000051400000000000405240010100000000000000008048400000000000C05740010100000000000000004054400000000000004E4001010000000000000000C05540000000000000494001010000000000000000805340000000000000304001010000000000000000C05340000000000000354001010000000000000000003E40000000000000364001010000000000000000805340000000000080454001010000000000000000003A40000000000040554001010000000000000000004840000000000000414001010000000000000000804140000000000080414001010000000000000000004240000000000000444001010000000000000000003F400000000000C0534001010000000000000000C054400000000000003D4001010000000000000000003B40000000000000554001010000000000000000004A400000000000805840010100000000000000000052400000000000C05740010100000000000000004055400000000000C0514001010000000000000000C05240000000000000554001010000000000000000C052400000000000405340010100000000000000004054400000000000003D4001010000000000000000405340000000000040524001010000000000000000804440000000000000454001010000000000000000C054400000000000005240010100000000000000000037400000000000004240010100000000000000004056400000000000804A4001010000000000000000003B400000000000804C4001010000000000000000804C40000000000040584001010000000000000000003B40000000000040534001010000000000000000804340000000000000564001010000000000000000004E40000000000040544001010000000000000000005440000000000000524001010000000000000000004B40000000000000404001010000000000000000804B400000000000003A4001010000000000000000004F400000000000003640010100000000000000008051400000000000003440010100000000000000000053400000000000003B4001010000000000000000005540000000000080414001010000000000000000C055400000000000004540010100000000000000008054400000000000004B4001010000000000000000C05440000000000000504001010000000000000000405140000000000080554001010000000000000000004E400000000000805640010100000000000000000049400000000000805540010100000000000000008045400000000000005440010100000000000000000042400000000000405240010100000000000000000042400000000000005140010100000000000000000044400000000000C05240010100000000000000000038400000000000C05040010100000000000000000037400000000000004E4001010000000000000000003A40000000000000464001010000000000000000003C40000000000080404001010000000000000000004440000000000000404001010000000000000000804540000000000000334001010000000000000000405040000000000000304001010000000000000000405240000000000000304001010000000000000000004340000000000000474001010000000000000000003F400000000000804D40010100000000000000000041400000000000805540010100000000000000008046400000000000805640010100000000000000000050400000000000405840 | 0106000000010000000103000000010000002400000000000000004056400000000000804A4000000000000056400000000000004D4000000000004055400000000000C051400000000000C0544000000000000052400000000000C0524000000000000055400000000000005340000000000000564000000000000052400000000000C05740000000000000504000000000004058400000000000804C4000000000004058400000000000004A40000000000080584000000000008048400000000000C057400000000000804640000000000080564000000000008043400000000000005640000000000000414000000000008055400000000000003A400000000000405540000000000000384000000000008054400000000000003B40000000000040534000000000000038400000000000C0504000000000000037400000000000004E400000000000003B400000000000004B400000000000003A400000000000004640000000000000374000000000000042400000000000003C4000000000008040400000000000003E40000000000000364000000000008042400000000000003740000000000080454000000000000033400000000000804A4000000000000032400000000000405040000000000000304000000000004052400000000000003040000000000080534000000000000030400000000000005540000000000000334000000000000056400000000000003D4000000000008056400000000000003E400000000000C0554000000000000045400000000000C05640000000000000494000000000004056400000000000804A40
The same point cloud can produce a shape with a hole when holes are allowed.
WITH data AS (
SELECT 'MULTIPOINT((63 84),(76 88),(68 73),(53 18),(91 50),(81 70),(88 29),(24 82),(32 51),(37 23),(27 54),(84 19),(75 87),(44 42),(77 67),(90 30),(36 61),(32 65),(81 47),(88 58),(68 73),(49 95),(81 60),(87 50),
(78 16),(79 21),(30 22),(78 43),(26 85),(48 34),(35 35),(36 40),(31 79),(83 29),(27 84),(52 98),(72 95),(85 71),
(75 84),(75 77),(81 29),(77 73),(41 42),(83 72),(23 36),(89 53),(27 57),(57 97),(27 77),(39 88),(60 81),
(80 72),(54 32),(55 26),(62 22),(70 20),(76 27),(84 35),(87 42),(82 54),(83 64),(69 86),(60 90),(50 86),(43 80),(36 73),
(36 68),(40 75),(24 67),(23 60),(26 44),(28 33),(40 32),(43 19),(65 16),(73 16),(38 46),(31 59),(34 86),(45 90),(64 97))'::geometry AS input_points
)
SELECT input_points AS input_points,
CG_AlphaShape(input_points, 100.1, true) AS alpha_shape
FROM data;
MULTIPOINT((63 84),(76 88),(68 73),(53 18),(91 50),(81 70),(88 29),(24 82),(32 51),(37 23),(27 54),(84 19),(75 87),(44 42),(77 67),(90 30),(36 61),(32 65),(81 47),(88 58),(68 73),(49 95),(81 60),(87 50),(78 16),(79 21),(30 22),(78 43),(26 85),(48 34),(35 35),(36 40),(31 79),(83 29),(27 84),(52 98),(72 95),(85 71),(75 84),(75 77),(81 29),(77 73),(41 42),(83 72),(23 36),(89 53),(27 57),(57 97),(27 77),(39 88),(60 81),(80 72),(54 32),(55 26),(62 22),(70 20),(76 27),(84 35),(87 42),(82 54),(83 64),(69 86),(60 90),(50 86),(43 80),(36 73),(36 68),(40 75),(24 67),(23 60),(26 44),(28 33),(40 32),(43 19),(65 16),(73 16),(38 46),(31 59),(34 86),(45 90),(64 97)) | MULTIPOLYGON(((89 53,88 58,85 71,83 72,75 84,76 88,72 95,64 97,57 97,52 98,49 95,45 90,39 88,34 86,26 85,24 82,27 77,24 67,23 60,27 54,26 44,23 36,28 33,30 22,43 19,53 18,65 16,73 16,78 16,84 19,90 30,87 42,91 50,89 53),(36 68,40 75,43 80,60 81,68 73,77 67,81 60,82 54,81 47,78 43,76 27,62 22,54 32,44 42,38 46,36 61,36 68)))
01040000005100000001010000000000000000804F40000000000000554001010000000000000000005340000000000000564001010000000000000000005140000000000040524001010000000000000000804A40000000000000324001010000000000000000C056400000000000004940010100000000000000004054400000000000805140010100000000000000000056400000000000003D4001010000000000000000003840000000000080544001010000000000000000004040000000000080494001010000000000000000804240000000000000374001010000000000000000003B400000000000004B4001010000000000000000005540000000000000334001010000000000000000C052400000000000C05540010100000000000000000046400000000000004540010100000000000000004053400000000000C05040010100000000000000008056400000000000003E40010100000000000000000042400000000000804E40010100000000000000000040400000000000405040010100000000000000004054400000000000804740010100000000000000000056400000000000004D40010100000000000000000051400000000000405240010100000000000000008048400000000000C05740010100000000000000004054400000000000004E4001010000000000000000C05540000000000000494001010000000000000000805340000000000000304001010000000000000000C05340000000000000354001010000000000000000003E40000000000000364001010000000000000000805340000000000080454001010000000000000000003A40000000000040554001010000000000000000004840000000000000414001010000000000000000804140000000000080414001010000000000000000004240000000000000444001010000000000000000003F400000000000C0534001010000000000000000C054400000000000003D4001010000000000000000003B40000000000000554001010000000000000000004A400000000000805840010100000000000000000052400000000000C05740010100000000000000004055400000000000C0514001010000000000000000C05240000000000000554001010000000000000000C052400000000000405340010100000000000000004054400000000000003D4001010000000000000000405340000000000040524001010000000000000000804440000000000000454001010000000000000000C054400000000000005240010100000000000000000037400000000000004240010100000000000000004056400000000000804A4001010000000000000000003B400000000000804C4001010000000000000000804C40000000000040584001010000000000000000003B40000000000040534001010000000000000000804340000000000000564001010000000000000000004E40000000000040544001010000000000000000005440000000000000524001010000000000000000004B40000000000000404001010000000000000000804B400000000000003A4001010000000000000000004F400000000000003640010100000000000000008051400000000000003440010100000000000000000053400000000000003B4001010000000000000000005540000000000080414001010000000000000000C055400000000000004540010100000000000000008054400000000000004B4001010000000000000000C05440000000000000504001010000000000000000405140000000000080554001010000000000000000004E400000000000805640010100000000000000000049400000000000805540010100000000000000008045400000000000005440010100000000000000000042400000000000405240010100000000000000000042400000000000005140010100000000000000000044400000000000C05240010100000000000000000038400000000000C05040010100000000000000000037400000000000004E4001010000000000000000003A40000000000000464001010000000000000000003C40000000000080404001010000000000000000004440000000000000404001010000000000000000804540000000000000334001010000000000000000405040000000000000304001010000000000000000405240000000000000304001010000000000000000004340000000000000474001010000000000000000003F400000000000804D40010100000000000000000041400000000000805540010100000000000000008046400000000000805640010100000000000000000050400000000000405840 | 0106000000010000000103000000020000002200000000000000004056400000000000804A4000000000000056400000000000004D4000000000004055400000000000C051400000000000C0544000000000000052400000000000C0524000000000000055400000000000005340000000000000564000000000000052400000000000C05740000000000000504000000000004058400000000000804C4000000000004058400000000000004A40000000000080584000000000008048400000000000C057400000000000804640000000000080564000000000008043400000000000005640000000000000414000000000008055400000000000003A400000000000405540000000000000384000000000008054400000000000003B40000000000040534000000000000038400000000000C0504000000000000037400000000000004E400000000000003B400000000000004B400000000000003A400000000000004640000000000000374000000000000042400000000000003C4000000000008040400000000000003E400000000000003640000000000080454000000000000033400000000000804A4000000000000032400000000000405040000000000000304000000000004052400000000000003040000000000080534000000000000030400000000000005540000000000000334000000000008056400000000000003E400000000000C0554000000000000045400000000000C05640000000000000494000000000004056400000000000804A40110000000000000000004240000000000000514000000000000044400000000000C05240000000000080454000000000000054400000000000004E4000000000004054400000000000005140000000000040524000000000004053400000000000C0504000000000004054400000000000004E4000000000008054400000000000004B40000000000040544000000000008047400000000000805340000000000080454000000000000053400000000000003B400000000000004F4000000000000036400000000000004B400000000000004040000000000000464000000000000045400000000000004340000000000000474000000000000042400000000000804E4000000000000042400000000000005140
The second documented point cloud also produces a holed alpha-shape.
WITH data AS (
SELECT 'MULTIPOINT ((132 64),(114 64),(99 64),(81 64),(63 64),(57 49),(52 36),(46 20),(37 20),(26 20),(32 36),(39 55),(43 69),(50 84),(57 100),(63 118),(68 133),(74 149),(81 164),(88 180),(101 180),(112 180),(119 164),(126 149),(132 131),(139 113),(143 100),(150 84),(157 69),(163 51),(168 36),(174 20),(163 20),(150 20),(143 36),(139 49),(132 64),(99 151),(92 138),(88 124),(81 109),(74 93),(70 82),(83 82),(99 82),(112 82),(126 82),(121 96),(114 109),(110 122),(103 138),(99 151),(34 27),(43 31),(48 44),(46 58),(52 73),(63 73),(61 84),(72 71),(90 69),(101 76),(123 71),(141 62),(166 27),(150 33),(159 36),(146 44),(154 53),(152 62),(146 73),(134 76),(143 82),(141 91),(130 98),(126 104),(132 113),(128 127),(117 122),(112 133),(119 144),(108 147),(119 153),(110 171),(103 164),(92 171),(86 160),(88 142),(79 140),(72 124),(83 131),(79 118),(68 113),(63 102),(68 93),(35 45))'::geometry AS input_points
)
SELECT input_points AS input_points,
CG_AlphaShape(input_points, 102.2, true) AS alpha_shape
FROM data;
MULTIPOINT((132 64),(114 64),(99 64),(81 64),(63 64),(57 49),(52 36),(46 20),(37 20),(26 20),(32 36),(39 55),(43 69),(50 84),(57 100),(63 118),(68 133),(74 149),(81 164),(88 180),(101 180),(112 180),(119 164),(126 149),(132 131),(139 113),(143 100),(150 84),(157 69),(163 51),(168 36),(174 20),(163 20),(150 20),(143 36),(139 49),(132 64),(99 151),(92 138),(88 124),(81 109),(74 93),(70 82),(83 82),(99 82),(112 82),(126 82),(121 96),(114 109),(110 122),(103 138),(99 151),(34 27),(43 31),(48 44),(46 58),(52 73),(63 73),(61 84),(72 71),(90 69),(101 76),(123 71),(141 62),(166 27),(150 33),(159 36),(146 44),(154 53),(152 62),(146 73),(134 76),(143 82),(141 91),(130 98),(126 104),(132 113),(128 127),(117 122),(112 133),(119 144),(108 147),(119 153),(110 171),(103 164),(92 171),(86 160),(88 142),(79 140),(72 124),(83 131),(79 118),(68 113),(63 102),(68 93),(35 45)) | MULTIPOLYGON(((168 36,163 51,157 69,150 84,143 100,139 113,132 131,126 149,119 164,112 180,101 180,88 180,81 164,74 149,68 133,63 118,57 100,50 84,43 69,39 55,35 45,32 36,26 20,37 20,46 20,52 36,57 49,63 64,81 64,90 69,99 64,114 64,132 64,139 49,143 36,150 20,163 20,174 20,168 36),(81 109,88 124,92 138,103 138,110 122,114 109,121 96,112 82,99 82,83 82,74 93,81 109)))
01040000006000000001010000000000000000806040000000000000504001010000000000000000805C40000000000000504001010000000000000000C05840000000000000504001010000000000000000405440000000000000504001010000000000000000804F40000000000000504001010000000000000000804C40000000000080484001010000000000000000004A40000000000000424001010000000000000000004740000000000000344001010000000000000000804240000000000000344001010000000000000000003A400000000000003440010100000000000000000040400000000000004240010100000000000000008043400000000000804B4001010000000000000000804540000000000040514001010000000000000000004940000000000000554001010000000000000000804C40000000000000594001010000000000000000804F400000000000805D40010100000000000000000051400000000000A06040010100000000000000008052400000000000A0624001010000000000000000405440000000000080644001010000000000000000005640000000000080664001010000000000000000405940000000000080664001010000000000000000005C40000000000080664001010000000000000000C05D40000000000080644001010000000000000000805F400000000000A06240010100000000000000008060400000000000606040010100000000000000006061400000000000405C4001010000000000000000E06140000000000000594001010000000000000000C06240000000000000554001010000000000000000A06340000000000040514001010000000000000000606440000000000080494001010000000000000000006540000000000000424001010000000000000000C06540000000000000344001010000000000000000606440000000000000344001010000000000000000C06240000000000000344001010000000000000000E06140000000000000424001010000000000000000606140000000000080484001010000000000000000806040000000000000504001010000000000000000C058400000000000E06240010100000000000000000057400000000000406140010100000000000000000056400000000000005F40010100000000000000004054400000000000405B4001010000000000000000805240000000000040574001010000000000000000805140000000000080544001010000000000000000C05440000000000080544001010000000000000000C05840000000000080544001010000000000000000005C40000000000080544001010000000000000000805F40000000000080544001010000000000000000405E40000000000000584001010000000000000000805C400000000000405B4001010000000000000000805B400000000000805E4001010000000000000000C05940000000000040614001010000000000000000C058400000000000E06240010100000000000000000041400000000000003B40010100000000000000008045400000000000003F40010100000000000000000048400000000000004640010100000000000000000047400000000000004D4001010000000000000000004A40000000000040524001010000000000000000804F40000000000040524001010000000000000000804E400000000000005540010100000000000000000052400000000000C0514001010000000000000000805640000000000040514001010000000000000000405940000000000000534001010000000000000000C05E400000000000C0514001010000000000000000A061400000000000004F4001010000000000000000C064400000000000003B4001010000000000000000C06240000000000080404001010000000000000000E063400000000000004240010100000000000000004062400000000000004640010100000000000000004063400000000000804A40010100000000000000000063400000000000004F4001010000000000000000406240000000000040524001010000000000000000C06040000000000000534001010000000000000000E06140000000000080544001010000000000000000A061400000000000C0564001010000000000000000406040000000000080584001010000000000000000805F400000000000005A40010100000000000000008060400000000000405C40010100000000000000000060400000000000C05F4001010000000000000000405D400000000000805E4001010000000000000000005C400000000000A0604001010000000000000000C05D40000000000000624001010000000000000000005B40000000000060624001010000000000000000C05D40000000000020634001010000000000000000805B40000000000060654001010000000000000000C059400000000000806440010100000000000000000057400000000000606540010100000000000000008055400000000000006440010100000000000000000056400000000000C0614001010000000000000000C053400000000000806140010100000000000000000052400000000000005F4001010000000000000000C05440000000000060604001010000000000000000C053400000000000805D40010100000000000000000051400000000000405C4001010000000000000000804F400000000000805940010100000000000000000051400000000000405740010100000000000000008041400000000000804640 | 0106000000010000000103000000020000002700000000000000000065400000000000004240000000000060644000000000008049400000000000A0634000000000004051400000000000C0624000000000000055400000000000E06140000000000000594000000000006061400000000000405C40000000000080604000000000006060400000000000805F400000000000A062400000000000C05D4000000000008064400000000000005C40000000000080664000000000004059400000000000806640000000000000564000000000008066400000000000405440000000000080644000000000008052400000000000A0624000000000000051400000000000A060400000000000804F400000000000805D400000000000804C400000000000005940000000000000494000000000000055400000000000804540000000000040514000000000008043400000000000804B4000000000008041400000000000804640000000000000404000000000000042400000000000003A40000000000000344000000000008042400000000000003440000000000000474000000000000034400000000000004A4000000000000042400000000000804C4000000000008048400000000000804F40000000000000504000000000004054400000000000005040000000000080564000000000004051400000000000C0584000000000000050400000000000805C40000000000000504000000000008060400000000000005040000000000060614000000000008048400000000000E0614000000000000042400000000000C062400000000000003440000000000060644000000000000034400000000000C065400000000000003440000000000000654000000000000042400C00000000000000004054400000000000405B4000000000000056400000000000005F40000000000000574000000000004061400000000000C0594000000000004061400000000000805B400000000000805E400000000000805C400000000000405B400000000000405E4000000000000058400000000000005C4000000000008054400000000000C0584000000000008054400000000000C0544000000000008054400000000000805240000000000040574000000000004054400000000000405B40