Aspose.GIS for .NET API 允许您处理以各种文件格式存储的地理空间数据。它使您能够渲染地图以及创建、读取和转换地理数据,而无需任何其他软件。
Aspose.GIS最新试用版
用于将 JSON 转换为 GeoJSON 的 C# API
Aspose.GIS for .NET API 允许您渲染地图并创建、读取和转换地理数据,而无需额外的软件。
使用 C# 将 JSON 转换为 GeoJSON
以下是将 JSON 转换为 GeoJSON 的步骤。
- 创建ConversionOptions类的实例。
- 使用DestinationSpatialReferenceSystem属性将SpatialReferenceSystem.Wgs84分配给ConversionOptions对象。
- 使用VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver, ConversionOptions options)方法将 JSON 转换为 GeoJSON 。
以下示例代码显示了如何使用 C# 将 JSON 转换为 GeoJSON
// Specify conversion settings if necessary. It is optional.ConversionOptions options = null;// This options assigns Wgs84 to the destination layer.// Conversion may throw error If destination layer does not support the Wgs84 spatial reference. So need to check.if (Drivers.Shapefile.SupportsSpatialReferenceSystem(SpatialReferenceSystem.Wgs84)){options = new ConversionOptions(){DestinationSpatialReferenceSystem = SpatialReferenceSystem.Wgs84,};}// Convert file format from JSON to GeoJSON.VectorLayer.Convert("source.geojson", Drivers.GeoJson, "destination.geojson", Drivers.GeoJson, options);
如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。
如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!