Decision makers can use the accumulated shortest paths output to identify the busiest paths to the school. They can use this information to communicate with guardians about the safest routes for their children.
Planners can go a step further by investing in safe infrastructure for the most used paths. For example, planners can identify the busy crossings over highways using the "count" attribute (and visualization) from the query layer and the "highways" attribute from newark_osm.
Of course, communication with stakeholders is ideally a two-way process. To achieve this goal, planners could establish a social networking account, such as a Twitter account, for parents and students to report the problems or features of the walking routes. Planners would likely want to look at this data as well to adjust the safe routes to the problem spots or amenities. This highly simplistic model should be adjusted for the other variables that could also be captured in the data and modeled, such as high traffic roads and so on.
The following instructions will direct you on how to set up a new Twitter account in a web browser and get your community to make geotagged tweets:
@YOURNAME). Retweet the tweets that you wish to add to your map. For a more passive solution, you can also follow all the users who you wish to capture; although, you'll need to find some way to filter out their irrelevant tweets.We must now download and install Python-based Twitter Tools, which leverage the Twitter API. This will allow us to pull down GeoJSON from our Twitter account. Perform the following steps:
sudo to run it with full privileges. Your OS Account must have administrator privileges. Navigate to C:\Program Files\QGIS Wien\OSGeo4W.bat.cd) into the directory that you extracted into (for example, C:\Users\[YOURUSERNAME]\Downloads\twitter-master\twitter-master), using the following command line:
> cd C:\Users\[YOURUSERNAME]\Downloads\twitter-master\twitter-master
> python setup.py install > twitter
Running python setup.py install in a directory containing the setup.py file on a path including the Python executable is the normal way to build (install) a Python program. You will need to install the setuptools module beforehand. The instructions to do so can be found on this website: https://pypi.python.org/pypi/setuptools.
twitter --help for more options. Execute the following in the command line:> twitter --format json 1> "C:\packt\c4\data\output\twitter.json" > cd c:\packt\c4 > python
import json
f = open('./output/twitter.json', 'r')
jsonStr = f.read()
f.close()
jpy = json.loads(jsonStr)
geojson = ''
for x in jpy['safe']:
if x['geo'] :
geojson += '{"type": "Feature","geometry": {"type": "Point", "coordinates": [' + str(x['geo']['coordinates'][1]) + ',' + str(x['geo']['coordinates'][0]) + ']}, "properties": {"id": "' + str(x['id']) + '", "text": "' + x['text'] + '"}},'
geojson = geojson[:-1]
geojson += ']}'
geojson = '{"type": "FeatureCollection","features": [' + geojson
f = open('./data/output/twitter.geojson', 'w')
f.write(geojson)
f.close()Or run the following command:
> python twitterJson2GeoJson.py
Here is an example of the GeoJSON-formatted output:
{"type": "FeatureCollection","features": [{"type": "Feature","geometry": {"type": "Point", "coordinates": [-75.75451,39.67434]}, "properties": {"id": "606454366212530177", "text": "Hello world"}},{"type": "Feature","geometry": {"type": "Point", "coordinates": [-75.73968,39.68139]}, "properties": {"id": "606454626456473600", "text": "Testing"}},{"type": "Feature","geometry": {"type": "Point", "coordinates": [-75.76838,39.69243]}, "properties": {"id": "606479472271826944", "text": "Test"}}]}Save this as c4/output/twitter.geojson from a text editor and import the file into QGIS as a vector layer to preview it along with the other layers. When these layers are symbolized, you may see something similar to the following image:

Finally, export the web application with qgis2leaf. You will notice some loss of information and symbology here. In addition, you may wish to customize the code to take advantage of the data and content passed through Twitter.
