Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the conversion between GeoJSON coordinates and WKT

Shulou Source: shulou.com Published: 2022-06-01 14:03:09 09月23日 Update

GeoJSON coordinates and WKT conversion is what, I believe that many inexperienced people are helpless about this, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

The OpenGIS specification defines two standard ways to represent spatial objects: one in the WKT (the Well-Known Text) form and the other in the WKB (the Well-Known Binary) form. Both forms include information about the type of object and coordinates that form the object. "

The following is an example of a spatial object that uses characters to describe features:

POINT(0 0) 
 LINESTRING(0 0,1 1,1 2) 
 POLYGON ((90 0,4 0,4 4,0 4,0 0),(1 1 ,2 1, 2 2, 1 2, 1 1))

GeoJSON is a format for encoding various geographic data structures, a geospatial information data exchange format based on Javascript object notation. GeoJSON objects can represent geometry, features, or feature collections.

Coordinates in GeoJSON appear as follows:

"geometry": {

"type": "Point",

"coordinates": [102.0, 0.5]

}

"geometry": {

"type": "LineString",

"coordinates": [[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]

}

Generally, the map client supports loading layers in the form of GeoJSON. In the backend database processing, coordinates in WKT format are generally returned. Therefore, there needs to be a conversion process in the middle. Of course, in the new version of PostGIS, GeoJSON data can be returned directly.

Mapbox open js library, you can coordinate the form of the two conversion.

Github address:

https://github.com/mapbox/wellknownwkt and geojson coordinate formats:

const { parse, stringify } = require('wellknown');

let _feature = parse('POINT(1 2)');

let _stringdata = stringify(_feature);

This is how nodejs works, and other uses are explained on github. After reading the above, do you know how to convert GeoJSON coordinates and WKT? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: Coordinates objects forms data formats information space content geography ways methods more features problems support helplessness for this two examples geometry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno vpn Huawei MySQL Shulou Information