0

I am creating a sample application for a client using mapbox and I need to huge dataset of locations that span accross the whole world in lt lng format.

E.g.

var addressPoints = [
[-37.8210922667, 175.2209316333, "2"],
[-37.8210819833, 175.2213903167, "3"],
[-37.8210881833, 175.2215004833, "3A"],
];

I was thinking of a list of hotels around the world or something? Or an extremely cleaver way of creating locations on the fly in Javascript that do not end up in the sea?

Any help would be great appreciated!

Thanks.

dallardtech
  • 185
  • 1
  • 2
  • 7

1 Answers1

0

This is a fun question - I don't know of a huge data set but some ideas I had for generating one are:

Strava API

If you have a free API key, you can query Strava's segments end point and give it a lat/lng boundary, so you will get start and end points within those bounds (but limited to 10 results so you'd have to loop to get enough data and may exceed your API call limit, however if you just create it once it might not be so bad). You could also get a lot of points from a specific bike ride/run, but they'd all be close together which I don't think you want.

http://strava.github.io/api/v3/segments/#explore e.g.

Throttling

The default rate limit allows 600 requests every 15 minutes, with up to 30,000 requests per day.

API call

curl -G https://www.strava.com/api/v3/segments/explore \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -d bounds=37.821362,-122.505373,37.842038,-122.465977 \

Response

{
  "segments": [
    {
      "id": 229781,
      "name": "Hawk Hill",
      "climb_category": 1,
      "climb_category_desc": "4",
      "avg_grade": 5.7,
      "start_latlng": [
        37.8331119,
        -122.4834356
      ],
      "end_latlng": [
        37.8280722,
        -122.4981393
      ],
      "elev_difference": 152.8,
      "distance": 2684.8,
      "points": "}g|eFnm@n@Op@VJr@"
    },
    {
      "id": 632535,
      "name": "Hawk Hill Upper Conzelman to Summit",
      "climb_category": 0,
      "climb_category_desc": "NC",
      "avg_grade": 8.10913,
      "start_latlng": [
        37.8334451,
        -122.4941994
      ],
      "end_latlng": [
        37.8281297,
        -122.4980005
      ],
      "elev_difference": 67.29200000000003,
      "distance": 829.834,
      "points": "_j|eFvc@p@SbAu@h@Qn@?RTDH"
    }
  ]
}

Google Geocoding API

This API will accept an address and give you a lat/lng (and more) but is throttled. You'd just need a list of addresses which would be pretty easy to get.

API https://developers.google.com/maps/documentation/geocoding/

Throttling

Users of the free API: 2,500 requests per 24 hour period. 5 requests per second.

API call

https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA

Response

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "1600",
               "short_name" : "1600",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Amphitheatre Pkwy",
               "short_name" : "Amphitheatre Pkwy",
               "types" : [ "route" ]
            },
            {
               "long_name" : "Mountain View",
               "short_name" : "Mountain View",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santa Clara",
               "short_name" : "Santa Clara",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "California",
               "short_name" : "CA",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            },
            {
               "long_name" : "94043",
               "short_name" : "94043",
               "types" : [ "postal_code" ]
            }
         ],
         "formatted_address" : "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
         "geometry" : {
            "location" : {
               "lat" : 37.42291810,
               "lng" : -122.08542120
            },
            "location_type" : "ROOFTOP",
            "viewport" : {
               "northeast" : {
                  "lat" : 37.42426708029149,
                  "lng" : -122.0840722197085
               },
               "southwest" : {
                  "lat" : 37.42156911970850,
                  "lng" : -122.0867701802915
               }
            }
         },
         "types" : [ "street_address" ]
      }
   ],
   "status" : "OK"
}
pherris
  • 17,195
  • 8
  • 42
  • 58