翻譯|使用教程|編輯:張瑩心|2021-11-17 11:25:39.737|閱讀 438 次
概述:在不同的情況下,使用Shapefile或GeoJSON格式的數據會有所幫助。如果您有一個想要轉換為 GeoJSON 的 Shapefile,反之亦然,您可以使用 C# 以編程方式輕松實現它。在本文中,您將學習如何做到這一點。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在不同的情況下,使用Shapefile或GeoJSON格式的數據會有所幫助。如果您有一個想要轉換為 GeoJSON 的 Shapefile,反之亦然,您可以使用 C# 以編程方式輕松實現它。在本文中,您將學習如何做到這一點。
Aspose.GIS for .NET API 允許您處理以各種文件格式存儲的地理空間數據。它使您能夠渲染地圖以及創建、讀取和轉換地理數據,而無需任何其他軟件。
用于將 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),我們很高興為您提供查詢和咨詢。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn