On samedi 27 avril 2019 17:09:51 CEST Paul Meems wrote:
> I'm not sure if this is the correct list, it might be I need to ask this on
> the proj4-list.
> Because I'm not a member of that list, I try here first.
> Can GDAL/OGR/Proj4 convert lat/long coordinates to Ordnance Survey grid
> I've been searching for an answer and found only this page:
> https://digimap.edina.ac.uk/webhelp/digimapgis/projections_and_transformatio > ns/transformations_in_gdalogr.htm suggesting
> it is possible with GDAL after some changes.
> But I can't find an example of how to convert '-2.02903211116781,
> 53.4040442788744' to 'SJ981896'.
First, in which CRS are those coordinates: in OSGB36 (EPSG:4277) or WGS84 (EPSG:4326) ?
Anyway given that the grid coordinates have 6 figures, thus 3 figures
for easting and northing, SJ981896 has only 100 meter precision (the page you
reference is just about using more accurate datum shift parameters, but this is
only if you are interested in ~1 meter precision, not 100 meter precision)
Let's assume they are already in OSGB36, and transform them to the
"OSGB 1936 / British National Grid" projected CRS (EPSG:27700):
So let drop the sub-meter precision and isolate the figures that are multiple of 100km in those coordinates:
3 98070, 3 89720
and drop the last 2 figures and round appropriately, to get only 4 digits
3 981, 3 897
So GDAL & PROJ handle the transformation from geographic to projected coordinates.
The formatting of the projected coordinates to the national grid reference
is left as an exercice to users :-)
(I'd be surprised if there is no code in the wild that would do the whole conversion)