Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the conversion between GeoJSON coordinates and WKT

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology