翻譯|使用教程|編輯:張瑩心|2021-11-17 11:25:39.737|閱讀 445 次
概述:在不同的情況下,使用Shapefile或GeoJSON格式的數(shù)據(jù)會(huì)有所幫助。如果您有一個(gè)想要轉(zhuǎn)換為 GeoJSON 的 Shapefile,反之亦然,您可以使用 C# 以編程方式輕松實(shí)現(xiàn)它。在本文中,您將學(xué)習(xí)如何做到這一點(diǎn)。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
在不同的情況下,使用Shapefile或GeoJSON格式的數(shù)據(jù)會(huì)有所幫助。如果您有一個(gè)想要轉(zhuǎn)換為 GeoJSON 的 Shapefile,反之亦然,您可以使用 C# 以編程方式輕松實(shí)現(xiàn)它。在本文中,您將學(xué)習(xí)如何做到這一點(diǎn)。
Aspose.GIS for .NET API 允許您處理以各種文件格式存儲(chǔ)的地理空間數(shù)據(jù)。它使您能夠渲染地圖以及創(chuàng)建、讀取和轉(zhuǎn)換地理數(shù)據(jù),而無(wú)需任何其他軟件。
用于將 Shapefile 轉(zhuǎn)換為 GeoJSON 的 C# API,反之亦然
Aspose.GIS for .NET API 允許您渲染地圖并創(chuàng)建、讀取和轉(zhuǎn)換地理數(shù)據(jù),而無(wú)需額外的軟件。此外,該 API 允許您將 Shapefile 轉(zhuǎn)換為 GeoJSON,反之亦然。
使用 C# 將 Shapefile 轉(zhuǎn)換為 GeoJSON
以下是將Shapefile 轉(zhuǎn)換為GeoJSON 的步驟。
使用VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver)方法將 Shapefile 轉(zhuǎn)換為 GeoJSON。
以下示例代碼顯示了如何使用 C# 將 Shapefile 轉(zhuǎn)換為 GeoJSON。
string shapefilePath = dataDir + "InputShapeFile.shp"; string jsonPath = dataDir + "output_out.json"; VectorLayer.Convert(shapefilePath, Drivers.Shapefile, jsonPath, Drivers.GeoJson);將 GeoJSON 轉(zhuǎn)換為 Shapefile
與將 Shapefile 轉(zhuǎn)換為 GeoJSON 類似,GeoJSON 文件只需一行代碼即可轉(zhuǎn)換為 Shapefile。以下是將 GeoJSON 轉(zhuǎn)換為 Shapefile 的步驟。
使用VectorLayer.Convert(string sourcePath, FileDriver sourceDriver, string destinationPath, FileDriver destinationDriver)方法將 GeoJSON 轉(zhuǎn)換為 Shapefile。
以下示例代碼顯示了如何使用 C# 將 GeoJSON 轉(zhuǎn)換為 Shapefile。
string jsonPath = dataDir + "output_out.json"; string outShapefilePath = dataDir + "OutputShapeFile_out.shp"; VectorLayer.Convert(jsonPath, Drivers.GeoJson, outShapefilePath, Drivers.Shapefile);
如果你想試用Aspose的全部完整功能,可聯(lián)系在線客服獲取30天臨時(shí)授權(quán)體驗(yàn)。
如果您有任何疑問(wèn)或需求,請(qǐng)隨時(shí)加入Aspose技術(shù)交流群(599154289),我們很高興為您提供查詢和咨詢。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn