Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Large Sample Database with Latitudes and Longitudes

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

PostgreSQL,PostGIS

like image 243
Eeyore Avatar asked Feb 17 '11 23:02

Eeyore


People also ask

How do you store latitude and longitude in a database?

Latitude & longitude values can be represented & stored in a SQL database using decimal points (Decimal degrees) rather than degrees (or Degrees Minutes Seconds). Depending on the accuracy you may require, you can decide how many decimal points you need to keep latitude & longitude values.

What type of data is latitude and longitude?

Latitude and longitude are a pair of numbers (coordinates) used to describe a position on the plane of a geographic coordinate system. The numbers are in decimal degrees format and range from -90 to 90 for latitude and -180 to 180 for longitude.

Can Tableau generate longitude and latitude?

When you assign a geographic role to a field, Tableau adds two fields to the Measures area of the Data pane: Latitude (generated) and Longitude (generated). These fields contain latitude and longitude values and are assigned the Latitude and Longitude geographic roles.

Can Google maps use latitude and longitude?

To search for a place, enter the latitude and longitude GPS coordinates on Google Maps. You can also find the coordinates of the places you previously found. Besides longitude and latitude, you can use plus codes to share a place without an address.


2 Answers

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.

like image 134
nate c Avatar answered Oct 08 '22 08:10

nate c


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>
like image 24
vfn Avatar answered Oct 08 '22 06:10

vfn