8/30/2010

Elevation, ocean names, country code

New custom geoservices



https://spreadsheets.google.com/ccc?key=0AppCRCbx33I9dGRiSFpxNkhHckxKbWNVVEFZUU1zaFE&hl=en

Copy Source | Copy HTML
  1. function astergdem(lat,lng) {
  2. /*
     Elevation - Aster Global Digital Elevation Model
     Parameters : lat,lng; sample are: ca 30m x 30m, between 83N and 65S latitude.
     Result : a single number giving the elevation in meters according to aster gdem,
     ocean areas have been masked as "no data" and have been assigned a value of -9999  
    */
  3.   var url = "http://ws.geonames.org/astergdem?lat="+lat+"&lng="+lng;
  4.   var response = UrlFetchApp.fetch(url);
  5.   var str = response.getContentText();
  6.   return str;
  7. }
  8.  
  9. function srtm3(lat,lng) {
  10. /*
    Elevation - SRTM3
    Shuttle Radar Topography Mission (SRTM) elevation data.
    The dataset covers land areas
    between 60 degrees north and 56 degrees south.
    This web service is using SRTM3 data with data points located
    every 3-arc-second (approximately 90 meters) on a latitude/longitude grid.
    Parameters : lat,lng;
    sample area: ca 90m x 90m
    Result : a single number giving the elevation in meters according to srtm3,
    ocean areas have been masked as "no data" and have been assigned a value of -32768 
    */
  11.   var url = "http://ws.geonames.org/srtm3?lat="+lat+"&lng="+lng;
  12.   var response = UrlFetchApp.fetch(url);
  13.   var str = response.getContentText();
  14.   return str;
  15. }
  16.  
  17. function gtopo30(lat,lng) {
  18. /*
    Elevation - GTOPO30
    GTOPO30 is a global digital elevation model (DEM)
    with a horizontal grid spacing of 30 arc seconds (approximately 1 kilometer).
    Result : a single number giving the elevation in meters according to gtopo30
    */
  19.   var url = "http://ws.geonames.org/gtopo30?lat="+lat+"&lng="+lng;
  20.   var response = UrlFetchApp.fetch(url);
  21.   var str = response.getContentText();
  22.   return str;
  23. }​


Copy Source | Copy HTML
  1. function ocean(lat,lng) {
  2. /*
     returns the ocean or sea for the given latitude/longitude
    */
  3.   var url = "http://ws.geonames.org/oceanJSON?lat="+lat+"&lng="+lng;
  4.   var response = UrlFetchApp.fetch(url);
  5.   var str = eval('(' + response.getContentText() + ')').ocean.name;
  6.   return str;
  7. }
  8.  
  9. function countryCode(lat,lng) {
  10. /*
     returns the iso country code of any given latitude/longitude
    */
  11.   var url = "http://ws.geonames.org/countryCode?lat="+lat+"&lng="+lng;
  12.   var response = UrlFetchApp.fetch(url);
  13.   var str = response.getContentText();
  14.   return str;
  15. }
  16.  

8/24/2010

Latitude/longitude spherical geodesy formulae & scripts spreadsheets interface

Latitude/longitude spherical geodesy formulae & scripts spreadsheets interface


Open spreadsheets https://spreadsheets.google.com/ccc?key=0AppCRCbx33I9dG5Wem1jTjMtbl9wTXpNUUUzOFl6TkE&hl=en

Credits and implementation code
http://www.movable-type.co.uk/scripts/latlong.html

Script interface

Copy Source | Copy HTML
  1. /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
  2. /*  Latitude/longitude spherical geodesy formulae & scripts spreadsheets interface                */
  3. /*  Credits - www.movable-type.co.uk/scripts/latlong.html                                         */
  4.  
  5.  
  6. function GCDist(lat1, lon1, lat2, lon2) {
  7. // Return Great Circle Distance between points calculation
  8.    var p1 = new LatLon(lat1, lon1);
  9.    var p2 = new LatLon(lat2, lon2);
  10.    var dist = p1.distanceTo(p2); // in km
  11.   return dist;
  12. }
  13.  
  14. function Bearing(lat1, lon1, lat2, lon2) {
  15. // Return Bearing between points calculation
  16.    var p1 = new LatLon(lat1, lon1);
  17.    var p2 = new LatLon(lat2, lon2);
  18.    var brng = p1.bearingTo(p2); // in degrees clockwise from north
  19.   return brng;
  20. }
  21.  
  22. function Midpointlat(lat1, lon1, lat2, lon2) {
  23. // Returns the midpoint latitude between this point and the supplied point.
  24.    var p1 = new LatLon(lat1, lon1);
  25.    var p2 = new LatLon(lat2, lon2);
  26.    var midp = p1.midpointTo(p2); // in deg
  27.   return midp._lat;
  28. }
  29.  
  30. function Midpointlon(lat1, lon1, lat2, lon2) {
  31. // Returns the midpoint longitude between this point and the supplied point.
  32.    var p1 = new LatLon(lat1, lon1);
  33.    var p2 = new LatLon(lat2, lon2);
  34.    var midp = p1.midpointTo(p2); // in deg
  35.   return midp._lon;
  36. }
  37.  
  38. function Destpointlat(lat1, lon1, bearing, distance) {
  39. // Returns the destination point latitude from this point having travelled the given distance (in km) on the 
  40. // given initial bearing (bearing may vary before destination is reached)
  41.    var p1 = new LatLon(lat1, lon1);
  42.    var midp = p1.destinationPoint(bearing, distance); // in degrees clockwise from north
  43.   return midp._lat;
  44. }
  45.  
  46. function Destpointlon(lat1, lon1, bearing, distance) {
  47. // Returns the destination point longitude from this point having travelled the given distance (in km) on the 
  48. // given initial bearing (bearing may vary before destination is reached)
  49.    var p1 = new LatLon(lat1, lon1);
  50.    var midp = p1.destinationPoint(bearing, distance); // in degrees clockwise from north
  51.   return midp._lon;
  52. }
  53.