- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/workshop-foss4g/geometries_exercises.rst
r21 r1 1 1 .. _geometries_exercises: 2 2 3 Partie 9 : exercices sur les géométries4 ============================= =========5 6 Voici un petit rappel de toute les fonction que nous avons jusqu'à présent. Elles devraient être utiles pour les exercices!7 8 * :command:`sum(expression)` ag régation retournant la somme d'un ensemble9 * :command:`count(expression)` ag régation retournant le nombre d'éléments d'un ensemble10 * :command:`ST_GeometryType(geometry)` ret ourne le type de la géométrie11 * :command:`ST_NDims(geometry)` ret ourne le nombre de dimensions12 * :command:`ST_SRID(geometry)` ret ourne l'identifiant du systÚme de références spatiales13 * :command:`ST_X(point)` ret ourne la coordonnée X14 * :command:`ST_Y(point)` ret ourne la coordonnée Y15 * :command:`ST_Length(linestring)` ret ourne la longueur d'une ligne16 * :command:`ST_StartPoint(geometry)` ret ourne le premier point d'une ligne17 * :command:`ST_EndPoint(geometry)` ret ourne le dernier point d'une ligne18 * :command:`ST_NPoints(geometry)` ret ourne le nombre point d'une ligne19 * :command:`ST_Area(geometry)` ret ourne l'aire d'un polygone20 * :command:`ST_NRings(geometry)` ret ourne le nombre de contours (1 ou plus si il y a des trous)21 * :command:`ST_ExteriorRing(polygon)` ret ourne le contour exterieur (ligne) d'un polygon22 * :command:`ST_InteriorRingN(polygon, integer)` ret ourne le contour intérieur (ligne) d'un polygone23 * :command:`ST_Perimeter(geometry)` ret ourne la longueur de tout les contours24 * :command:`ST_NumGeometries(multi/geomcollection)` ret ourne le nombre de composantes dans une collection25 * :command:`ST_GeometryN(geometry, integer)` ret ourne la niÚme entité de lacollection26 * :command:`ST_GeomFromText(text)` ret ourne``geometry``27 * :command:`ST_AsText(geometry)` ret ourneWKT ``text``28 * :command:`ST_AsEWKT(geometry)` ret ourneEWKT ``text``29 * :command:`ST_GeomFromWKB(bytea)` ret ourne``geometry``30 * :command:`ST_AsBinary(geometry)` ret ourneWKB ``bytea``31 * :command:`ST_AsEWKB(geometry)` ret ourneEWKB ``bytea``32 * :command:`ST_GeomFromGML(text)` ret ourne``geometry``33 * :command:`ST_AsGML(geometry)` ret ourneGML ``text``34 * :command:`ST_GeomFromKML(text)` ret ourne``geometry``35 * :command:`ST_AsKML(geometry)` ret ourneKML ``text``36 * :command:`ST_AsGeoJSON(geometry)` ret ourneJSON ``text``37 * :command:`ST_AsSVG(geometry)` ret ourneSVG ``text``38 39 Souvenez-vous aussi des tables qui sont disponibles:3 Section 9: Geometry Exercises 4 ============================= 5 6 Here's a reminder of all the functions we have seen so far. They should be useful for the exercises! 7 8 * :command:`sum(expression)` aggregate to return a sum for a set of records 9 * :command:`count(expression)` aggregate to return the size of a set of records 10 * :command:`ST_GeometryType(geometry)` returns the type of the geometry 11 * :command:`ST_NDims(geometry)` returns the number of dimensions of the geometry 12 * :command:`ST_SRID(geometry)` returns the spatial reference identifier number of the geometry 13 * :command:`ST_X(point)` returns the X ordinate 14 * :command:`ST_Y(point)` returns the Y ordinate 15 * :command:`ST_Length(linestring)` returns the length of the linestring 16 * :command:`ST_StartPoint(geometry)` returns the first coordinate as a point 17 * :command:`ST_EndPoint(geometry)` returns the last coordinate as a point 18 * :command:`ST_NPoints(geometry)` returns the number of coordinates in the linestring 19 * :command:`ST_Area(geometry)` returns the area of the polygons 20 * :command:`ST_NRings(geometry)` returns the number of rings (usually 1, more if there are holes) 21 * :command:`ST_ExteriorRing(polygon)` returns the outer ring as a linestring 22 * :command:`ST_InteriorRingN(polygon, integer)` returns a specified interior ring as a linestring 23 * :command:`ST_Perimeter(geometry)` returns the length of all the rings 24 * :command:`ST_NumGeometries(multi/geomcollection)` returns the number of parts in the collection 25 * :command:`ST_GeometryN(geometry, integer)` returns the specified part of the collection 26 * :command:`ST_GeomFromText(text)` returns ``geometry`` 27 * :command:`ST_AsText(geometry)` returns WKT ``text`` 28 * :command:`ST_AsEWKT(geometry)` returns EWKT ``text`` 29 * :command:`ST_GeomFromWKB(bytea)` returns ``geometry`` 30 * :command:`ST_AsBinary(geometry)` returns WKB ``bytea`` 31 * :command:`ST_AsEWKB(geometry)` returns EWKB ``bytea`` 32 * :command:`ST_GeomFromGML(text)` returns ``geometry`` 33 * :command:`ST_AsGML(geometry)` returns GML ``text`` 34 * :command:`ST_GeomFromKML(text)` returns ``geometry`` 35 * :command:`ST_AsKML(geometry)` returns KML ``text`` 36 * :command:`ST_AsGeoJSON(geometry)` returns JSON ``text`` 37 * :command:`ST_AsSVG(geometry)` returns SVG ``text`` 38 39 Also remember the tables we have available: 40 40 41 41 * ``nyc_census_blocks`` … … 72 72 .. note:: 73 73 74 L'aire est données en metres carrés. Pour obtenir l'aire en hectare, divisez par 10000. Pour obrenir l'aire en acres, divisez par4047.75 76 * **" Quelle est l'aire de Manhattan in acres ?"** (Astuce: ``nyc_census_blocks`` et ``nyc_neighborhoods`` on toutes deux le champ ``boroname``.)74 The area is given in square meters. To get an area in hectares, divide by 10000. To get an area in acres, divide by 4047. 75 76 * **"What is the area of Manhattan in acres?"** (Hint: both ``nyc_census_blocks`` and ``nyc_neighborhoods`` have a ``boroname`` in them.) 77 77 78 78 .. code-block:: sql … … 99 99 100 100 101 * **" Combien de bloques de la ville de New York ont des trous?"**101 * **"How many census blocks in New York City have a hole in them?"** 102 102 103 103 .. code-block:: sql … … 111 111 66 112 112 113 * **" Quel est la longueur totale des rues (en kilomÚtres) dans la ville de New York ?"** (Astuce: l'unité de mesure des données spatiales est le mÚtre, il y a 1000 mÚtres dans un kilomÚtre.)113 * **"What is the total length of streets (in kilometers) in New York City?"** (Hint: The units of measurement of the spatial data are meters, there are 1000 meters in a kilometer.) 114 114 115 115 .. code-block:: sql … … 122 122 10418.9047172 123 123 124 * **" Quelle est la longueur de 'Columbus Cir' (Columbus Circle)?**124 * **"How long is 'Columbus Cir' (Columbus Circle)?** 125 125 126 126 .. code-block:: sql … … 134 134 308.34199 135 135 136 * **" Quelle est le contour de 'West Village' au format JSON?"**136 * **"What is the JSON representation of the boundary of the 'West Village'?"** 137 137 138 138 .. code-block:: sql … … 149 149 [583263.2776595836,4509242.6260239873]]]]} 150 150 151 La géométrie de type "MultiPolygon", interressant!151 The geometry type is "MultiPolygon", interesting! 152 152 153 153 154 * **" Combien de polygones sont dans le multi-polygone 'West Village'?"**154 * **"How many polygons are in the 'West Village' multipolygon?"** 155 155 156 156 .. code-block:: sql … … 166 166 .. note:: 167 167 168 I l n'est pas rare de trouver des éléments de type multi-polygone ne contenant qu'un seul polygone dans des tables. L'utilisation du type multi-polygone permet d'utiliser une seule table pour y stoquer des géométries simples et multiples sans mélanger lestypes.169 170 171 * **" Quel est la longueur des rues de la ville de New York, suivant leur type?"**168 It is not uncommon to find single-element MultiPolygons in spatial tables. Using MultiPolygons allows a table with only one geometry type to store both single- and multi-geometries without using mixed types. 169 170 171 * **"What is the length of streets in New York City, summarized by type?"** 172 172 173 173 .. code-block:: sql … … 207 207 .. note:: 208 208 209 La clause ``ORDER BY length DESC`` ordonne le résultats par la valeurs des longueur dans l'ordre décroissant. Le résultat avec la plus grande valeur se retrouve au début la liste de résultats.209 The ``ORDER BY length DESC`` clause sorts the result by length in descending order. The result is that most prevalent types are first in the list. 210 210 211 211
Note: See TracChangeset
for help on using the changeset viewer.