HI
I tried to implement a simple GPS tracker. Therefore is used
lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, this);
Then i used the
public void onLocationChanged(Location location) {
method to read the altitude of my current location.
But i dont really know what Location.getAltitude() returns. The document says it returns the altitude. But is this in meters? or feets? if i put the phone on the desk next to me, this value changes between 500 and -500??
How does this really work???
The altitude value you get is in meters from the gps (WGS84) reference ellipsoid and not from the geoid.
From my own experience the GPS are really bad at altitude values.
I read this on the GPS Status FAQ:
GPS does not report the height above the mean sea level, rather the GPS system compares the height to the WGS84 reference ellipsoid which may be above or below the actual sea level. In different parts of the earth it can be off by more than 200 meters (depending on the mass distribution of Earth). For example the geoid's surface around Florida is above the mean sea level by a good 30-40 meters, which means that standing on the shore would show you -30m as altitude. This is normal, and not an error, and caused by the fact that the altitude is relative to an artificial reference surface and not to the sea level. If you are interested in this topic, I recommend to read Mean Sea Level, GPS, and the Geoid.
old post, i rekon, but someone might still be interested. while listening to GPS, you can parse NMEA GPGGA sentence (http://aprs.gids.nl/nmea/#gga), in which there is the geoid height (Height of geoid above WGS84 ellipsoid). just subtract this heigh from the getAltitude returned value, one and you'll have a more accurate elevation value.
Edit after several months of usage and feedback received from users of my app
A better solution is to get directly the elevation value in the GPGGA sentence:
double GGA_ALTITUDE = 0d;
private static final String NMEA_GGA = "$GPGGA";
private static final int altitude_element_id = 9;
@Override
public void onNmeaReceived(long timestamp, String nmea) {
foundSats = true;
// check that this is an RMC string
if (nmea.startsWith(NMEA_GGA)) {
String[] tokens = nmea.split(",");
try {
// get orthometric elevation
String elevation = tokens[altitude_element_id];
if (!elevation.equals("")) {
Log.d("NMEA", "ortho elev: " + ortho);
GGA_ALTITUDE = Double.parseDouble(elevation);
}
} catch (Exception ex) {
Log.e("NMEA", "onNmeaReceived: "
+ ex.getMessage());
onNmeaException(ex.getMessage());
ex.printStackTrace();
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With