-
Introduction 1
-
Lecture1.1
-
-
Getting the Data 4
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
-
Location Groups 3
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
-
Creating the New Data 3
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
-
Mapping the Data 3
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
Grid Basics
First let’s import our libraries and get the dataset in.
import pandas as pd
import numpy as np
Assess_Combined = pd.DataFrame.from_csv("Assess_Combined.csv",encoding="UTF-8")
Now, let’s create a function to find the upper and lower bounds for both latitude and longitude.
def locationSlice():
Map_Points = Assess_Combined[['LATITUDE','LONGITUDE']]
a= Map_Points.max()['LATITUDE']
b= Map_Points.min()['LATITUDE']
c= Map_Points.max()['LONGITUDE']
d= Map_Points.min()['LONGITUDE']
print(a)
print(b)
print(c)
print(d)
And let’s run it.
locationSlice()
Now that we know the bounds, what we want to do is find the distance from bound to bound. This will be what we slice up for our grid. We’ll modify the function, and get the variables as such below.
def locationSlice(slice_constant):
Map_Points = Assess_Combined[['LATITUDE','LONGITUDE']]
a= Map_Points.max()['LATITUDE']
b= Map_Points.min()['LATITUDE']
c= Map_Points.max()['LONGITUDE']
d= Map_Points.min()['LONGITUDE']
lat_range = (a-b)/slice_constant
lon_range = (c-d)/slice_constant
return (a,b,c,d,lat_range,lon_range)
a,b,c,d,lat_range,lon_range = locationSlice(100)
Our next move is to represent these location slices as numbers in the grid.
Challenge
Try to create a function that returns a number representing what slice both latitude and longitude are on. We want a number 0-99 for both latitude and longitude where 0 is near the lowest bound, and 99 is near the highest bound.
Prev
Introduction
Next
Building the Grid