# pgr_alphaShape¶

## Nom¶

pgr_alphashape — Fonction Core pour le calcul de la forme alpha

Note

Cette fonction ne devrait pas être utilisée directement. Utilisez pgr_drivingDistance à la place.

## Synopsis¶

Retourne un tableau avec des lignes (x, y) qui décrivent les sommets d’une forme alpha.

```table() pgr_alphashape(text sql);
```

## Description¶

sql:

text une requête SQL, qui doit retourner un ensemble de lignes avec les colonnes suivantes :

```SELECT id, x, y FROM vertex_table
```
id: int4 identifiant du sommet coordonnée x float8 coordonnée y float8

Retourne un enregistrement sommet pour chaque ligne :

x: coordonnée x coordonnée y

Histoire

• Renommé depuis la version 2.0.0

## Exemples¶

In the alpha shape code we have no way to control the order of the points so the actual output you might get could be similar but different. The simple query is followed by a more complex one that constructs a polygon and computes the areas of it. This should be the same as the result on your system. We leave the details of the complex query to the reader as an exercise if they wish to decompose it into understandable pieces or to just copy and paste it into a SQL window to run.

```SELECT * FROM pgr_alphashape('SELECT id, x, y FROM vertex_table');

x | y
---+---
2 | 0
4 | 1
4 | 2
4 | 3
2 | 4
0 | 2
(6 rows)

SELECT round(st_area(ST_MakePolygon(ST_AddPoint(foo.openline, ST_StartPoint(foo.openline))))::numeric, 2) as st_area
from (select st_makeline(points order by id)  as openline from
(SELECT st_makepoint(x,y) as points ,row_number() over() AS id
FROM pgr_alphAShape('SELECT id, x, y FROM vertex_table')
) as a) as foo;

st_area
---------
10.00
(1 row)

SELECT * FROM pgr_alphAShape('SELECT id::integer, st_x(the_geom)::float as x, st_y(the_geom)::float as y  FROM edge_table_vertices_pgr');
x  |  y
-----+-----
0.5 | 3.5
0 |   2
2 |   0
4 |   1
4 |   2
4 |   3
3.5 |   4
2 |   4
(8 rows)

SELECT round(st_area(ST_MakePolygon(ST_AddPoint(foo.openline, ST_StartPoint(foo.openline))))::numeric, 2) as st_area
from (select st_makeline(points order by id)  as openline from
(SELECT st_makepoint(x,y) as points ,row_number() over() AS id
FROM pgr_alphAShape('SELECT id::integer, st_x(the_geom)::float as x, st_y(the_geom)::float as y  FROM edge_table_vertices_pgr')
) as a) as foo;

st_area
---------
10.00
(1 row)
```

Les requêtes utilisent le réseau Données d’échantillon.