辅导案例-SPAT1003/5012

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
SPAT1003/5012
Advanced Coding Exercise: Spatial Computations
“Just for the record darling, not all positive change feels positive in the beginning.”S.C. Lourie
Overview
This assessment is in two parts and each part will be submitted separately through the dropbox that will be madeavailable on Blackboard. Please keep up-to-date with announcements within Blackboard to ensure that all that isrequired is submitted at the appropriate time.
Outcomes for the assessment:
Upon successful completion of the two assessments you will be able to:
• Analyse a problem and design a solution for it (ULO 1,2,3);
• Use programming skills to implement your design in Python (ULO 2,3,4);
• Construct well structured and documented Python code (ULO 4,5);
• Test and debug your code to produce a robust application (ULO 4,5);
• Present a visualisation of the output from your program (ULO 1,2,3); and
• Present your findings in a structured, professional report (ULO 3).
Background
The overall aim of this assessment is to understand more about road accidents, where they happen, fatalities involved,locations of where accidents occurred and more. On the way to understanding this we will learn several other thingswhich may also assist in the overall learning process.
The General Tasks for Assessment Two
Assessment Two continues directly on from Assessment One. Hence, you will use the code you wrote in assessmentone and further develop it by adding new features to it. It will perform several calculations given different parametersand display this data to the user and further process large files of data. For example, you will need to do thingssuch as:
• calculate the distance from a specified location to the nearest car accident;
• calculate the number of car accidents within a given radius from a specified location;
• calculate the number of fatal car accidents;
• calculate the furtherest away car accident;
• and more...
Advanced Coding Exercise
School of Earth and Planetary Sciences - Spatial Sciences, Curtin University..
Page 1 of 6
CRICOS Provider Code 00301J
SPAT1003/5012
The Task Breakdown
The assessment is broken down into several tasks. Tasks can flow into the following tasks. It is recommended thatyou complete the assessment task by task in the order they are listed. Design a solution for the task, test thatsolution; fix any problems found in the solution; code the solution; debug, test and document it. It is possible thateach new task may require the previous task(s) to be completed. As you develop your solution you may need toalter the order of the tasks, but this will become evident as you create your solution.
Task 6
In this task you will now calculate which accident is the furtherest accident from your measuring point. You will needto display this data to the user in a meaningful way.
Design the task in pseudocode and implement it in Python.
Let’s take a deep breath and examine what we have at this point in time.
We have now collected and/or calculated the following information:
• The name and coordinates of a centre point from which we are measuring everything;
• the name of the place from which the calculations will be measured;
• the coordinates (latitude, longitude) of the location from which the accidents will be measured from;
• a radius distance from the location from which the accidents will be measured and analysed from;
• Accident ID number for each accident;
• Accident severity: Medical, Hospital, Fatal, Major, Minor for each accident;
• Accident Type: Intersection or Midblock for each accident;
• Year of accident for each one;
• Latitude and longitude of each accident; and
• The accident furtherest away from your measuring point.
What would be excellent is to now visually present this information to the user in the form of a map.
Task 7
In this task your program will create a GeoJSON file that will contain the following information:
• The name of the centre point from which you are measuring everything;
• Coordinates of the centre point from which you are measuring everything;
• For each accident:
– Accident ID number;
– Accident severity: Medical, Hospital, Fatal, Major, Minor;
– Accident Type: Intersection or Midblock;
Advanced Coding Exercise
School of Earth and Planetary Sciences - Spatial Sciences, Curtin University..
Page 2 of 6
CRICOS Provider Code 00301J
SPAT1003/5012
– Year of accident;
– Latitude of accident; and
– Longitude of accident.
– Distance from the measuring point;
– Bearing from the the measuring point;
– If it is inside or outside the radius; and
– If it is furtherest from the measuring point.
The GeoJSON file will be able to be loaded into an external program and display this information on a map.
To complete this task you will use the code that has been provided. Follow the instructions as to how to use itand it will produce for you a GeoJSON string that you then must write to file giving it a .geojson extension. Openthe the .py file and copy and paste it into a Code Cell within Colab/Anaconda. There is sample code to assist withunderstanding the provided code. This too will need to be copied and pasted into Colab/Anaconda.
You will create a list of dictionaries. Each dictionary will contain the data about a single accident. The first dictionaryin the list will be the point from which you are measuring.
Figure 1: GeoJSON Visualised.
Design the task in pseudocode and implement it in Python.
Advanced Coding Exercise
School of Earth and Planetary Sciences - Spatial Sciences, Curtin University..
Page 3 of 6
CRICOS Provider Code 00301J
SPAT1003/5012
Great news, data files now available!
There is now data available in a file and hence the data can now be retrieved from files instead of entering data byhand for each accident. A sample screenshot of available files is given in Figure 2.
Figure 2: A screenshot of a the accidents file.
Task 8
In this task you now need to adjust your program so that after it has launched and displayed a welcome messageetc. it asks the user if they wish to:
• enter the details by hand (as in assessment one); or
• read data from a file (defining the details of the measuring point still needs to be entered manually).
If the user chooses to enter the data by hand, your program runs as it did through to the end of Task 7.
If the user chooses to use a file your program will now process the data file. Data file is provided in Blackboard.
Your program will ask the user to enter the details of where it is measuring from, including the radius, just as it hasdone before, and for file name containing the accident data.
In order to complete this task, you are REQUIRED to write and use a function in the following format. When you callthe function, the code will look like this:
centroid_file_name = get_file_name()
The function MUST return the following value: the_file_name.
The function definition will look like this:
def get_file_name():
...
*your code here*
...
return the_file_name
For either choice the user makes, to enter the data manually or to read data from a file, you will carry out the samecalculations as you did in Task 7 and generate a .geojson file. You will display the data to the user as shown in thesample output below. Please note it has slightly changed from assessment one. Hence, this is the data that mustbe displayed regardless of the user choice.
Advanced Coding Exercise
School of Earth and Planetary Sciences - Spatial Sciences, Curtin University..
Page 4 of 6
CRICOS Provider Code 00301J
SPAT1003/5012
Sample output data
Acc_ID, Severity, Type, Year, Latitude, Longitude, Distance, Bearing, In_Radius, Furtherest
===========================================================================================
12345, Fatal, Intersection, 2011, -33.349144, 115.668396, 3125, 33.55, No, Yes
Design the task in pseudocode and implement it in Python.
Task 9
In this task you will generate some basic statistics from either the data entered manually or the data read from thefile.
The statistics to generate and display to the user are:
• Total number of fatal accidents;
• Total number of fatal accidents as a percentage of all accidents;
• Total number of fatal accidents within the radius;
• Total number of fatal accidents within the radius as a percentage of accidents within the radius;
Design the task in pseudocode and implement it in Python.
It should be possible for your program to be run and all tasks to executecorrectly, including if the user chooses to manually enter the details.
Task 10
Write a short report that contains:
• an explanation of any errors you were unable to solve and/or any tasks that have not been completed; and
• a testing plan with a short explanation.
Task 11: SPAT5012 ONLY
Dijkstra’s algorithm is a shortest path algorithm that is often used to calculate the shortest path between twolocations within a road network. Write a 500 word summary of the algorithm highlighting its strengths and weaknesses.You must include at least 3 citations and one should NOT be Wikipedia. However, a good starting point to understandDijkstra’s algorithm is Wikipedia.
Advanced Coding Exercise
School of Earth and Planetary Sciences - Spatial Sciences, Curtin University..
Page 5 of 6
CRICOS Provider Code 00301J
SPAT1003/5012
Things to Note:
After successfully completing each Task, backup your code and begin on the next Task using a copy of your programcode. This ensures you have a back up of the assessment at each stage should something go wrong.
Your code should be well documented using the 2 types of comments that have been discussed within this unit: inlinecomments and block comments.
Assessment 2 Submission Details:
Due Date:• Sunday 8 November 2020 @ 23:59 (AWST).
Deliverables:
• Completed Student Declaration form;
• The pseudocode of all tasks as Text Cells within your Notebook;
• The Colab/Anaconda notebook .pynb file;
• The report containing:
– The testing plan; and
– An explanation of any errors you were unable to solve or any tasks you have not completed.
• SPAT5012 Students Only: The Dijkstra algorithm write up.
Where to deliver:
• Via the Blackboard assessment dropbox tool.
Advanced Coding Exercise
School of Earth and Planetary Sciences - Spatial Sciences, Curtin University..
Page 6 of 6
CRICOS Provider Code 00301J

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468