我正在尝试为Silverlight ArcGIS应用程序添加功能,该应用程序允许上传形状文件并在地图上显示。每当我上传一个形状文件时,它都会正确显示,但位置不对,比如一个本应在得克萨斯州绘制的形状正在撒哈拉沙漠中绘制。
我很确定问题是,我们的地图使用的坐标系与每个shapefile不同,但我还没有找到任何可以成功转换shapefile坐标的资源。WebMercator.FromGeographic适用于某些形状文件,但会导致其他文件的应用程序崩溃。
我尝试过使用GeometryService,也尝试过更改形状的空间引用,但都没有任何明显的效果。
无法使用FromGeographic的文件的PRJ如下所示:
PROJCS["Basic Albers WGS84",GEOGCS["D_WGS_1984",DATUM["D_WG.S_1984"、SPHEROID["WGS_1984",6378137.0298.257223563]、PRIMM["Greenwich",0.0]、UNIT["Degree",0.0174532925199433]]、PROJECTION["Albers"]、PARAMETER["False_Easting",0.0】、PARAMETER["Farse_Northing",0.0]PARAMETER]、Central_Meridian",-96.0]、PARMATER["Standard_Parallel_1",45.5]、PARAMETER["Standard_Parallel_2",29.5],PARAMETER["Latitude_Of_Origin",23.0],UNIT["Foot_US",0.30480006096012192]]
我从哪里开始寻找答案?
编辑:
以下是创建多边形图形的代码:
ESRI.ArcGIS.Client.Geometry.Polygon geo = new ESRI.ArcGIS.Client.Geometry.Polygon();
ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection> paths = new ObservableCollection<ESRI.ArcGIS.Client.Geometry.PointCollection>();
ESRI.ArcGIS.Client.Geometry.PointCollection pcol = new ESRI.ArcGIS.Client.Geometry.PointCollection();
foreach (System.Windows.Point p in this.points)
{
MapPoint mp = new MapPoint();
mp.X = p.X;
mp.Y = p.Y;
pcol.Add(mp);
}
paths.Add(pcol);
geo.Rings = paths;
// Random WKID to test with.
geo.SpatialReference = new ESRI.ArcGIS.Client.Geometry.SpatialReference(3174);
ESRI.ArcGIS.Client.Graphic gr = new ESRI.ArcGIS.Client.Graphic()
{
Geometry = geo,
Symbol = window.Get(symbolPolygon) as ESRI.ArcGIS.Client.Symbols.Symbol,
};
return gr;
GeometryService的使用方式如下:
GraphicsLayer graphicsLayer = new GraphicsLayer();
foreach (ShapefileRecord r in sh.Records)
{
Graphic g = r.ToGraphic(this);
graphicsLayer.Graphics.Add(g);
}
geoServ.ProjectAsync(graphicsLayer.Graphics.ToList(), new ESRI.ArcGIS.Client.Geometry.SpatialReference(102100));
Map.Layers.Add(graphicsLayer);
这可能不是一个完整的答案,但信息太多,无法发表评论。
您的源SR 3174
不正确。该SR的WKT与您发布的.PRJ文件有很大不同:
PROJCS["NAD83 / Great Lakes Albers",
GEOGCS["NAD83",
DATUM["North_American_Datum_1983",
SPHEROID["GRS 1980",6378137,298.257222101,
AUTHORITY["EPSG","7019"]],
AUTHORITY["EPSG","6269"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.01745329251994328,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4269"]],
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
PROJECTION["Albers_Conic_Equal_Area"],
PARAMETER["standard_parallel_1",42.122774],
PARAMETER["standard_parallel_2",49.01518],
PARAMETER["latitude_of_center",45.568977],
PARAMETER["longitude_of_center",-84.455955],
PARAMETER["false_easting",1000000],
PARAMETER["false_northing",1000000],
AUTHORITY["EPSG","3174"],
AXIS["X",EAST],
AXIS["Y",NORTH]]
其中最糟糕的问题是你的.PRJ文件有UNIT["Foot_US",0.3048006096012192]
,而3174有UNIT["metre",1]
!这可能就是撒哈拉沙漠出现的原因
我认为您最好使用SpatialReference类的这个构造函数,并将您从PRJ文件发布的WKT提供给它。