我已經創建成功kml
文件名爲gis.kml
,現在我看到了一個邊際的大小變化,當您轉換KML到KMZ使用googleearth
。所以我在想如何轉換KML
到KMZ
在C#。我有代碼轉換任何文件爲.zip,但不會在這裏工作如何KML文件轉換爲KMZ文件在C#中
1
A
回答
0
郵編然後將文件擴展名更改爲KMZ
2
您可以將文件'中讀gis.kml'並將其內容添加到a KMZ文件,或者您可以編程方式創建KML元素並將其轉換爲字節數組以寫入KMZ流。該解決方案使用CSharpZipLib創建KMZ文件。
這裏是C#代碼片段創建KMZ文件:
using (FileStream fileStream = File.Create(ZipFilePath)) // Zip File Path (String Type)
{
using (ZipOutputStream zipOutputStream = new ZipOutputStream(fileStream))
{
// following line must be present for KMZ file to work in Google Earth
zipOutputStream.UseZip64 = UseZip64.Off;
// now normally create the zip file as you normally would
// add root KML as first entry
ZipEntry zipEntry = new ZipEntry("doc.kml");
zipOutputStream.PutNextEntry(zipEntry);
//build you binary array from FileSystem or from memory...
zipOutputStream.write(System.IO.File.ReadAllBytes("gis.kml"));
zipOutputStream.CloseEntry();
// next add referenced file entries (e.g. icons, etc.)
// ...
//don't forget to clean your resources and finish the outputStream
zipOutputStream.Finish();
zipOutputStream.Close();
}
}
也可以創建一個使用ZipArchive類的KMZ文件。
相關問題
- 1. 以編程方式在C#中創建KMZ文件KML文件
- 2. 如何將我的xml文件轉換爲kml文件
- 3. 將.kml轉換爲.txt文件
- 4. 如何使用geoxml3獲取KMZ或KML文件的界限?
- 5. 如何從KML使用Java動態創建KMZ文件
- 6. 使用PHP或Javascript將KML文件轉換爲圖像文件
- 7. KMZ文件
- 8. 如何將.xlsx文件轉換爲.mpp文件在c#
- 9. 如何將pdf文件轉換爲C#.net中的xml文件?
- 10. 嵌套KMZ文件
- 11. 如何將m文件轉換爲c文件
- 12. 將KML文件轉換爲java中的geoJson
- 13. .net中的shp文件並將其轉換爲kml
- 14. 鏈接到Google Drive上的kml/kmz文件
- 15. 如何在Delphi中將Html文件轉換爲pdf文件
- 16. 如何在iphone中將jpeg文件轉換爲pdf文件?
- 17. 將二進制文件轉換爲C中的文本文件
- 18. 如何在Android中創建KML文件?
- 19. 如何在Android中製作kml文件?
- 20. 如何使用powershell替換KMZ文件中的字符串
- 21. 如何將文本文件轉換爲java中的TIF文件
- 22. 如何將字節數組轉換爲zip文件在c#中?
- 23. 如何使用KML文件
- 24. kml文件如何工作?
- 25. 將C#2008文件轉換爲C#2010
- 26. 在Google地圖中使用KMZ文件
- 27. 在c#中轉換excel文件在xml文件中#
- 28. C++:如何將C庫文件IO轉換爲C++流IO?
- 29. 如何將.doc文件轉換爲.pdf文件在android
- 30. 如何在Mac上將.po文件轉換爲.mo文件?
Peter:請參閱以下網頁:https://developers.google.com/kml/documentation/kmzarchives – jdweng
這意味着ZIP實用程序是否足夠?我使用7zip從kml和zip文件中使用googleearth創建了kmz文件,並找到了一些KB大小的差異。因此認爲它會有所不同。但是你發送的鏈接提到了相同的 – peter
只要確保在kml中引用的任何文件在kmz中的正確位置。描述說kmz必須有一個文件夾(可能是空的)。 – jdweng