This project has moved and is read-only. For the latest updates, please go here.

Layer misalignment

Topics: SharpMap v0.9 / v1.x, WinForms Controls
Dec 13, 2015 at 3:01 AM

I got some trouble aligning two layers, got one tilelayer and a shapefile backed layer.
The tilelayer's tiles are created using 'gdal2tiles' on NASA BlueMarble image.

The shapefile:
The base image for tiles:
The command I used in gdal2tiles:
gdal2tiles -p geodetic -s EPSG:4326 -z 0-4 world.topo.200407.3x21600x10800.jpg
(I renamed the resulting folder to 'world.topo.200407')

Now my problem is that both layers are misaligned: LINK

My sourcecode: (I added four points as reference)
Dim vlay As New SharpMap.Layers.VectorLayer("Test")
vlay.DataSource = New SharpMap.Data.Providers.ShapeFile("SHF\continent.shp", True)
vlay.Style.Fill = Brushes.Transparent
vlay.Style.Outline = Pens.Yellow
vlay.Style.EnableOutline = True

Dim schema As New TileSchema
schema.Resolutions.Add(New Resolution() With {.Id = "0", .UnitsPerPixel = 0.703125})
schema.Resolutions.Add(New Resolution() With {.Id = "1", .UnitsPerPixel = 0.3515625})
schema.Resolutions.Add(New Resolution() With {.Id = "2", .UnitsPerPixel = 0.17578125})
schema.Resolutions.Add(New Resolution() With {.Id = "3", .UnitsPerPixel = 0.087890625})
schema.Resolutions.Add(New Resolution() With {.Id = "4", .UnitsPerPixel = 0.0439453125})
schema.Srs = "EPSG:4326"
schema.Extent = New Extent(-180, -90, 180, 90)
schema.Height = 256
schema.Width = 256
schema.Format = "png"
schema.OriginX = -180
schema.OriginY = -90

Dim ts As New TileSource(New FileTileProvider(New FileCache("world.topo.bathy.200407", "png")), schema)
Dim tl As New TileLayer(ts, "BM")

Dim geos As New List(Of IGeometry)
Dim gf As New GeometryFactory()
geos.Add(gf.CreatePoint(New Coordinate(-160, -70)))
geos.Add(gf.CreatePoint(New Coordinate(160, 70)))
geos.Add(gf.CreatePoint(New Coordinate(-160, 70)))
geos.Add(gf.CreatePoint(New Coordinate(160, -70)))

Dim gemlay As New VectorLayer("GL")
gemlay.DataSource = New Providers.GeometryProvider(geos)


MB1.ActiveTool = SharpMap.Forms.MapBox.Tools.Pan
Any Ideas?

Greetings, Xeoniz
Dec 15, 2015 at 8:02 AM
I followed the steps you are outlining and took a look at the output of gdal2tiles.
To me it seems that your extent is not correct. shouldn't it be schema.Extent = new Extent(-180, -90, 270, 180);

Where do the values for UnitsPerPixesl come from?