I'm trying to plot polygons on an OpenLayers map of Scotland which represent the area covered by UK Ordnance Survey maps. These polygons should cover the whole of Scotland and have no gaps between them. However when the polygons (with yellow edges) appear on the map they appear to be misaligned with slight gaps between some of them. The polygons should overlap in places (some locations appear on two maps) but there should be no gaps.

misaligned polygons

I've checked the co-ordinates (in both their original OS X & Y co-ordinate form and their converted latitudes and longitudes, done using PHPcoord http://www.jstott.me.uk/phpcoord/) and they seem to be accurate and fine. Which makes me think it might be a projection issue, but I can't figure out what I'm doing wrong or how to change it.

I wasn't able to create a JSFiddle using my actual GeoJson file so the JSFiddle below shows my map code but with the GeoJson file missing.


I've validated the GeoJson file and it seems to be ok.

  • Without the geojson file we can not really help you. It is the key to identify your problem. Why dont you upload it somewhere? Or add just a part of it as a string variable within your fiddle. – pavlos Jun 23 '17 at 7:36
  • Thanks @pavlos. Here are the contents of the GeoJson file saved in a fiddle: jsfiddle.net/MrAndySweet/2o8v1x1L – MrAndySweet Jun 24 '17 at 8:09
  • The gaps come from coordinates. Here is a fiddle -->jsfiddle.net/p_tsagkis/proggazz click on any polygon to see its coordinates on an info box above map. If you check the original coords you should see that there is a gap. So better check your coords again. – pavlos Jun 26 '17 at 7:55
  • Thanks @pavlos. It seems you're right, I used an online coordinate converter and thought they were accurate but they're not perfect. I tried another converter and they were also slightly out. I have now gone back to my original data which is in the Ordnance Survey X and Y format (OSGB 36) as I know that is accurate. However now I do actually seem to have a projection issue and can't figure out how to fix it. The polygons are now aligned as they should be but placed over West Africa instead of Scotland. Here's a fiddle of the new map: jsfiddle.net/MrAndySweet/47c1vr1v – MrAndySweet Jun 27 '17 at 11:28
  • Do you know the projection code of your data???? – pavlos Jun 27 '17 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.