Using the GeoJson.Net lib, how do I serialize a GeoJson.Net.Geometry.MultiPoint to a VALID MultiPoint GeoJSON file?

All I can find is how to serialize a random Geometry object to a JSON file that cannot be read for instance in QGIS.

  • 1
    can you show what you have tried so far? – Brad Mar 31 '17 at 16:06

I was able to serialize with no problem and view in both QGIS 2.18 and 3.2.1.

Using a modified version of the GeoJSON.Net Multipoint serialization test:

using System;
using System.Collections.Generic;
using System.IO;
using Agema.Common;
using GeoJSON.Net.Geometry;
using Newtonsoft.Json;

namespace geojson_serialize_example
    internal class Program
        private static void Main(string[] args)
            var points = new List<Point>
                new Point(new Position(52.370725881211314, 4.889259338378906)),
                new Point(new Position(52.3711451105601, 4.895267486572266)),
                new Point(new Position(52.36931095278263, 4.892091751098633)),
                new Point(new Position(52.370725881211314, 4.889259338378906))

            var multiPoint = new MultiPoint(points);

            var actualJson = JsonConvert.SerializeObject(multiPoint);
            // ReSharper disable once UseFormatSpecifierInInterpolation
            var outputFilePath = Path.Combine(TempFileHelper.GetTemporaryDirectory(),

            File.WriteAllText(outputFilePath, actualJson);

            Console.WriteLine($"GeoJson Geometry Written To: {outputFilePath}");

This produced:

    "type": "MultiPoint",
    "coordinates": [[4.8892593383789062, 52.370725881211314], [4.8952674865722656, 52.3711451105601], [4.8920917510986328, 52.369310952782627], [4.8892593383789062, 52.370725881211314]]

which I was able to view in QGIS:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.