Shapefile Projection Problem

Topics: SharpMap Project, WinForms Controls
Sep 23, 2014 at 10:04 PM
I am trying to add a shapefile layer over a Bing aerial in a VB project. The shapefile is from Oklahoma but it is displayed in the Arctic Ocean. When I use the Open Street layer it works just fine. I’m sure I’m not converting the coordinates correctly but I can’t seem to find the error.

This code places the shape layer correctly.
    shpFile = New SharpMap.Data.Providers.ShapeFile("C:\CountyData\Stephens\MapData\PAR_N.shp", True)
    vLayer.DataSource = shpFile

    Dim ctFact As New ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory()
    Dim csFact As New ProjNet.CoordinateSystems.CoordinateSystemFactory()
    vLayer.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(shpFile.CoordinateSystem, GetEPSG900913(csFact))
    vLayer.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(GetEPSG900913(csFact), shpFile.CoordinateSystem)

    Dim OSM = New SharpMap.Layers.TileAsyncLayer(New BruTile.Web.OsmTileSource(), "OSM")

    MapBox1.Map.BackgroundLayer.Add(OSM)
    MapBox1.Map.Layers.Add(vLayer)
    MapBox1.Map.ZoomToBox(vLayer.Envelope)
    MapBox1.Refresh()
    MapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan

This projects the shapelayer north of Alaska in the Arctic Ocean.
    shpFile = New SharpMap.Data.Providers.ShapeFile("C:\CountyData\Stephens\MapData\PAR_N.shp", True)
    vLayer.DataSource = shpFile

    Dim ctFact As New ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory()
    Dim csFact As New ProjNet.CoordinateSystems.CoordinateSystemFactory()
    vLayer.CoordinateTransformation = ctFact.CreateFromCoordinateSystems(shpFile.CoordinateSystem, GetEPSG900913(csFact))
    vLayer.ReverseCoordinateTransformation = ctFact.CreateFromCoordinateSystems(GetEPSG900913(csFact), shpFile.CoordinateSystem)

    tileSource = New BruTile.Web.BingTileSource(BruTile.Web.BingRequest.UrlBing, token, BruTile.Web.BingMapType.Roads)
    tileLayer = New SharpMap.Layers.TileLayer(tileSource, "BingMap")

    MapBox1.Map.BackgroundLayer.Add(tileLayer)
    MapBox1.Map.Layers.Add(vLayer)
    MapBox1.Map.ZoomToBox(vLayer.Envelope)
    MapBox1.Refresh()
    MapBox1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan
Thanks for any help anyone can provide.
Coordinator
Sep 24, 2014 at 12:17 PM
This is not a problem with your projection, rather the BingRequest/-TileSource is faulty.
Will be fixed with SharpMap 1.2
Sep 24, 2014 at 1:17 PM
Thank you for the response, I will watch for the new version.