TransWikia.com

NetTopologySuite: How to convert Polygon into LineString?

Geographic Information Systems Asked on December 25, 2021

I have a load of GeoJSON which represents roads that are defined as Polygons in the data. I wish to convert them into a simpler representation so as to reduce the amount of noise in the presentation.

Is there any way to do this using the NetTopologySuite?

One Answer

Polygons can be converted into LineString simply by obtaining his boundary:

IGeometry pol = ...;
IGeometry lineString = pol.Boundary;

Notice that if you have a polygon with holes, the boundary will return a MultiLineString for each part of the polygon. You will have to explode it afterwards to get simple LineStrings.

Answered by César Argul García on December 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP