Mapping With Drupal - Alan Palazzolo [9]
Data Types
There are two main data types when talking about geospatial data: vector (such as points and lines) and raster (such as satellite imagery).
Vector data
Most often, geospatial data is represented as geometric shapes and stored sets of numbers representing these shapes; these are most commonly points, lines, or polygons.
Vector data standards
Three of the main geographic data storage types are shown in the table below (Table 2-1) for point data and polygon data (a shape), along with a text version. When we think about a place, typically we refer to its name, for example, New York. But this is not very useful when we try to do calculations or comparisons. What do we mean when we say New York? Are we talking about the city? The state? The borough of Manhattan? And nothing in the names Shanghai and Sydney is any help in determining where they are or what the distance is between them. Representing a location with numbers (for example latitude and longitude) removes this ambiguity.
A location as a latitude and longitude is not always useful, though. It is just a single point. Sometimes we need to represent a shape, normally referred to as a polygon in mapping. Only polygon data can answer questions like “Is Manhattan an island?” Whereas point data can be described as two separate fields in a database, polygons require more complicated data storage types, such as Well Known Text (WKT) and Keyhole Markup Language (KML).
WKT is a versatile format, because it is text that can be read and stored very easily. It is supported in Drupal by the Geofield module, and is used in the tutorials in Geofield Module. As is shown in Table 2-1, WKT is flexible in the type of geographic data it can handle: it can be used to represent a single point with just one latitude and longitude; it can represent a line (a series of points); or it can represent a polygon (a line that connects at each end).
KML is a file format used to display geographic data using a structure that is based on XML. It is widely used because of its support in Google Maps and Google Earth. As a file format it is not suited to being stored in a database. Instead, it is useful when you want to share geographic information with other websites and applications, especially if you do not need to update this information frequently. Using KML files on your maps is covered in Creating an OpenLayers Map Layer from KML, and creating KML files is described in the tutorial in Creating Feeds.
There are many other geographic data formats. GPX and TCX are based on XML. They are formats used by GPS (global positioning systems) devices to track routes and way points. GeoJSON is based on JSON (JavaScript Object Notation), which is generally more compact than XML. Like WKT, GeoJSON is able to represent many different geographic data types.
Table 2-1. Data standards examples
Standards Point Data (New York City) Polygon Data (border of Manhattan)
Descriptive Text New York City, New York Borough of Manhattan, New York
Longitude/Latitude -74, 40.71 n/a
Well Known Text (WKT) POINT(-74, 40.71)
POLYGON((
-73.924942016601 40.877698964746,
-73.909149169922 40.8709493023,
-73.934555053711 40.828878212816,
-73.927688598633 40.798736824942,
-73.975067138672 40.712394426605,
-74.020385742188 40.698340181788,
-74.010086059571 40.75193859846,
-73.924942016601 40.877698964746
))
Keyhole Markup Language (KML) xmlns:kml= "http://www.opengis.net/kml/2.2" xmlns:gx= "http://www.google.com/kml/ext/2.2" xmlns:atom= "http://www.w3.org/2005/Atom"> -74.005973,40.714353,0
xmlns:kml= "http://www.opengis.net/kml/2.2" xmlns:gx= "http://www.google.com/kml/ext/2.2" xmlns:atom= "http://www.w3.org/2005/Atom">