Free Support Forum - aspose.com

How to control the accuracy when conversion to geojson

{“type”:“FeatureCollection”, “features”:[
{“type”:“Feature”,“geometry”:{“type”:“Polygon”,“coordinates”:[[[140.02461258430064,32.25555555550106716,-0.08400000000256114]…

x,y,z too long, can we control the accuracy?

Hi, @lsl

Yes, you can do it. Please consider the below code that converts a shapefile to geojson.

        var options = new ConversionOptions()
        {
            DestinationDriverOptions = new GeoJsonOptions()
            {
                XYPrecisionModel = PrecisionModel.Rounding(2),
                ZPrecisionModel = PrecisionModel.Rounding(2),
                MPrecisionModel = PrecisionModel.Rounding(2),
            }
        };

        VectorLayer.Convert(
            "source.shp", Drivers.Shapefile,
            "destination.json", Drivers.GeoJson, options);

Best regards.

ok, I get it, work fine now, thanks