5

I am looking for a large sample dataset (preferably in csv format) that has lat/lng coordinates.

PostgreSQL,PostGIS

Cœur
  • 37,241
  • 25
  • 195
  • 267
Eeyore
  • 2,126
  • 7
  • 33
  • 49
  • 3
    Why don't you generate them randomly. You know the maximum and the minimum value that lat/long can assume. Create a script to generate as many samples as you need. – vfn Feb 17 '11 at 23:15
  • This question would be on-topic at http://opendata.stackexchange.com/ – Nicolas Raoul Jul 24 '15 at 11:40

4 Answers4

6

One liner will generate the data in sql:

test=# select POINT(random()*180-90, random()*90-45)from generate_series(1,5);
                point                 
--------------------------------------
 (79.7833853960037,27.2689918940887)
 (27.6489242445678,-9.43540174048394)
 (-51.9591500423849,19.2025181371719)
 (83.5859301500022,31.8948447704315)
 (-56.1149036698043,42.5037826504558)
(5 rows)

You could easily add this query to an insert statement and add the right Postgis function for the geometry if necessary. Last number '5' of course controls how many lines will be generated.

nate c
  • 8,802
  • 2
  • 27
  • 28
2

Following my comment, you can use this html page to generate as many points as you want.

<!DOCTYPE html>
<html lang="en-au">
<head>
    <meta charset="utf-8">
    <meta http-equiv="pragma" content="no-cache" />
</head>
<body>
<script type="text/javascript">
function generatePoints(){
    var pointsToGenerate = document.getElementById('pointsToGenerate').value;

    var output = '';

    for (i=0;i<pointsToGenerate;i++) {
        var multiplier = 10000;
        var latitude=(Math.random()*(90*multiplier))/multiplier;
        var longitude=(Math.random()*(180*multiplier))/multiplier;
        latitude *=(Math.floor(Math.random()*2) == 1)?1:-1;
        longitude *=(Math.floor(Math.random()*2) == 1)?1:-1;
        output = output + latitude + ',' + longitude + '\n';
    }

    document.getElementById('output').innerHTML = output;
}
</script>
<input type="text" id="pointsToGenerate" value="1000" />
<input type="button" onclick="generatePoints()" value="Generate Points" />
<div><textarea cols=40 rows=10 id="output"></textarea></div>
</body>
</html>
vfn
  • 6,026
  • 2
  • 34
  • 45
2

Simulations of database activity based on random data tend not to be realistic, so be wary of any load or query testing you do with it. If you actually want examples of real coordinates, the data sets available from OpenStreetMap are certainly big. Importing the TIGER/Line Shapefiles is one of the best single sets of sample data like this around, and is probably easier to deal with than the ones that have been converted to OSM formats.

Greg Smith
  • 16,965
  • 1
  • 34
  • 27
0

This CSV file has 228500 lat/long couples representing real-life points of interest (tourism attractions/etc) in all countries:

http://datahub.io/dataset/wikivoyage-listings-as-csv

License is CC-BY-SA.

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373