I'm having difficulties reading the Gridded height data (OS Meridian 2). I'm loading with OSGB 1936 reference system but have trouble finding the lat/lon data for each point. i.e.I open the attribute table to see three columns FEATURE_SE, FEATURE_CO, and HEIGHT. I know the data loads correctly, as it produces the right shape map but don't know how to query the height at a position as I can't figure out how the Feature_se and feature_co link to lat/lon, or OSGB references. Thanks if more information is needed please ask and I'll try and find it.


First, I would say that the height data is going to be a bit ropey because it's derived from Landform PANORAMA data (a now defunct product), which was derived from contours many years ago, and the values are rounded to the nearest metre with a grid spacing of 200 metres - worse than SRTM. But accuracy might not be critical for you, which is fine.

Secondly, there's no notion of latitude and longitude in Meridian 2 data, its all stored in the OSGB36 projection. To get the long/lat of a point, you'll need to unproject and shift the datum to get to presumably WGS84 long/lat (OSGB36 uses the Airy ellipsoid hence the datum shift, but that's usually handled automatically); this can be done with either a library like proj4, or if you're using PostGIS, the function ST_Transform().

In the manual, it says that height has a feature code of 6762, that'll be the FEATURE_CO field you have in your Shapefile. The FEATURE_SE is just the ID of that point, unique to that file. With shapefiles, geometry isn't stored as an attribute per se, it's the intrinsic data to which attributes are attached. Which is why you'll never be able to extract any sort of coordinate from the three attributes you are given, instead it is handled by whichever GIS/spatial database you've loaded the data into.

So putting this all together, you could use a PostGIS SQL statement something like this:

SELECT ST_AsText(ST_Transform(heights.the_geom, 4326)) as lonlat, height FROM heights
  WHERE ST_ClosestPoint(ST_Transform(ST_GeomFromText('POINT(-0.142 51.501)', 4326), 27700), heights.the_geom)
  AND heights.feature_co = 6762;

Which should return the WKT representation and height of the point nearest to Buckingham Palace. Where 4326 is the SRID of WGS84 coordinate system, and 27700 is the SRID of the OSGB36 projection.

  • Thanks, that's just what I needed. I had read it and so could identify the 100km squares but had no idea how to go about converting coordinate systems as I couldn't identify what I needed to convert. As a side check am i right in thinking that as the geometry isn't an attribute I can safely merge shapefiles using ogr2ogr. – wookie1 Apr 10 '12 at 11:58
  • Yes, merging them with ogr2ogr is fine, just remember that the FEATURE_SE field will no longer be unique, indeed it'll be laregely meaningless. So you could use the -select option to extract just the height value. – MerseyViking Apr 10 '12 at 12:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.