其实,最终的问题是我的坐标系统不是基于900913的。有两种解决办法。一,将自己的数据转化为900913,可以用ogr或者arcToolbox里 相应的命令行,不再多说了。或者就是通过MapServer on-the-fly去reprojections。但是MapServer,ogr,以及arcGIS进行投影转换需要有预定好的投影,而在proj4 和arcGIS里并没有预定900913。定义方法如下:
1. 在/proj/nad/epsg里添加“# Google Mercator
<900913> +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs <>”
这样你就可以使用ogr,Mapserver实时的进行转换了。
2. 如果你需要用arcGIS来转换,需要在文件ArcGIS\Coordinate Systems\Projected Coordinate Systems\world里添加文件 Google Mercator (world).prj. 我自己写的内容为:
PROJCS[”Google_Mercator”,GEOGCS[”GCS_WGS_1984″,
DATUM[”D_WGS_1984″,SPHEROID[”WGS_1984″,6378137,0]],
PRIMEM[”Greenwich”,0],UNIT[”Degree”,0.017453292519943295]],
PROJECTION[”Mercator”],PARAMETER[”False_Easting”,0],PARAMETER[”False_Northing”,0],
PARAMETER[”Central_Meridian”,0],PARAMETER[”Standard_Parallel_1″,0],UNIT[”Meter”,1]]
PS. EPSG: 900913 为横轴墨卡托投影。它和EPSG:3395非常类似,只是没有扁率298. 257223563。也就是说他不是一个椭球。还有一点需要注意,Google 投影用的是Mercator——2SP该投影在acrGIS以及proj4里均没有定义。所以要做一些转换。
如果您对地图投影,墨卡托投影,特别是WebGIS里面的使用情况有疑惑,请参考如下的文献:
http://www.spatialreference.org/ref/user/google-projection/
http://jira.codehaus.org/browse/GEOT-1511
http://spatialreference.org/ref/user/6/
http://www.ibm.com/developerworks/cn/java/j-coordconvert/#resources
http://www.sharpgis.net/2007/05/05/SpatialReferencesCoordinate
SystemsProjectionsDatumsEllipsoidsConfusing.aspx
code:
在html中:
var lon = 4174203.107;
var lat = 3556972.005;
var zoom = 5;
var options = { maxExtent: new OpenLayers.Bounds(7765266.742441,429318.305045,16113672.956358,7543262.315404),
maxResolution: 16543,
projection: "EPSG:900913",
units: "km",
numZoomLevels: 7};
map = new OpenLayers.Map('map', options);
layer = new OpenLayers.Layer.MapServer( "CHGIS MapServer", "/cgi-bin/mapserv.exe?map=/ms4w/apache/htdocs/buddhist/google.map&layers=PII_google",
{layers: 'basic'},
{opacity:0.5, isBaseLayer:false});
map.addLayer(layer);
satellite = new OpenLayers.Layer.Google( "Google Satellite" , {type: G_SATELLITE_MAP,
'maxZoomLevel':18, 'sphericalMercator': true} );
map.addLayers([satellite]);
在map文件中:
MAP
IMAGETYPE PNG
# EXTENT 72.9958 17.9958 136.0042 54.0042
EXTENT 7765266.742441 429318.305045 16113672.956358 7543262.315404
SIZE 1200 800
SHAPEPATH "data"
IMAGECOLOR 234 255 255
TRANSPARENT ON
FONTSET "fonts/fonts.list"
SYMBOLSET "symbols/symbols.sym"
PROJECTION
# "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"
"init=epsg:900913"
END
#定义图层LAYERS
END
from:http://www.geoinformatics.cn/?p=563