Meteorite Mania
Tags: datascience, python, programming, github
Published: 2022-12-02 02:34:23


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/slkozhel0qrzno85nvgx.png)
**Author:** Jonathan Fetterolf

<center> *If you want to know how I put this together, I step through my process from start to finish after the conclusions and limitations...* 
or view the juicy details here: 
**[Meteorite Mania GitHub Repository](https://github.com/fetterollie/meteorite-mania)**
</center>

# Overview
This notebook analyzes a dataset of known meteorite landing sites and the data associated with those meteorites. I derived some statistics about the known meteorites and mapped their landing sites as well as looked into where the majority of meteorites fell. In terms of mass, the largest known meteorite is 60000kg, which is contrasted by the smallest that comes in at 1e-05kg. The mean mass of the dataset is approximately 15.6kg, while the median is approximately 0.029kg. Nearly 74% of known meteorite landing sites are in the southern hemisphere while 26% are in the northern hemisphere. This overwhelming amount of known meteorite landing sites can be explained by this information compiled by the [Department of Earth and Planetary Sciences](https://sites.wustl.edu/meteoritesite/items/some-meteorite-statistics/) at the Washington University in St. Louis. 

They state: <center>*"Nearly all meteorites are found in deserts. (Yes, Antarctica is a desert because the annual precipitation rate is very low.) Deserts are places that accumulate meteorites over thousands of years and then nothing much happens to the meteorite. Also, meteorites are easier to find in deserts than in places with topography, vegetation, and other rocks."*</center>


# Understanding & Cleaning Data
This comprehensive data set from The Meteoritical Society contains information on all of the known meteorite landings up to 2013. The Fusion Table is collected by Javier de la Torre. This data consists of 34,513 meteorites. This dataset was obtained [here](https://catalog.data.gov/dataset/meteorite-landings) through [data.gov](https://data.gov/).

# Conclusions
**Mass**
- In terms of mass, the largest known meteorite is 60000kg which is contrasted by the smallest that comes in at 1e-05kg. 
- The mean mass of the dataset is approximately 15.6kg.
- The median is approximately 0.029kg. 

**Location**
![All Strike Locations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eldjqgvkrd41a4dfdbmh.png)

Approximately 74% of known meteorite landing sites are in the southern hemisphere.
![Southern Hemisphere Known Strike Locations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5l5rc6dfv3w6wxw80p1a.png)
Approximately 26% of known meteorite landing sites are in the northern  hemisphere.
![Northern Hemisphere Known Strike Locations](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/grf2yv94h88v9cjofx7m.png)

**Limitations**
- The dataset only contains data up to 2013.
- There are many known sites exactly on the equator. I did not include these in either northern or southern hemisphere.
- Many sites in the southern hemisphere, specifically Antartica are close so the visual representation of the data leads you to believe there are more landing sites in the northern hemisphere when in actuality, it is the opposite conclusion.

# Walkthrough
## Imports
```
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
import geopandas as gpd
```
 I used a data set with the geometry of landmasses to plot the shapes of land under my scatterplots. 

```
countries = gpd.read_file(
               gpd.datasets.get_path("naturalearth_lowres"))
```
## Importing data from file: 
```
df = pd.read_csv('data/Meteorite_Landings.csv', index_col=0)
```
## Cleaning & Filtering
I cleaned up the columns, dropped null values, filtered out a data point with an incorrect year, filtered out any entries with a mass of zero (what is a meteorite without mass...?), converted mass(g) to mass(kg) in a new column, and changed values in the fall column from 'Fell' to 'Not Found'. 
```
newcols = [col.strip().lower().replace(' ','') for col in df.columns]
df.columns = newcols

df = df.dropna()

df = df[ df['year'] <= 2013]

df = df[ df['mass(g)'] > 0]

df['mass(kg)'] = df['mass(g)']/1000

key = {'Not Found' : 'Fell'}
replace_key = {v: k for k, v in key.items()}
df['fall'].replace(replace_key, inplace=True)
```
## The Juicy Code
I calculated the maximum, minimum, mean, and median for the mass values.
```
largest_mass = df['mass(kg)'].max()
smallest_mass = df['mass(kg)'].min()
mean_mass = df['mass(kg)'].mean()
median_mass = df['mass(kg)'].median()
```
## The Juiciest Code
I wanted to plot coordinates of the following subsets of known meteorite landing sites. The following code filters for each and subsequently plots a scatterplot over a world map:

Top 500 Largest by Mass (kg)
```
df_top_500_largest_strikes = df.sort_values(by='mass(kg)', ascending=False).head(500)

fig5, ax5 = plt.subplots(figsize=(20, 10))

countries.plot(color="lightgrey", ax=ax5)

sns.scatterplot(data=df_top_500_largest_strikes, x='reclong', y='reclat', hue='mass(kg)', size='mass(kg)', ax=ax5, palette='flare')

ax5.set_title('Landing Sites of 500 Largest Known Meteorites')
ax5.grid(visible=True, alpha=0.5)
ax5.set_xlabel('Longitude')
ax5.set_ylabel('Latitude')
ax5.legend(title='Mass (kg)')
```
![Landing Sites of 500 Largest Known Meteorites](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4dpgpkonqc1wg25g6jh.png)

Top 100 Largest by Mass (kg)
```
df_top_100_largest_strikes = df.sort_values(by='mass(kg)', ascending=False).head(100)

fig4, ax4 = plt.subplots(figsize=(20, 10))

countries.plot(color="lightgrey", ax=ax4)

sns.scatterplot(data=df_top_100_largest_strikes, x='reclong', y='reclat', hue='mass(kg)', size='mass(kg)', ax=ax4, palette='flare')

ax4.set_title('Landing Sites of 100 Largest Known Meteorites')
ax4.grid(visible=True, alpha=0.5)
ax4.set_xlabel('Longitude')
ax4.set_ylabel('Latitude')
ax4.legend(title='Mass (kg)')
```
![Landing Sites of 100 Largest Known Meteorites](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kzssdo3i78rw1af72tre.png)

Top 10 Largest by Mass (kg)
```
df_top_10_largest_strikes = df.sort_values(by='mass(kg)', ascending=False).head(10)

fig6, ax6 = plt.subplots(figsize=(20, 10))

countries.plot(color="lightgrey", ax=ax6)

sns.scatterplot(data=df_top_10_largest_strikes, x='reclong', y='reclat', hue='mass(kg)', size='mass(kg)', ax=ax6, palette='flare')

ax6.set_title('Landing Sites of 10 Largest Known Meteorites')
ax6.grid(visible=True, alpha=0.5)
ax6.set_xlabel('Longitude')
ax6.set_ylabel('Latitude')
ax6.legend(title='Mass (kg)')
```
![Landing Sites of 10 Largest Known Meteorites](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjwlpumzjcjtfr5nvh48.png)
*I'm happy I wasn't living yet to see any of these largest known meteorite strikes.*

Northern Hemisphere Known Sites
```
df_northern_hem = df[ df['reclat'] > 0]

fig1, ax1 = plt.subplots(figsize=(20, 10))

countries.plot(color="lightgrey", ax=ax1)

sns.scatterplot(data=df_northern_hem, x='reclong', y='reclat',\
                hue='fall', ax=ax1, palette='flare', alpha=0.4)

ax1.set_title('Northern Hemisphere Known Meteorite Landings')
ax1.grid(visible=True, alpha=0.5)
ax1.set_xlabel('Longitude')
ax1.set_ylabel('Latitude')
ax1.legend(title='')
```
![Northern Hemisphere Known Meteorite Landings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kkcmwaw3dzvacmllizko.png)


Southern Hemisphere Known Sites
```
df_southern_hem = df[ df['reclat'] < 0]

fig1, ax1 = plt.subplots(figsize=(20, 10))

countries.plot(color="lightgrey", ax=ax1)

sns.scatterplot(data=df_southern_hem, x='reclong', y='reclat', hue='fall', ax=ax1, palette='flare', alpha=0.4)

ax1.set_title('Southern Hemisphere Known Meteorite Landings')
ax1.grid(visible=True, alpha=0.5)
ax1.set_xlabel('Longitude')
ax1.set_ylabel('Latitude')
ax1.legend(title='')
```
![Southern Hemisphere Known Meteorite Landings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvoa9s663vq13jwy9vlo.png)

## Find Out More
If you want to find out more about how I put this together (including seeing some fun exploratory visualizations) you can view the [GitHub Repository](https://github.com/fetterollie/meteorite-mania) for this project. Please feel free to drop a comment or reach out via [LinkedIn](https://www.linkedin.com/in/jonathanfetterolf/).