# issues with projection Rgdal versus Manifold [closed]

I am pretty new to the topic and OK with R, but spatial data is still terra incognita

I got a Mapinfo file and i had to convert it to ESRI shp and then within r into spatial lines data frame and use with leaflet+OS maps epsg:3857

whatever i tried within R with spTransform (rgdal) it did not work - either was not visible or was visible with offset (approx 20 meters). Proj4 did not want to work with SLDF. I took the file into Manifold, converted it to 3857, returned to R, transformed it to epsg:4269 and it works perfectly OK with leaflet + OS map 3857. But i have to automate this process to work within R, without any Manifold intervention.

I checked how the files differed: i selected one item (the same of course) from the file and to make it easy to present created a centroid for it. Then I checked projection, xy, and latlong.

the item created from the file without using Manifold: proj4string

"+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +units=m +no_defs"


centroid:

528685 181836.2


centroid after spTransform to 4269

-0.1450149 51.52028


the item from the file pre-processed by Manifold: proj4string

"+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +no_defs"


centroid:

-16321.64 6713938


centroid after spTransform to 4269:

-0.1466198 51.52079


the latter is correct of course. Just to emphasize - it is the same file and the same item

Few questions:

1. any idea what happens in Manifold that fails in rgdal?

2. is there any mechanism in R that I can apply to fix the error (to match the 'with Manifold' output)? Maybe a kind of offset or work on prj files?

I tried to use the latter CRS for transformation

P5 <-spTransform(ptp.points1P, CRS( "+proj=merc +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +units=m +no_defs"))


and it returned still incorrect values the xy is t least inverted but shifted

 -16142.98 6713847


the latlong is of course incorrect, but the same as without any attempt to transform

-0.1450149 51.52028


content of prj file not transformed - failing to correctly show

PROJCS["Transverse_Mercator",GEOGCS["GCS_Airy 1830",DATUM["D_unknown",SPHEROID["airy",6377563.396,299.3249646]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",49],PARAMETER["central_meridian",-2],PARAMETER["scale_factor",0.9996012717],PARAMETER["false_easting",400000],PARAMETER["false_northing",-100000],UNIT["Meter",1]]


content of prj manifold transformed file - good to go

PROJCS["Mercator_2SP",GEOGCS["GCS_unnamed ellipse",DATUM["D_unknown",SPHEROID["Unknown",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Mercator"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]


## closed as too broad by PolyGeo♦May 22 '17 at 21:47

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Note: you should not be converting to 4269, but 4326. 4269 is NAD83--used in North America. 4326 is WGS 84. – mkennedy May 22 '17 at 19:39
• As per the Tour there should be only one question asked per question. – PolyGeo May 22 '17 at 21:44
• there was just one question, the other statement was a pre-requisite to answer THE question - "how can i replicate the transformation Manifold did without manifold". The answer is below - by substituting the proj4 content. I truly do not see what broad is about it. Mkennedy - probably it was another Manifold pitfall that was rectified by removing the proj4. But believe me, the NA transformation worked for London data;) – Slav May 24 '17 at 14:49

seems I found the answer with the file not processed i swapped the proj4str to bng (without transformation, just a swap)

bng = '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs'


and then the file worked like the Manifold I have no idea how the manifold swapped the strings in the first place, but at least I know how to automate it