Aspose.GIS for .NET API 允许您处理以各种文件格式存储的地理空间数据。它使您能够渲染地图以及创建、读取和转换地理数据,而无需任何其他软件。
Aspose.GIS最新试用版
用于将 Shapefile 转换为 GeoJSON 的 C# API,反之亦然
Aspose.GIS for .NET API 允许您渲染地图并创建、读取和转换地理数据,而无需额外的软件。此外,该 API 允许您将 Shapefile 转换为 GeoJSON,反之亦然。
使用 C# 将 Shapefile 转换为 GeoJSON
以下是将Shapefile 转换为GeoJSON 的步骤。
使用VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver)方法将 Shapefile 转换为 GeoJSON。
以下示例代码显示了如何使用 C# 将 Shapefile 转换为 GeoJSON。
string shapefilePath = dataDir + "InputShapeFile.shp";string jsonPath = dataDir + "output_out.json";VectorLayer.Convert(shapefilePath, Drivers.Shapefile, jsonPath, Drivers.GeoJson);
将 GeoJSON 转换为 Shapefile
与将 Shapefile 转换为 GeoJSON 类似,GeoJSON 文件只需一行代码即可转换为 Shapefile。以下是将 GeoJSON 转换为 Shapefile 的步骤。
使用VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver)方法将 GeoJSON 转换为 Shapefile。
以下示例代码显示了如何使用 C# 将 GeoJSON 转换为 Shapefile。
string jsonPath = dataDir + "output_out.json";string outShapefilePath = dataDir + "OutputShapeFile_out.shp";VectorLayer.Convert(jsonPath, Drivers.GeoJson, outShapefilePath, Drivers.Shapefile);
如果你想试用Aspose的全部完整功能,可联系在线客服获取30天临时授权体验。
如果您有任何疑问或需求,请随时加入Aspose技术交流群(599154289),我们很高兴为您提供查询和咨询。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!