谷歌地球里面可以顯示KML工具,但是很多地圖都是Shp文件格式,所以需要轉(zhuǎn)換一下。
Esri 的地圖文件 shp 格式轉(zhuǎn)google earth kml的方法很多,有人說利用Arcgis來轉(zhuǎn),但是如果沒有arcgis, 是不是有另外方法?
可以利用免費的Ogr2Ogr.exe命令行工具進行轉(zhuǎn)換,它們都是開源的工具,GDAL/OGR Binaries Proj.4 FWTools 你可以從下面的連接下載
http://trac./gdal/wiki/DownloadingGdalBinaries
http://trac./proj/ 這里下載 proj.dll
當(dāng)然,最好是一口氣從這里下載 http://fwtools./
上帝之眼 http://www./ 里面有人已經(jīng)提到使用Ogr2Ogr把Shp文件轉(zhuǎn)換為KML文件的方法: 1.下載并安裝 FWTools, 2.下載并安裝 Google Earth. 3從“開始”中選擇 "FWTools Shell" 4.下載壓縮文件 zipped shape file. (shp文件里面有prj投影文件) 5.解壓縮文件到 C:\temp\ 6.在控制平臺中輸入如下命令,回車即可完成轉(zhuǎn)換 ogr2ogr.exe -f KML C:\temp\smdo2.kml C:\temp\smdo2
當(dāng)然,英文版的說得更明白,摘錄如下: http://code.google.com/intl/zh-CN/apis/kml/articles/vector.html
ogr2ogr
GDAL provides a powerful set of libraries for working with vector data. In particular, ogr2ogr is a powerful utility for data conversion. Many applications, including some of those mentioned above, incorporate GDAL/OGR.
To get started, download and install GDAL. Then you will need a shapefile. For purposes of this tutorial, try using one from DataSF. The example below uses the realtor_neighborhoods shapefile, which can be obtained, after agreeing to their license, here. Once you've downloaded the file, unzip it into a directory that you will remember. Open up a command line and navigate to the directory that you put the data in. Now for the fun part.
ogr2ogr can be used from the command line very easily. Here is how you could convert realtor_neighborhoods from a shapefile to KML:
ogr2ogr -f "KML" -where "NBRHOOD='Telegraph Hill'" realtor_neighborhoods.kml realtor_neighborhoods.shp
Here's a breakdown of what that command does:
ogr2ogr : This is the core command.-f "KML : This sets the output format to KML.-where "NBRHOOD='Telegraph Hill'" : This is an optional where clause, like in SQL. Basically, it allows you to query the data based on metadata. It works with shapefiles and other file types that support querying. In this case, it is querying for the NBRHOOD field, and only selecting features that have a NBRHOOD of Telegraph Hill. If you leave that parameter off, ogr2ogr gives you every neighborhood polygon.realtor_neighborhoods.kml : This is the output file name. Output file name comes first.realtor_neighborhoods.shp : This is the input file name. The .shp file represents the whole shapefile.
That's it, it's very simple. This command writes a KML file that looks like this: <?xml version="1.0" encoding="utf-8" ?> <kml xmlns="http://www./kml/2.2"> <Document><Folder><name>realtor_neighborhoods</name> <Schema name="realtor_neighborhoods" id="realtor_neighborhoods"> <SimpleField name="Name" type="string"></SimpleField> <SimpleField name="Description" type="string"></SimpleField> <SimpleField name="OBJECTID" type="float"></SimpleField> <SimpleField name="NBRHOOD" type="string"></SimpleField> <SimpleField name="SFAR_DISTR" type="string"></SimpleField> </Schema> <Placemark> <ExtendedData><SchemaData schemaUrl="#realtor_neighborhoods"> <SimpleData name="OBJECTID">81</SimpleData> <SimpleData name="NBRHOOD">Telegraph Hill</SimpleData> <SimpleData name="SFAR_DISTR">District 8 - Northeast</SimpleData> </SchemaData></ExtendedData> <Polygon><outerBoundaryIs><LinearRing><coordinates>-122.41041847319012,37.805924016582715,0 -122.407203813674,37.806324902060979,0 -122.40667792852096,37.803710121958744,0 -122.40348255423899,37.804117462290641,0 -122.40237202127015,37.798540648764529,0 -122.40876046662795,37.797723222540775,0 -122.41041847319012,37.805924016582715,0</coordinates></LinearRing></outerBoundaryIs></Polygon> <Style><LineStyle><color>ff0000ff</color></LineStyle> <PolyStyle><fill>0</fill></PolyStyle></Style> </Placemark> </Folder></Document></kml>
本人實際操作了一下,可行,放上截圖,轉(zhuǎn)換好后的kml顯示中文也許有亂碼問題,
這時可以用notepad打開kml文件,然后用utf-8方式再存一下盤,就可以了。
|