Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have a txt file from which I need to draw data and use it to plot the path and a bar graph. I am

I have a txt file from which I need to draw data and use it to plot the path and a bar graph. I am having trouble designing the dictionary and lists for containing the information. Also could you suggest how I would plot them using the dictionaries. I will attach my code, the txt file, and assignment help sheet.

https://www.dropbox.com/s/yb67xy52rsuy2gy/ZebraBotswana.txt?dl=0

import pylab

from math import *

def distance(lon1, lat1, long2, lat2):

l1 = radians(float(long1))

l2 = radians(float(lat1))

p1 = radians(float(lat1))

p2 = radians(float(lat2))

dp = p2 -p1

d1 = l2 - l1

a = sin(dp/2)**2 + cos(p1)*cos(p2)*sin(d1/2)**2

c = atan2(sqrt*a, sqrt*1-a)

d = 6371 * c

return d

def Getltlg():

zebraltdict = {}

zebralgdict = {}

infile = open("ZebraBotswana.txt", "r")

readlines = infile.readlines()

Types = [line.split(',') for line in readlines]

if tuple(Types[3]) not in zebraltdict:

zebraltdict.setdefault(tuple(Types[3]), [])

if tuple(Types[3]) not in zebralgdict:

zebralgdict.setdefault(tuple(Types[3]), [])

for keys in zebraltdict.keys():

ltd = [Type[1] for Type in Types if Types[3] == keys]

zebraltdict[keys].append(ltd)

for keys in zebralgdict.keys():

lat = [Type[2] for Type in Types if Types[3] == keys]

zebralgdict[keys].append(lat)

infile.close()

image text in transcribed

The position data of several zebra (Equus quagga burchell) in northern Botswana are given in the file ZebraBotswana.txt. (source: movebank.org) The comma unix timestam degrees), and the number of the corresponding zebra (e.g., 23864). separated data consist of the date and time of the measurement (in p format), the longitude and latitude of the measured position (in Write a program to do the following: 1. Read the data and display a plot of the path of each zebra. Use a different color for each zebra. 2. Display a bar graph of the average distance traveled per day of each Submit your program as a single Python file with the name Zebra. py Mathematics: The following function will compute the distance in kilometers zebra. between two longitude-latitude positions. from math import * def distance(long1,latl,long2,lat2): 11-radians (float (lon 12-radians(float(long2)) pl-radians(float(latl)) p2-radians(float(lat2)) dp-p2-pl dl-12-11 a=sin(dp / 2 ) * * 2 + cos (p1 ) *cos (p2)*sin(a1 /2 ) * * 2 c-2*atan2 (sqrt(a),sqrt (1-a)) d-6371*c return d g1))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

ISBN: 0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago