Quantization‎ > ‎

## Methods

PYXIS DGGS SDK provides 2 methods to read, sample, and quantize data values from vector (feature) data files into DGGS cells:

1. Rapid Rasterization: At any DGGS resolution a vector is represented as a rasterization of the vector with its associated attributes set as data values in the DGGS cells.
2. Multi-Resolution GeoPacket: A vector tree is formed that represents the rasterization of the vectors at all resolutions of the DGGS while data values are represented as statistical summaries of the associated attribute values.

## Sampling Vector Geometry

The first step in representing a DGGS GeoSource is to open the native vector file and extract the following from the file:.
1. Spatial Domain Information - Information about the native coordinate system, native bbox, scale, data types, etc.
2. Data Definition - Describes the attribute value domain and value types return from the feature.
The second step is the rasterization of the associated vector by representing it as a collection of DGGS cells.  The subject of representing vector geometries in a regular square raster grid is well understood and widely implemented.  However, the rasterization of spherical geometries into hexagonal tessellations require some attention.  The PYXIS DGGS SDK provide optimized implementations of several techniques of vector rasterization:
• Cell tracing of great circle arcs (O(cells x arcs) - border only)
• Multi-resolution distance based vector rasterization ( O(log(cells) x arcs) ) - including support for buffers.
• Multi-resolution, multi-details simplification based on tessellation error bounds ( O(log(cells) x log(arcs)) ) - including support for buffers.
• Hybrid representation and indexing of vectors. (indexing O(log(cells) x log(arcs)), raster: O(1))
At code level, PYXVectorRegion provide the basic class for all vector based regions. and region can be rasterized on demand into DGGS set of cells using PYXVectorGeometryPYXVectorGeometry2 (optimized implementation).

## Quantization of Vector Data

Once the cells of a DGGS area associated with a particular vector geometry the final step is to quantize vector attribute data into associated DGGS cells.  A bounding cell for each feature entity is calculated and the attribute is assigned to the cell.  The GDAL/OGR File Reader is used to identify all features that intersects a given cell.

If a mutli-resolution GeoPacket is to be generated, statistical summaries are created for each numerical attribute value associated with the feature.  The rasterization of each feature and statistical summary are stored for each ISEA3H resolution to form a vector tree that enable progressive streaming of very large vectors and their attribute data.

## Interactive Example

Rapid Rasterization logic as a naive implementation using PYXIS HTML5 canvas API.
{"ft_lang_label":"__label__en","ft_lang_prob":0.89625657,"math_prob":0.866423,"size":1336,"snap":"2021-43-2021-49","text_gpt3_token_len":271,"char_repetition_ratio":0.124624625,"word_repetition_ratio":0.0,"special_character_ratio":0.1744012,"punctuation_ratio":0.071428575,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9591962,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-18T02:03:58Z\",\"WARC-Record-ID\":\"<urn:uuid:76c483f1-452a-4f76-8f4f-f708c8366e15>\",\"Content-Length\":\"39948\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4954258d-9c6b-440b-8e71-9c9db21eee73>\",\"WARC-Concurrent-To\":\"<urn:uuid:309a8b4f-5ab7-4bf6-b80b-36514250176f>\",\"WARC-IP-Address\":\"172.217.15.83\",\"WARC-Target-URI\":\"http://sdk.pyxisinnovation.com/quantization/vectors\",\"WARC-Payload-Digest\":\"sha1:D7GZLB3M6LUNXLWLPEF4D57LF3QGXQLN\",\"WARC-Block-Digest\":\"sha1:KXB7T2WMLUW2ZTJKNKGZDW7S5MHTAODO\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585186.33_warc_CC-MAIN-20211018000838-20211018030838-00485.warc.gz\"}"}