2

I am a Java Developer and I was given this coordinates from a database

verbat_sistema_coordenadas  verbatim_SRS    datum   verbat_longitud verbat_latitud
UTM                         WGS84           WGS84   9947921          815887

And I tried the examples here https://stackoverflow.com/questions/7661/java-code-for-wgs84-to-google-map-position-and-back, but I get something like this when I try to use the MercatorTransform showed there

LatVerb           LonVerb               LatEPSG                        LonEPSG
815612.0         9948458.0           7.3267672551129115        66.40190209729147

I tried the formulas shown there and I get differnt result with each formula and none are close to what I need. Then someone I am working with gave me an excel sheet with some formulas but the have a million variables and constants

Fi' Ni  a   A1  A2  J2  J4  J6  Alfa    Beta    Gamma   B(fi)   b   Zeta    Xi  Eta Sen h Xi    Delta Lambda    Tau

And they depend on the Timezone(meridian, maybe I am translating this wrong?), and the hemisphere, and they seem to work. They gave me -0.4544682953,-78.1736736245, which is the correct answer.

This is the excel sheet http://www.gabrielortiz.com/descargas/descarga.asp?Fichero=Conversion_UTM_Geograficas.xls

I tried using geotools, but it was way off too http://osgeo-org.1560.x6.nabble.com/convert-wgs84-coordinate-to-Google-Map-coordinate-system-EPSG-3785-with-geotools-and-java-td4983362.html

2
  • 1
    What is your question?
    – whuber
    Commented Jun 6, 2013 at 4:23
  • Sorry, I am looking for a formula to transform from WGS84 to EPSG 3785, but none of them give me the same results, what is the correct way to do this.
    – Juan Diego
    Commented Jun 6, 2013 at 5:07

3 Answers 3

2

UTM has nothing to do with EPSG 3785 and Google maps, apart from the WGS84 ellipsoid and datum. And WGS84 in degrees is yet another coordinate system.

If your desired point of the earth has negative lat/lon in degrees, the Google mercator coordinates are negative as well.

If you have UTM coordinates, they are always positive, but you need the UTM zone they are laying in. For the southern hemisphere, positive y counts from the south pole, for the northern hemisphere from the equator.

You can find formulas for UTM here: http://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system

Your zone might be UTM 30S.

2

You can use Geotools

 //create reference system WGS84 Web Mercator
 CoordinateReferenceSystem wgs84Web = CRS.decode("EPSG:3857", true);
 //create reference system WGS84
 CoordinateReferenceSystem wgs84 = CRS.decode("EPSG:4326", true);

 //Create transformation from WS84 Web Mercator to WGS84
 MathTransform wgs84WebToWgs84 = CRS.findMathTransform(wgs84Web, wgs84);

 GeometryFactory jtsGf = JTSFactoryFinder.getGeometryFactory();

 //create a point
 Geometry pointInWgs84Web = jtsGf.createPoint(new Coordinate(-3.678393944400995, 40.43664108222252);
//transform point from WGS84 Web Mercator to WGS84 
Geometry pointInWgs84 = JTS.transform(pointInWgs84Web, wgs84WebToWgs84);
1

Based on the latitude-longitude values you gave as correct (-0.4544682953,-78.1736736245), that the input coordinate values are labeled misleadingly.

 verbat_longitud verbat_latitud
   9947921          815887

The first number is the northing value and the 2nd one is the easting. Also based on the latitude-longitude values, the zone should be 17 South (data is in/near Quito).

So you have two conversions to do: UTM to latitude,longitude and latitude,longitude to EPSG:3857 (EPSG:3785 has been deprecated and replaced with 3857). UTM is based on tranverse Mercator and knowing the UTM zone allows you to figure out the parameter values. To convert to EPSG:3857, you will need the sphere-based equations for Mercator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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