有时候需要找些地图Shape文件来测试一下程序,分享一下我的步骤:
Shape文件可以由网络上搜索,比如新浪爱问(http://ishare.iask.sina.com.cn/)里面搜索"矢量地图",你可以得到上海矢量地图文件。
这个格式是MapInfo格式的,MapInfo是美国MapInfo公司的桌面地理信息系统软件,
上海矢量地图文件例子里面可以看到poi.tab, poi.id, poi.map, poi.dat
还是用上篇博客的老办法,利用 fwtools 2.4.7 里面的 ogr2ogr.exe 工具
1) 建立一个MapInfo2Shap目录,把poi.tab, poi.id, poi.map, poi.dat 放入那个目录
2)下载 fwtools ( fwtools.maptools.org) 并运行Fwtools shell
3)运行 ogr2ogr -f "ESRI Shapefile" Mapinfo2Shp\poi.shp Mapinfo2Shp\poi.tab
4)SET OGR_FORCE_ASCII=NO 设置这个环境变量的目的是可以显示中文信息
5)ogr2ogr.exe -f "KML" Mapinfo2Shp\poi.kml Mapinfo2Shp
6)Notepad 打开poi.kml 并用utf-8方式存盘转换一下
7)Google Earth可以打开poi.kml看结果了。
下面是别人写的英文步骤
For a while now I've been searching for a way to convert MapInfo files to ESRI shape format so that I can use them in MapWindow GIS and today I came across an open source GIS/RS binary kit called FWTools (created by Frank Warmerdam) which you can find at [fwtools.maptools.org]
After installing FWTools you should have a new FWTools menu group in Start->All Programs list. From there you can launch a command shell with the environment all setup to run the various commands for GDAL, OGR, PROJ, MapServer, etc.
I've attached a zip file that contains a set of MapInfo files that represents the boundary of Lincolnshire in the UK (where I live) so that those of you who want to try the example below can do so.
In the C:\Program Files\FWTools directory create a new folder named 'Mapinfo2Shp' and unzip the attached file there; you should find four files with extensions .DAT, .ID, .MAP and .TAB
Now double-click the FWTools shortcut on your desktop. This opens a command window. Copy and paste the following command into the window and press the enter key to run it.
ogr2ogr -f "ESRI Shapefile" Mapinfo2Shp\LincsBoundary.shp Mapinfo2Shp\Lincolnshire.tab
NOTE: In the command above the first file is the file format and filename you want to convert to, while the second is the one you're converting from.
You should now see the ESRI shape fileset appear in the folder so run MapWindow and load the LincsBoundary.shp file.
Also, if you want to change the projection at the same time then this is the command:
ogr2ogr -f "ESRI Shapefile" -t_srs "EPSG: 4269" Mapinfo2Shp\LincsBoundary.shp Mapinfo2Shp\Lincolnshire.tab (although I've not tried this).