Problem: Disparity in distance values (they vary with latitude)

Hi

Firstly, I am new to using Mapwingis.ocx, so I apologise if I have overlooked something simple to resolve the problem outlined below. I have created a GIS application using Visual Basic (in Visual Studio 2010) – so far so good; all is functioning well. However, there is one problem I have not been able to resolve, so I am looking for some help to find a solution.

The problem relates to the distance values that are generated for polygons when interacting with the map. I am getting a disparity in distance values with latitude. For example, if I programmatically create a 1 hectare polygon (100m x 100m) at the equator, it is created fine; but if I create it at 51.7 degrees latitude (in the UK), the polygon created is 62m x 62m. A similar disparity in the distance occurs if I create a buffer around a shape (setting 100m buffer results in a 62m buffer on the map). Hence, I would like to know if there is something that I have overlooked that is causing this problem. I have tried changing the projection, geoprojection, mapunits, changing the tile provider (or having no tiles), and/or using the Utils ConvertDistance function, but none have worked; and I am struggling to find any further potential solutions online.

The settings I have in the application are:

  • AxMap1.Projection = MapWinGIS.tkMapProjection.PROJECTION_GOOGLE_MERCATOR
  • AxMap1.GeoProjection.SetGoogleMercator()
  • AxMap1.TileProvider = MapWinGIS.tkTileProvider.BingMaps
  • AxMap1…MapUnits = tkUnitsOfMeasure.umMeters

Any help to point me in the right direction would be much appreciated. Happy to provide any further information to help resolve this.

Thanks

John

Hello @JohnTz , and welcome.

Could you post the code you are using to create the polygon? That might help to see what’s happening.

Regards,
Jerry.

Hi Jerry

Thanks for the quick reply.

The steps/code for generating the polygon are (in summary):

Step 1. Set the map:

AxMap1.Projection = MapWinGIS.tkMapProjection.PROJECTION_GOOGLE_MERCATOR

AxMap1.GeoProjection.SetGoogleMercator()

AxMap1.TileProvider = MapWinGIS.tkTileProvider.BingMaps

AxMap1…MapUnits = tkUnitsOfMeasure.umMeters

Step 2: Create and save the shapefile:

sfile = save_shp_dialog(1, “”) 'gets the filename to save the shapefile

Dim sf As New MapWinGIS.Shapefile()

sf.Projection = “+proj=merc +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”

sf.CreateNewWithShapeID(sfile, MapWinGIS.ShpfileType.SHP_POLYGON)

sf.Save()

ih = AxMap1.NumLayers - 1

hndl = AxMap1.get_LayerHandle(ih)

current_layer = hndl 'Note: current_layer is the public variable that stores the layer currently selected.

Step 3: Create 100m x 100m square polygon:

'Note x and y derived from AxMap mousedown event (AxMap1.PixelToProj(e.x, e.y, x, y) which are then sent to the following routine:

Dim sf As Shapefile = AxMap1.get_Shapefile(current_layer)

Dim shp = New Shape

sf.StartEditingShapes(True)

ext = AxMap1.MaxExtents

xStep = 100

yStep = 100

shp.Create(ShpfileType.SHP_POLYGON)

shp.AddPoint(x, y)

shp.AddPoint(x + xStep, y)

shp.AddPoint(x + xStep, y - yStep)

shp.AddPoint(x, y - yStep)

shp.AddPoint(x, y)

shapeIndex = sf.EditAddShape(shp)

AxMap1.Redraw()

As described previously, this results in a square polygon ok, but the size varies with latitude, e.g. 62m at 51.7 degrees latitude; 100m at the equator.

If you think there is an issue in my code, then do please flag it up. My suspicion is that this is a projection issue; I came across the following articles over the weekend:

I have not been able to find a solution either in terms of a different projection or a mathematical conversion; albeit limitations in my GIS skills and knowledge of projections may also be contributing.

Any help or advice would be much appreciated. Please let me know if you need any further details.

Kind regards

John