You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I greatly appreciate for any help, I deserialized GeoJson file into feature collection using GeoJson.Net. Then I get the feature from the feature collection. Inside the feature I can loop and get all the type of geometry. From there I can loop each of the type and get the coordinate. However now I am stuck on how to edit to add Altitude equal to 0 for each coordinate then serialize back to geojson.
string filePath = @"D:\test.geojson";
FeatureCollection collection = JsonConvert.DeserializeObject<FeatureCollection>(File.ReadAllText(filePath)); //1 min 21 s
var feature = collection.Features;
foreach (var featureItem in feature)
{
if (featureItem.Geometry.Type.Equals(GeoJSONObjectType.Point))
{
Point point = featureItem.Geometry as Point;
}
else if (featureItem.Geometry.Type.Equals(GeoJSONObjectType.MultiPoint))
{
}
else if (featureItem.Geometry.Type.Equals(GeoJSONObjectType.Polygon))
{
Polygon polygon = featureItem.Geometry as Polygon;
foreach (var Item in polygon.Coordinates)
{
foreach (var coordinates in Item.Coordinates)
{
//Here I want to add value 0 altitude coordinate
}
}
}
else if (featureItem.Geometry.Type.Equals(GeoJSONObjectType.MultiPolygon))
{
MultiPolygon multiPolygon = featureItem.Geometry as MultiPolygon;
foreach (var Item in multiPolygon.Coordinates)
{
foreach (var item1 in Item.Coordinates)
{
foreach (var item2 in item1.Coordinates)
{
//Here I want to add value 0 altitude coordinate
}
}
}
}
}
//here I want to serialize my FeatureCollection after edit
File.WriteAllText(@"D:\test_Edit.geojson", JsonConvert.SerializeObject(collection));
My expected output is to add Altitude equal to 0 like below:
I greatly appreciate for any help, I deserialized GeoJson file into feature collection using GeoJson.Net. Then I get the feature from the feature collection. Inside the feature I can loop and get all the type of geometry. From there I can loop each of the type and get the coordinate. However now I am stuck on how to edit to add Altitude equal to 0 for each coordinate then serialize back to geojson.
This is my sample test.geojson file:
My expected output is to add Altitude equal to 0 like below:
The text was updated successfully, but these errors were encountered: