Skip to content

Commit e3a0d0c

Browse files
author
Senaka Fernando
committed
Geovisualisation Tutorial
0 parents  commit e3a0d0c

12 files changed

+20395
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
crime_map_config.json
2+
roads_map_config.json
3+
listings*

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Open Visualisation Environment - Tutorials
2+
3+
This repository contains example files used by the [Open Visualisation Environment (OVE)](https://ove.readthedocs.io/) tutorials.
4+
5+
It currently includes the following tutorials:
6+
7+
* [Geovisualisation](geovisualisation/README.md)
8+
9+
The OVE Tutorials are intended to be used as a supplement for the [OVE Documentation](https://ove.readthedocs.io/en/stable/).

geovisualisation/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Geovisualisation Tutorial
2+
3+
This repository contains example files used by the [Geovisualisation Tutorial](https://ove.readthedocs.io/en/stable/docs/tutorials/GEOVISUALISATION.html) of OVE. Some of the content found in this repository were obtained from [Geofabrik](https://download.geofabrik.de/europe/great-britain/england/hampshire.html) and [DATA.POLICE.UK](https://data.police.uk/data/). No modifications have been made to the original data, but they have been transformed into the [GeoJSON](http://geojson.org/) format using various tools as described in the [Documentation](https://ove.readthedocs.io/en/stable/docs/tutorials/GEOVISUALISATION.html#summary).

geovisualisation/convert.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
3+
#copied from https://stackoverflow.com/a/48586799
4+
5+
import sys, csv, json
6+
from geojson import Feature, FeatureCollection, Point
7+
8+
features = []
9+
f = 'listings.csv' if len(sys.argv) < 2 else sys.argv[1]
10+
with open(f) as csvfile:
11+
reader = csv.reader(csvfile, delimiter=',')
12+
next(reader, None) # skip the headers
13+
14+
# Modify the following line when using with other CSV files. You will also need to change the if-condition and the properties below, accordingly.
15+
for id,listing_url,scrape_id,last_scraped,name,summary,space,description,experiences_offered,neighborhood_overview,notes,transit,access,interaction,house_rules,thumbnail_url,medium_url,picture_url,xl_picture_url,host_id,host_url,host_name,host_since,host_location,host_about,host_response_time,host_response_rate,host_acceptance_rate,host_is_superhost,host_thumbnail_url,host_picture_url,host_neighbourhood,host_listings_count,host_total_listings_count,host_verifications,host_has_profile_pic,host_identity_verified,street,neighbourhood,neighbourhood_cleansed,neighbourhood_group_cleansed,city,state,zipcode,market,smart_location,country_code,country,latitude,longitude,is_location_exact,property_type,room_type,accommodates,bathrooms,bedrooms,beds,bed_type,amenities,square_feet,price,weekly_price,monthly_price,security_deposit,cleaning_fee,guests_included,extra_people,minimum_nights,maximum_nights,calendar_updated,has_availability,availability_30,availability_60,availability_90,availability_365,calendar_last_scraped,number_of_reviews,first_review,last_review,review_scores_rating,review_scores_accuracy,review_scores_cleanliness,review_scores_checkin,review_scores_communication,review_scores_location,review_scores_value,requires_license,license,jurisdiction_names,instant_bookable,cancellation_policy,require_guest_profile_picture,require_guest_phone_verification,calculated_host_listings_count,reviews_per_month in reader:
16+
if room_type == 'Entire home/apt':
17+
longitude, latitude = map(float, (longitude, latitude))
18+
features.append(
19+
Feature(
20+
id = id,
21+
properties = {
22+
'timestamp': host_since + 'T00:00:00Z',
23+
'version': '1',
24+
'changeset': '0',
25+
'name': name
26+
},
27+
geometry = Point((longitude, latitude))
28+
)
29+
)
30+
31+
collection = FeatureCollection(features)
32+
with open(f.replace('.csv', '.json'), 'w') as f:
33+
f.write('%s' % collection)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"layers": [
3+
{
4+
"type": "L.tileLayer",
5+
"visible": false,
6+
"wms": false,
7+
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}.jpg"
8+
},
9+
{
10+
"type": "L.geoJSON",
11+
"visible": true,
12+
"wms": false,
13+
"url": "http://localhost:8000/hampshireCrime.json"
14+
}
15+
],
16+
"center": ["-157081.37129179656", "6606026.977066623"],
17+
"resolution": "77",
18+
"zoom": "12"
19+
}

geovisualisation/fixIP.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
import os, sys
4+
5+
if len(sys.argv) < 2:
6+
print("usage: python -m %s <IP>" % os.path.basename(sys.argv[0]).split('.')[0])
7+
else:
8+
ip = sys.argv[1]
9+
try:
10+
i = open("crime_map_config_original.json","r")
11+
o = open("crime_map_config.json","w")
12+
for line in i:
13+
o.write(line.replace("localhost", ip))
14+
finally:
15+
i.close()
16+
o.close()
17+
18+
try:
19+
i = open("roads_map_config_original.json","r")
20+
o = open("roads_map_config.json","w")
21+
for line in i:
22+
o.write(line.replace("localhost", ip))
23+
finally:
24+
i.close()
25+
o.close()

geovisualisation/hampshireCrime.json

+1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)