Question

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

PostgreSQL,PostGIS

Was it helpful?

Solution

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>

OTHER TIPS

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top