stat157 / recent-quakes

Stat 157 Homework 2 due on Monday 2013-10-21 at 11:59pm
0 stars 20 forks source link

Ideas about visualization #19

Open davidwang001 opened 11 years ago

davidwang001 commented 11 years ago

I wanted to share my ideas about visualization and hopefully get some help on debugging them since our group's data isn't ready yet.

  1. First I want to filter the panda dataframe so that we only have data relevant to the state of interest.

def state_data(state, data): sdata=data[state in data.location] return sdata[0:10]

  1. Next, we dig into that data to find values of the bbox by taking max and min long/lats for the new data set.

quakes = state_data("California",data)

from mpl_toolkits.basemap import Basemap

def bbox(quakes):

create a variable called x to create margins

x=50
#calculate quake bounding box from lat,lon
Max_lat=quakes[,1]+x
Min_lat=quakes[,1]+x
Max_long=quakes[,2]+x
Min_long=quakes[,2]+x
centerlat=mean(quakes[,1])
centerlon=mean(quakes[,2])

#create bounded box
b=[]
return b
  1. Use the bbox to create a nice area for the visualization map

Am I missing anything up to this point? Does any of it not make sense? Also, how do I synch a python compiler to my sublime text 2? Thank you guys!

timothyhoang commented 11 years ago

That sounds like a good idea, but I don't know how you can generalize the function plot_quakes by using bbox(quakes), because bbox(quakes) would have to return something different for different areas/countries/states, but only takes in one parameter. It might just be easier to add parameters for the bounding box in plot_quakes:

plot_quakes(quakes, centerlat, centerlon, dimensionsOfBoundingBox)

Keep in mind that bounding box for basemap is determined by 2 corner points, which are determined by 4 parameters - so you need to initialize:

llcrnrlon - lower left hand corner longitude degree llcrnrlat - lower left hand corner latitude degree urcrnrlon - upper right hand corner longitude urcrnrlat - upper right hand corner latitude

From the looks of you bbox code, it might be easier to do something lke this:

#calculate quake bounding box from centerlat,centerlon for a region of dimensions a x a you want to plot around  point (centerlon, centerlat) 

Max_lat=centerlat+a
Min_lat=centerlat-a
Max_long=centerlon+a
Min_long=centerlon-a