Pergunta

I am trying to add functionality to a Silverlight ArcGIS application that allows shapefiles to be uploaded and displayed on the map. Whenever I upload a shapefile, it displays it correctly but in the wrong place, such as a shape that should be in Texas being drawn in the Sahara.

I'm pretty sure the problem is that our map uses a different coordinate system than each shapefile, but I haven't been able to find any resources that can successfully convert the shapefile coordinates. WebMercator.FromGeographic works for some of the shapefiles, but causes the application to crash for others.

I've tried using a GeometryService and have tried altering the SpatialReferences for the shapes, but neither had any noticeable effect.

The PRJ for the file that didn't work with FromGeographic looks like this:

PROJCS["Basic Albers WGS84",GEOGCS["D_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-96.0],PARAMETER["Standard_Parallel_1",45.5],PARAMETER["Standard_Parallel_2",29.5],PARAMETER["Latitude_Of_Origin",23.0],UNIT["Foot_US",0.3048006096012192]]

Where can I start looking to figure this out?

EDIT:

Here is the code for how the Polygon Graphic is created:

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;

The GeometryService is used like this:

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);
Foi útil?

Solução

This may not be a complete answer, but there's too much info for a comment.

Your source SR, 3174, is incorrect. The WKT of that SR is significantly different from the .PRJ file you posted:

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]]

...where the worst problem is that your .PRJ file has UNIT["Foot_US",0.3048006096012192], while 3174 has UNIT["metre",1]! This is probably why things are appearing in the Sahara. :)

I think your best bet is to use this constructor of the SpatialReference class, and feed it the WKT you posted from the PRJ file.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top