Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:32:22+00:00 2026-05-25T19:32:22+00:00

I need to transform a GPS point from DDD MM.MMM (string) to decimal (two

  • 0

I need to transform a GPS point from DDD MM.MMM (string) to decimal (two values: latitude & longitude) with Java.

For example, I have this String:

String a = "N 39° 28.941 W 0° 23.275"

I need to transform that string into these two values:

double lat= 39.48235
double lon= -0.38792

How can I do it with Java code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:32:23+00:00Added an answer on May 25, 2026 at 7:32 pm

    Parse the string for those six values:

    • N or S to determine the sign of of the latitude (plus or minus)
    • The degrees (39 – the part before the dot)
    • The double value (28.941 – the part after the dot)

    … the same for longitude

    Quick hack to do so:

    public class CoordTest {
    
        private static String  coords = "N 39° 28.941 W 0° 23.275";
    
        public static void main(String[] args) {
            String[] cArray = coords.split(" ");
            String latSign = cArray[0];
            String latDegrees = cArray[1].substring(0, cArray[1].length()-1);
            String latSubdegrees = cArray[2];
            String lonSign = cArray[3];
            String lonDegrees = cArray[4].substring(0, cArray[4].length()-1);
            String lonSubdegrees = cArray[5];
            double lat = getSign(latSign) * (Integer.valueOf(latDegrees) + convertFromDegreesToDecimal(Double.valueOf(latSubdegrees)));
            double lon = getSign(lonSign) * (Integer.valueOf(lonDegrees) + convertFromDegreesToDecimal(Double.valueOf(lonSubdegrees)));
        }
    
    
        private static int getSign(String c){
            if (c.equals("N") || c.equals("E")){
                return 1;
            }
            return -1;
        }
    
        private static double convertFromDegreesToDecimal(Double value){
            double result = value/60d;
            return result;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to accurately visualize points coming from iPhone (and other) GPS data in
I need a function that maps gps positions to x/y values like this: getXYpos(GeoPoint
I have a list of integer ASCII values that I need to transform into
I need to transform some article about information technologies from format XHTML or HTML
I need to transform HTML into XHTML 1.1. I'm doing it in a Java
I have plenty of java domain objects that I need to transform to DTOs.
i need to transform/access memory indices to and from row-major and cartesian* layouts. if
I need to transform a string into a number using some oracle built-in methods
I have a column with values like this: 01709100011 I need to transform it
My code builds an xml output from mysql dataset. Then I need to transform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.