{
  "id": 5074,
  "title": "Calc distances between Lon/Lat on a sphere ",
  "url": "/competitions/ams-2014-solar-energy-prediction-contest/discussion/5074",
  "author_name": "",
  "post_date": "2013-07-11T23:37:06.057Z",
  "votes": 4,
  "comment_count": 5,
  "views": 2390,
  "content": "<p>Here is a little C program that calculates distances between two lon/lat pairs on the Earth.</p>\r\n<p>The accuracy is a less than a foot/meter for the distances in the challenge</p>\r\n<p>It is the 'haversine' function (see wikipedia for more)</p>\r\n<p>It may be of use (or not) to you. I used it long ago for a road tracking robot car demo.</p>\r\n<p>(the mean of the mean Earth radius 'magic number' constants are tuned for distances less that 2000 miles apart and low to mid latitudes)</p>\r\n<p>NOTE: The code computes the distances between two randomly picked MESONET stations (CHER and BLAC) from the challenge.</p>\r\n<p>Enjoy</p>\r\n<p>Karle</p>\r\n<p></p>\r\n<p>Edit: added a screen shot of the C program running (in case you dont have C)</p>",
  "messages": [
    {
      "id": "27039",
      "postDate": "07/11/2013 23:37:06",
      "content": "<p>Here is a little C program that calculates distances between two lon/lat pairs on the Earth.</p>\r\n<p>The accuracy is a less than a foot/meter for the distances in the challenge</p>\r\n<p>It is the 'haversine' function (see wikipedia for more)</p>\r\n<p>It may be of use (or not) to you. I used it long ago for a road tracking robot car demo.</p>\r\n<p>(the mean of the mean Earth radius 'magic number' constants are tuned for distances less that 2000 miles apart and low to mid latitudes)</p>\r\n<p>NOTE: The code computes the distances between two randomly picked MESONET stations (CHER and BLAC) from the challenge.</p>\r\n<p>Enjoy</p>\r\n<p>Karle</p>\r\n<p></p>\r\n<p>Edit: added a screen shot of the C program running (in case you dont have C)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27049",
      "postDate": "07/12/2013 05:45:41",
      "content": "<p>Mmh, interesting, but where is the random function in your code?</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27056",
      "postDate": "07/12/2013 12:22:11",
      "content": "<p>Sorry, you pick two randomly... :) :)</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27618",
      "postDate": "07/24/2013 19:57:27",
      "content": "<p>Note that if you are using R the &quot;fields&quot; package has a function called &quot;rdist.earth&quot; that calculates great circle distance given latitude and longitude.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "27638",
      "postDate": "07/25/2013 04:43:04",
      "content": "<p>Also, one can run the C++ progr with &quot;Rcpp&quot;,</p>\n<p>but the code is easy to translate into R.</p>",
      "rawMarkdown": "",
      "votes": null
    },
    {
      "id": "32350",
      "postDate": "10/15/2013 17:51:24",
      "content": "<p>Attached is a MATLAB function that converts lat/lon degrees to meters from a reference lat/lon pair.</p>",
      "rawMarkdown": "",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 27049,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "07/12/2013 05:45:41",
      "content": "<p>Mmh, interesting, but where is the random function in your code?</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27056,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "07/12/2013 12:22:11",
      "content": "<p>Sorry, you pick two randomly... :) :)</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27618,
      "author_name": "dkincaid",
      "author_url": "",
      "post_date": "07/24/2013 19:57:27",
      "content": "<p>Note that if you are using R the &quot;fields&quot; package has a function called &quot;rdist.earth&quot; that calculates great circle distance given latitude and longitude.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 27638,
      "author_name": "herimanitra",
      "author_url": "",
      "post_date": "07/25/2013 04:43:04",
      "content": "<p>Also, one can run the C++ progr with &quot;Rcpp&quot;,</p>\n<p>but the code is easy to translate into R.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 32350,
      "author_name": "jessebikman",
      "author_url": "",
      "post_date": "10/15/2013 17:51:24",
      "content": "<p>Attached is a MATLAB function that converts lat/lon degrees to meters from a reference lat/lon pair.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "27039": "",
    "27049": "",
    "27056": "",
    "27618": "",
    "27638": "",
    "32350": ""
  },
  "source": "meta"
}