Click or drag to resize

IMPORT POLYGONS Statement

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
IMPORT POLYGONS Statement

This statement converts GIS-formatted polygons data to GBFS data.

Syntax

Alchemy
IMPORT POLYGONS [id = %id_col, gbfs1 = %col1] FROM "path\src_file" WHERE condition;

Nomenclature

Nomenclature

id_colA 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.

Example

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.

sfi alleghenytable

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:

Alchemy
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:

Alchemy
IMPORT POLYGONS [
  ID = %ID,
  LABEL = %NAME,
  LANG = "ENG"
] FROM "waterbody" WHERE %AREA > 1000;

Column Names

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

Polygon Types

This table shows the different polygon types. The polygon TYPE field should contain one of the type values listed below (in the left column).

NameDescription
0Oceans
1States
2Cities
3Bays
4Water
5Buildings
6Unused
7Unused
8Airports
9Cemeteries
10Hospitals
11Industrial complexes
12Military bases
13National parks
14State parks
15County parks
16Shopping centers
17Sports complexes
18Colleges
19Aircraft roads (runways & taxi-ways)
20Golf courses
21Native American reservations
22Countries
23Counties
24Islands
25Land
26Global water

IMPORT POLYGONS From CSV Files

To import Polygons from CSV format text files, use the following format.

Alchemy
IMPORT POLYGONS [id = %id, name = %name, geom = wkt((%polygon))] FROM "csv://src_file";

Nomenclature

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.

Example

CSV
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

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:

Alchemy
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:

CSV
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))
.....