IMPORT POLYGONS Statement |
This statement converts GIS-formatted polygons data to GBFS data.
IMPORT POLYGONS [id = %id_col, gbfs1 = %col1] FROM "path\src_file" WHERE condition;
Nomenclature
id_col | A column of unique numerical identifiers in the source table. |
gbfsX | One or more GBFS columns. See the 'Columns' section below for a list of appropriate GBFS columns. |
colX | An expression referencing one or more GIS columns in src_file. This column will be converted to GBFS data. |
path\src_file | Specifies the path and file containing the GIS shapefile data. |
condition | A logic expression that is satisfied by a subset of the data in path\src_file. This expression, along with the WHERE keyword, is optional. |
By examining the sample 'waterbody.dbf' shapefile (found in the 'GeoBase Examples\Alchemy\Allegheny' folder) using a spreadsheet package we see that there are 7 columns: 'ID', 'AREA', 'PERIMETER', and so on.
Knowing that bodies of water are polygons, we will use the IMPORT POLYGONS command to import this data. The 'ID' column (above) provides a unique ID for each feature and we will use the 'NAME' column as the label. The language is English.
The IMPORT POLYGONS statement to import the geometries of the polygons would be structured as follows:
IMPORT POLYGONS [ ID = %ID, LABEL = %NAME, LANG = "ENG" ] FROM "waterbody";
To import only the bodies of water with an area greater than (for example) 1000 we would add a WHERE clause to the IMPORT POLYGONS statement, as follows:
IMPORT POLYGONS [ ID = %ID, LABEL = %NAME, LANG = "ENG" ] FROM "waterbody" WHERE %AREA > 1000;
The following GBFS columns are available for population through the Alchemy IMPORT POLYGONS command.
Column | Description | Type | Length | Values |
ABBREV | When the full text of the LABEL cannot be rendered on a map, the ABBREV text is displayed. | Text | Variable | |
LABEL | The label assigned to this polygon data. This label may be rendered by GeoBase on a map. | Text | Variable | |
LANG | Language code: the language that should be associated with this polygon. | Text | 3 | ENG: English FRE: French SPA: Spanish complete list |
TYPE | The type of this polygon. See the 'Polygon Types' table, below. | Numeric | Variable | 0-25 |
This table shows the different polygon types. The polygon TYPE field should contain one of the type values listed below (in the left column).
Name | Description |
0 | Oceans |
1 | States |
2 | Cities |
3 | Bays |
4 | Water |
5 | Buildings |
6 | Unused |
7 | Unused |
8 | Airports |
9 | Cemeteries |
10 | Hospitals |
11 | Industrial complexes |
12 | Military bases |
13 | National parks |
14 | State parks |
15 | County parks |
16 | Shopping centers |
17 | Sports complexes |
18 | Colleges |
19 | Aircraft roads (runways & taxi-ways) |
20 | Golf courses |
21 | Native American reservations |
22 | Countries |
23 | Counties |
24 | Islands |
25 | Land |
26 | Global water |
To import Polygons from CSV format text files, use the following format.
IMPORT POLYGONS [id = %id, name = %name, geom = wkt((%polygon))] FROM "csv://src_file";
id | A column of unique identifiers in the CSV source file. |
name | An expression referencing one or more column in the CSV source file. |
geom | A column of polygon data stored as well known text (WKT) in the CSV source file. |
polygon_id,polygon_label,polygon_type,polygon_data 1,Telogis Park,15,"POLYGON((-118.268898 34.045484,-118.267866 34.045484,-118.267866 34.044802,-118.268902 34.044798,-118.268898 34.045484))"
Note |
---|
Note the formatting of our polygon geometry. For Well Known Text, the location of each vertice should be formatted as 'Longitude Latitude', reversing the conventional GeoBase standard of 'Latitude Longitude'. Note also the use of a space as a separator rather than a comma (commas are is used instead to separate field values). |
The IMPORT POLYGONS statement required to import data from the example CSV file shown above is:
IMPORT POLYGONS [ id = %polygon_id, label = %polygon_label, type = %polygon_type, geom = wkt(%polygon_data) ] FROM "csv://mycsvfile.csv";
The 'polygon_id' column provides a unique ID for each polygon shape, the 'polygon_label' column a name for each polygon and the 'polygon_type' the type of polygon (refer to the 'Polygon Types' table above). The 'polygon_data' column provides polygon data stored as WKT string Polygons.
Polygon data stored in the CSV file should be contained within quotes, unless data is separated by pipes; for example:
polygon_id|polygon_label|polygon_type|polygon_data 1|Telogis Park|15|POLYGON((-118.268898 34.045484,-118.267866 34.045484,-118.267866 34.044802,-118.268902 34.044798,-118.268898 34.045484)) .....