%sh wget -O UppsalaCentrumWgot.osm "https://api.openstreetmap.org/api/0.6/map?bbox=17.6244,59.8464,17.6661,59.8643"
--2019-06-19 08:14:56-- https://api.openstreetmap.org/api/0.6/map?bbox=17.6244,59.8464,17.6661,59.8643
Resolving api.openstreetmap.org (api.openstreetmap.org)... 130.117.76.13, 130.117.76.11, 130.117.76.12, ...
Connecting to api.openstreetmap.org (api.openstreetmap.org)|130.117.76.13|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/xml]
Saving to: ‘UppsalaCentrumWgot.osm’
0K .......... .......... .......... .......... .......... 162K
50K .......... .......... .......... .......... .......... 324K
100K .......... .......... .......... .......... .......... 39.3M
150K .......... .......... .......... .......... .......... 1.40M
200K .......... .......... .......... .......... .......... 422K
250K .......... .......... .......... .......... .......... 44.0M
300K .......... .......... .......... .......... .......... 16.7M
350K .......... .......... .......... .......... .......... 1.57M
400K .......... .......... .......... .......... .......... 424K
450K .......... .......... .......... .......... .......... 17.6M
500K .......... .......... .......... .......... .......... 22.4M
550K .......... .......... .......... .......... .......... 16.3M
600K .......... .......... .......... .......... .......... 16.2M
650K .......... .......... .......... .......... .......... 59.6M
700K .......... .......... .......... .......... .......... 63.6M
750K .......... .......... .......... .......... .......... 2.12M
800K .......... .......... .......... .......... .......... 39.5M
850K .......... .......... .......... .......... .......... 426K
900K .......... .......... .......... .......... .......... 55.7M
950K .......... .......... .......... .......... .......... 51.6M
1000K .......... .......... .......... .......... .......... 28.4M
1050K .......... .......... .......... .......... .......... 57.6M
1100K .......... .......... .......... .......... .......... 52.5M
1150K .......... .......... .......... .......... .......... 30.0M
1200K .......... .......... .......... .......... .......... 19.8M
1250K .......... .......... .......... .......... .......... 43.6M
1300K .......... .......... .......... .......... .......... 46.1M
1350K .......... .......... .......... .......... .......... 41.6M
1400K .......... .......... .......... .......... .......... 51.2M
1450K .......... .......... .......... .......... .......... 37.2M
1500K .......... .......... .......... .......... .......... 35.8M
1550K .......... .......... .......... .......... .......... 2.59M
1600K .......... .......... .......... .......... .......... 34.3M
1650K .......... .......... .......... .......... .......... 84.7M
1700K .......... .......... .......... .......... .......... 153M
1750K .......... .......... .......... .......... .......... 426K
1800K .......... .......... .......... .......... .......... 31.4M
1850K .......... .......... .......... .......... .......... 43.4M
1900K .......... .......... .......... .......... .......... 28.2M
1950K .......... .......... .......... .......... .......... 41.1M
2000K .......... .......... .......... .......... .......... 41.6M
2050K .......... .......... .......... .......... .......... 114M
2100K .......... .......... .......... .......... .......... 131M
2150K .......... .......... .......... .......... .......... 153M
2200K .......... .......... .......... .......... .......... 57.0M
2250K .......... .......... .......... .......... .......... 18.5M
2300K .......... .......... .......... .......... .......... 21.5M
2350K .......... .......... .......... .......... .......... 27.5M
2400K .......... .......... .......... .......... .......... 109M
2450K .......... .......... .......... .......... .......... 153M
2500K .......... .......... .......... .......... .......... 134M
2550K .......... .......... .......... .......... .......... 145M
2600K .......... .......... .......... .......... .......... 151M
2650K .......... .......... .......... .......... .......... 151M
2700K .......... .......... .......... .......... .......... 126M
2750K .......... .......... .......... .......... .......... 149M
2800K .......... .......... .......... .......... .......... 149M
2850K .......... .......... .......... .......... .......... 150M
2900K .......... .......... .......... .......... .......... 129M
2950K .......... .......... .......... .......... .......... 151M
3000K .......... .......... .......... .......... .......... 152M
3050K .......... .......... .......... .......... .......... 153M
3100K .......... .......... .......... .......... .......... 3.16M
3150K .......... .......... .......... .......... .......... 150M
3200K .......... .......... .......... .......... .......... 152M
3250K .......... .......... .......... .......... .......... 434K
3300K .......... .......... .......... .......... .......... 20.5M
3350K .......... .......... .......... .......... .......... 52.3M
3400K .......... .......... .......... .......... .......... 64.9M
3450K .......... .......... .......... .......... .......... 20.9M
3500K .......... .......... .......... .......... .......... 27.7M
3550K .......... .......... .......... .......... .......... 60.5M
3600K .......... .......... .......... .......... .......... 47.4M
3650K .......... .......... .......... .......... .......... 161M
3700K .......... .......... .......... .......... .......... 38.3M
3750K .......... .......... .......... .......... .......... 28.8M
3800K .......... .......... .......... .......... .......... 24.7M
3850K .......... .......... .......... .......... .......... 56.5M
3900K .......... .......... .......... .......... .......... 50.5M
3950K .......... .......... .......... .......... .......... 51.5M
4000K .......... .......... .......... .......... .......... 77.3M
4050K .......... .......... .......... .......... .......... 130M
4100K .......... .......... .......... .......... .......... 149M
4150K .......... .......... .......... .......... .......... 152M
4200K .......... .......... .......... .......... .......... 149M
4250K .......... .......... .......... .......... .......... 126M
4300K .......... .......... .......... .......... .......... 150M
4350K .......... .......... .......... .......... .......... 151M
4400K .......... .......... .......... .......... .......... 151M
4450K .......... .......... .......... .......... .......... 132M
4500K .......... .......... .......... .......... .......... 147M
4550K .......... .......... .......... .......... .......... 151M
4600K .......... .......... .......... .......... .......... 3.35M
4650K .......... .......... .......... .......... .......... 32.2M
4700K .......... .......... .......... .......... .......... 153M
4750K .......... .......... .......... .......... .......... 5.42M
4800K .......... .......... .......... .......... .......... 463K
4850K .......... .......... .......... .......... .......... 27.4M
4900K .......... .......... .......... .......... .......... 97.2M
4950K .......... .......... .......... .......... .......... 29.5M
5000K .......... .......... .......... .......... .......... 38.9M
5050K .......... .......... .......... .......... .......... 81.6M
5100K .......... .......... .......... .......... .......... 25.8M
5150K .......... .......... .......... .......... .......... 146M
5200K .......... .......... .......... .......... .......... 43.6M
5250K .......... .......... .......... .......... .......... 24.3M
5300K .......... .......... .......... .......... .......... 20.9M
5350K .......... .......... .......... .......... .......... 18.9M
5400K .......... .......... .......... .......... .......... 39.4M
5450K .......... .......... .......... .......... .......... 123M
5500K .......... .......... .......... .......... .......... 152M
5550K .......... .......... .......... .......... .......... 153M
5600K .......... .......... .......... .......... .......... 146M
5650K .......... .......... .......... .......... .......... 128M
5700K .......... .......... .......... .......... .......... 145M
5750K .......... .......... .......... .......... .......... 146M
5800K .......... .......... .......... .......... .......... 152M
5850K .......... .......... .......... .......... .......... 130M
5900K .......... .......... .......... .......... .......... 147M
5950K .......... .......... .......... .......... .......... 149M
6000K .......... .......... .......... .......... .......... 126M
6050K .......... .......... .......... .......... .......... 150M
6100K .......... .......... .......... .......... .......... 3.67M
6150K .......... .......... .......... .......... .......... 46.6M
6200K .......... .......... .......... .......... .......... 56.6M
6250K .......... .......... .......... .......... .......... 16.7M
6300K .......... .......... .......... .......... .......... 446K
6350K .......... .......... .......... .......... .......... 49.3M
6400K .......... .......... .......... .......... .......... 25.4M
6450K .......... .......... .......... .......... .......... 46.2M
6500K .......... .......... .......... .......... .......... 59.7M
6550K .......... .......... .......... .......... .......... 90.3M
6600K .......... .......... .......... .......... .......... 44.3M
6650K .......... .......... .......... .......... .......... 34.5M
6700K .......... .......... .......... .......... .......... 41.6M
6750K .......... .......... .......... .......... .......... 55.8M
6800K .......... .......... .......... .......... .......... 161M
6850K .......... .......... .......... .......... .......... 44.1M
6900K .......... .......... .......... .......... .......... 33.2M
6950K .......... .......... .......... .......... .......... 42.3M
7000K .......... .......... .......... .......... .......... 27.9M
7050K .......... .......... .......... .......... .......... 45.4M
7100K .......... .......... .......... .......... .......... 56.6M
7150K .......... .......... .......... .......... .......... 178M
7200K .......... .......... .......... .......... .......... 158M
7250K .......... .......... .......... .......... .......... 178M
7300K .......... .......... .......... .......... .......... 141M
7350K .......... .......... .......... .......... .......... 168M
7400K .......... .......... .......... .......... ......... 196M=1.6s
2019-06-19 08:15:00 (4.67 MB/s) - ‘UppsalaCentrumWgot.osm’ saved [7628216]
val path = "dbfs:/datasets/maps/UppsalaCentrumWgot.osm" val uppsalaCentrumOsmDF = spark.read .format("magellan") .option("type", "osm") .load(path)
path: String = dbfs:/datasets/maps/UppsalaCentrumWgot.osm
uppsalaCentrumOsmDF: org.apache.spark.sql.DataFrame = [point: point, polyline: polyline ... 3 more fields]
uppsalaCentrumOsmDF.show()
+-----+--------------------+--------------------+--------------------+-----+
|point| polyline| polygon| metadata|valid|
+-----+--------------------+--------------------+--------------------+-----+
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...|[addr:street -> B...| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...|[addr:street -> B...| true|
| null| null|magellan.Polygon@...|[addr:street -> B...| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...|[building -> garage]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...| [building -> yes]| true|
| null| null|magellan.Polygon@...|[amenity -> parking]| true|
| null|magellan.PolyLine...| null|[highway -> service]| true|
| null|magellan.PolyLine...| null| []| true|
+-----+--------------------+--------------------+--------------------+-----+
only showing top 20 rows
%sh wget -O TinyUppsalaCentrumWgot.osm "https://api.openstreetmap.org/api/0.6/map?bbox=17.63514,59.85739,17.64154,59.86011"
--2019-06-19 08:18:28-- https://api.openstreetmap.org/api/0.6/map?bbox=17.63514,59.85739,17.64154,59.86011
Resolving api.openstreetmap.org (api.openstreetmap.org)... 130.117.76.12, 130.117.76.13, 130.117.76.11, ...
Connecting to api.openstreetmap.org (api.openstreetmap.org)|130.117.76.12|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/xml]
Saving to: ‘TinyUppsalaCentrumWgot.osm’
0K .......... .......... .......... .......... .......... 164K
50K .......... .......... .......... .......... .......... 328K
100K .......... .......... .......... .......... .......... 39.4M
150K .......... .......... .......... .......... .......... 1.24M
200K .......... .......... .......... .......... .......... 441K
250K .......... .......... .......... .......... .......... 58.9M
300K .......... .......... .......... .......... .......... 45.0M
350K .......... .......... .......... .......... .......... 38.4M
400K .......... .......... .......... .......... .......... 336K
450K .......... .......... .......... .......... .......... 48.1M
500K .......... .......... .......... .......... .......... 40.9M
550K .......... .......... .......... .......... .......... 42.1M
600K .......... .......... .......... .......... .......... 48.8M
650K .......... .......... .......... .......... .......... 42.0M
700K .......... .......... .......... .......... .......... 64.5M
750K .......... .......... .......... .......... ....... 151M=0.8s
2019-06-19 08:18:29 (1.01 MB/s) - ‘TinyUppsalaCentrumWgot.osm’ saved [816717]
//val point1 = sc.parallelize(Seq((59.839264, 17.647075),(59.9, 17.88))).toDF("x", "y") val point1 = sc.parallelize(Seq((59.839264, 17.647075))).toDF("x", "y") val point1c = point1.collect() //val string_p1c = point1.mkString(", ") val string2 = point1c.mkString(",") //df.select(columns: _*).collect.map(_.toSeq) val string22 = "'random_string'"
point1: org.apache.spark.sql.DataFrame = [x: double, y: double]
point1c: Array[org.apache.spark.sql.Row] = Array([59.839264,17.647075])
string2: String = [59.839264,17.647075]
string22: String = 'random_string'
def genLeafletHTML(): String = { // you should get your own later! val accessToken = "pk.eyJ1IjoiZHRnIiwiYSI6ImNpaWF6MGdiNDAwanNtemx6MmIyNXoyOWIifQ.ndbNtExCMXZHKyfNtEN0Vg" val generatedHTML = f"""<!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.css"> <style>#map {width: 600px; height:400px;}</style> </head> <body> <div id="map" style="width: 600px; height: 400px"></div> <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/leaflet.js"></script> <script type="text/javascript"> var map = L.map('map').setView([59.838, 17.646865], 16); L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=$accessToken', { maxZoom: 19 , id: 'mapbox.streets' , attribution: '<a href="http://openstreetmap.org">OpenStreetMap</a> ' + '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a> ' + '| © <a href="http://mapbox.com">Mapbox</a>' }).addTo(map); str1 = 'SDS<br>Ångströmlaboratoriet<br>59.839264, 17.647075<br>'; str2 = ${string22}; var popup = str1.concat(str2); L.marker(${string2}).addTo(map) .bindPopup(popup) .openPopup(); </script> </body> """ generatedHTML } displayHTML(genLeafletHTML)
SDS-2.x, Scalable Data Engineering Science
By Marina Toger
Last refresh: Never