Android Question how to calculate a NAD83(CSRS) to WGS84

yfleury

Active Member
Licensed User
Longtime User
Hi!
I have a database with GPS coordinates in NAD83(CSRS) format.
It's for a google map app
I want to convert it to WGS84 (latitude, longitude)
How to do it, some link
 
Solution
Omar, thank you for the API explanation!

In case you want to calculate it directly, you can use the following snippet. The result matches the API result. Be careful with the MTM zone, check the prj file for the description of the projection.
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    
    Private const MathPIdiv180 As Double = cPI / 180
    Private Const WGS84_a As Double = 6378137
    Private Const WGS84_b As Double = 6356752.3142
    
    Type eGPSLocation(Latitude As Double, Longitude As Double)
    Type eProjCoordinate(Easting As Double, Northing As Double)
    
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub

'This event will be called once, before the page becomes...

drgottjr

Expert
Licensed User
Longtime User
my understanding is that the difference, to all intents and purposes,
is small, certainly at lower zoom levels. so unless you are using the
coordinates to fly an attack drone at zoom level 19, you should be able
to use your canadian database without incident. i understand there has
been a very recent update to the NAD83 CSRS system, so your dataset
may be based on out-of-date coordinates.

i fed a couple NAD83 coordinates into a WGS84-base map, and
the results were decent.

also, i believe it is possible to change the google maps projection scheme,
so that your NAD83 coordinates would not need transformation. you'll have
to look into the API.

in any case, a formula for transforming NAD83 CSRS to WGS84 is not
easy to find. lots of blah, blah, but not much in the way of actual calculations.
i spent some time searching...
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
tools:

this tool uses this JavaScript library

1657864100699.png
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
Thanks for the links
May be the best add to my app is PROJ4JS
But I don't know how to use it in my app like I call a function (from java scrip) with parameters and wait for a result
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
As @drgottjr noted above the differences are very small. As you state you are using it in conjunction with Google Maps I question whether you need that conversion at all as I believe they correspond to within a metre or so and that is probably not a discernible difference on a map.

 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
Precision is very important for that app.
Can I put x,y meter directly to Google map?
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
good luck with that; gps coordinates used for non-military purposes are deliberately fudged. "stand ready, stand down", as someone once said.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
gps coordinates used for non-military purposes are deliberately fudged.
If you mean GPS Selective Availability then not any more. Bill Clinton signed an order to turn it off in 2000 and current GPS satellites no longer have the capability. As I understand it Glonass, Beidou and Galileo are also not degraded for civilian use. Non-compensated ionospheric effects are the main inaccuracy of civilian GPS giving inaccuracies of several to tens of metres, hence the availability of various augmentation systems which can correct to centimetric accuracy - good enough for surveying purposes.

I have some doubt that Google Maps is capable of accurate 1 metre resolution anyway but then we get into the discussion of Web Mercator spherical projections as used by almost all web mapping sources versus True Mercator elliptical projections as used by government and professional mapping agencies.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
I have some doubt that Google Maps is capable of accurate 1 metre resolution anyway but then we get into the discussion of Web Mercator spherical projections as used by almost all web mapping sources versus True Mercator elliptical projections as used by government and professional mapping agencies.

just like we (France Telecom) use the Lambert 2 Extended subset!
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
i'm encouraged by everyone's faith in various governments' word that we are free to locate what we want within millimeters with our phone.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
i'm encouraged by everyone's faith in various governments' word that we are free to locate what we want within millimeters with our phone.
Within milimeters I would say is a really big stretch but, I use GMaps often to pinpoint manholes in our sites, and they are very accurate within 1 to 2 meters
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
Within milimeters I would say is a really big stretch but, I use GMaps often to pinpoint manholes in our sites, and they are very accurate within 1 to 2 meters
I have a lot of manholes locations in nad83 from technicians (within milimeters) in a small town. I want to show it to Google maps app. But I need to convert to wgs84 for Google map.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I have a lot of manholes locations in nad83 from technicians (within milimeters)
I assumed you wanted to convert NAD83 (CSRS) to WGS84 for these types of locations.

I suggest you read this link carefully:


You will see that you will have to obtain other additional information from the grids for greater precision.
 
Last edited:
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
I have a geojson file many lines like this
B4X:
{ "type": "Feature", "properties": { "OBJECTID": 1, "CODE": "C-3924", "LENGTH": 129.942726271, "INSTALLATI": 1990, "SECTEUR": "Mistassini", "OWNER": "Ville", "Shape_Leng": 235.731013, "Matériau": "Fonte ductile", "Diamètre": "200", "Type_de_co": "D", "Hiérarchi": "III", "SECTION": "A-20061", "Troncon": 20061 }, "geometry": { "type": "LineString", "coordinates": [ [ 399871.321219788631424, 5418344.341168709099293 ], [ 399768.00000369240297, 5418367.000000730156898 ], [ 399745.999987671908457, 5418357.000000720843673 ], [ 399661.564147593220696, 5418293.268160661682487 ] ] } },
coordinates": [ [ 399871.321219788631424, 5418344.341168709099293 ], ... are in meter.
I need latitude and longitude to put in google map.
I have a shapefile .shp that come with many file type like .cpg .dbf .prj .sbn .sbx shp.xml .shx theses files come from ArcGis software but I don't have access to the sofware

The place is Dolbeau-Mistassini, Quebec, Canada
 
Upvote 0

roumei

Active Member
Licensed User
You're probably looking at the Modified Transverse Mercator (MTM) projection here to get from the coordinates in meters to WGS84. Your title is a little bit misleading because it indicates that you want to transform between NAD83 and WGS84.

EPSG:2950 NAD83(CSRS) / MTM zone 8 gives a lat/lon in Dolbeau-Mistassini.

You can read more about MTM here: https://cgrsc.ca/resources/coordinate-transformations/projections/
Info on the projection parameters is here: https://epsg.io/2950 (click on transform to calculate lat/lon.)
The necessary formulas should be in here: https://www.iogp.org/wp-content/uploads/2019/09/373-07-02.pdf
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
You're probably looking at the Modified Transverse Mercator (MTM) projection here to get from the coordinates in meters to WGS84. Your title is a little bit misleading because it indicates that you want to transform between NAD83 and WGS84.

EPSG:2950 NAD83(CSRS) / MTM zone 8 gives a lat/lon in Dolbeau-Mistassini.

You can read more about MTM here: https://cgrsc.ca/resources/coordinate-transformations/projections/
Info on the projection parameters is here: https://epsg.io/2950 (click on transform to calculate lat/lon.)
The necessary formulas should be in here: https://www.iogp.org/wp-content/uploads/2019/09/373-07-02.pdf
API:
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
I try many software without succes, they are export always in xy format.
The best solution for now is to send a text file with xy to https://tool-online.com/en/ and I download a text file with lat and long (dd.dddd) and it is very fast.
It's free for one coodinate at time, But I have to paid for text file.

The best, it's a library if exist
 
Last edited:
Upvote 0
Top