Vector Data Processing using Python Tools

Encodings, Formats and Libraries

Overview

Teaching: 10 min
Exercises: 0 min
Questions
  • What are common ways to encode vector geospatial data in Python, and how do they relate to broader encoding standards?

Objectives
  • Learn about common community standards (broader than Python) for vector data encoding, and how they’re implemented in core Python libraries.

  • Learn to transform from one encoding type to another. Learn the GeoJSON format and exchange encoding interface, including the __geo_interface__ method implemented across libraries.

Standard Geometry/Data Encodings

Standards exist for text (and binary) encoding of the geometry and feature types we saw. These include OGC/ISO Well-Known Text (WKT) and Well-Known Binary (WKB), OGC Geography Markup Language (GML), and GeoJSON (based on JSON, and now an ISO standard). GML is a complex XML-based encoding that we won’t discuss much here. We also won’t touch on WKB in much detail. In this tutorial we’ll focus on WKT and specially GeoJSON.

WKT

WKT text representations of geometric entities are fairly intuitive. Here are some examples of the basic geometric entities we saw earlier (where coordinates are ordered as X Y):

GeoJSON and __geo_interface__ interface

GeoJSON Example:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [102.0, 0.5]
      },
      "properties": {
        "prop0": "value0",
        "prop1": 0
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [-90.0, 10.5]
      },
      "properties": {
        "prop0": "value3",
        "prop1": 3
      }
    }
  ]
}

GIS file formats, including Relational Databases (RDBMS)

Standard encodings and libraries for projections, codes

Key Points