Skip to content

Create two Jupyter Notebooks: use API calls to determine weather conditions for 500 cities around the equator; use Geoapify API based on the weather analysis to plan future vacations.

Notifications You must be signed in to change notification settings

SteveTuttle/weather-analysis-vacation-destination

Repository files navigation

weather-analysis-vacation-destination

UNC DataBootCamp API module challenge

Challenge Description

Background

Data's true power is its ability to definitively answer questions. So, let's take what you've learned about Python requests, APIs, and JSON traversals to answer a fundamental question: "What is the weather like as we approach the equator?"

Now, we know what you may be thinking: “That’s obvious. It gets hotter.” But, if pressed for more information, how would you prove that?

from the UNC Bootcamp instructions for this challenge

Deliverables

This challenge is broken down into two parts, WeatherPY then VacationPY. I added my intials to the starter code version of both these files.

We will be working with Jupyter notebooks, using APIs from various sites to achieve this.

We will be using OpenWeatherMap for the API key as well as API call formatting examples.

The URL I generate for the city_day variable uses "units=imperial" because this would make the output measurements easier to interpret. Conversions applied where needed.

I am color-blind but I am well aware the importance color can bring to the audience. That said I could not tell what colors the plots were meant to be for the scatter plot charts so I used documentation from matplotlib.org color tables for color IDs. For the linear regression scatter plots my goal was to choose colors that were different from one another.

Part-1: WeatherPY

For this portion of the challenge, we must create a Python script to visualize the weather of over 500 cities of varying distances from the equator. We will be using the citipy Python library and the OpenWeatherMap API links to external websites. We will use WeatherPy.ipynb from the starter code, in a Jupyter notebook using a modified URL we generate along with the other pieces of code. The starter code acts as a guide through the process, providing only what the output should come to be. Note: as mentioned later in the instructions, the city data we generate is based on random coordinates and different query times, so our outputs will not be an exact match to the provided starter notebook. We then convert this city data into a pandas DataFrame, city_data_df , which will be used to plot the charts in Requirement-1 and Requirement-2 , we will also save this DataFrame over cities.csv in the output_data folder to be used later.

Requirement-1

To meet first requirement, we are to create plots that display the relationship between different weather variables and Latitude . We will use city_data_df to do this, along with the strftime function to convert the date from Unix to a more legible (Year-Month-Day) format in the title. We will also, export these charts as Fig1-4.png to the output_data folder, overwriting the original files.

The Scatter Plots will showcase the following relationships:

  • Latitude vs. Temperature
  • Latitude vs. Humidity
  • Latitude vs. Cloudiness
  • Latitude vs. Wind Speed

Requirement-2

To meet the second requirement, we are to compute the linear regression for each relationship in both Northern (Latitude >= 0) and Southern (Latitude < 0) Hemispheres. Along with this, we were tasked to define a function in order to generate the linear regression plots. In this case I chose to define two functions, one for both the Northern Hemisphere and Southern Hemisphere, this way the outputs could be displayed in different formatting for when/if the data is compared side by side. Along with the linear regression line, these scatter plots also need to include each models's formula (y = m x + b ) and the r value. I also chose to export these charts as linreg1-8.png to the output_data folder to provide quicker access if ever needed.

The Linear Regression Scatter Plots will showcase the following relationships:

  • Northern Hemisphere: Temperature vs. Latitude
  • Southern Hemisphere: Temperature vs. Latitude
  • Northern Hemisphere: Humidity vs. Latitude
  • Southern Hemisphere: Humidity vs. Latitude
  • Northern Hemisphere: Cloudiness vs. Latitude
  • Southern Hemisphere: Cloudiness vs. Latitude
  • Northern Hemisphere: Wind Speed vs. Latitude
  • Southern Hemisphere: Wind Speed vs. Latitude

linear regression chart example

lin-regress-plot

Part-2: VacationPY

In this deliverable, you'll use your weather data skills to plan future vacations.

Use the cities.csv created in Part-1: WeatherPy to provide the initial DataFrame ,city_data_df, for this portion of the challenge. From this DataFrame we create the first map and the remainder of the challenge will be completed in the following Steps :

  1. Create a map that displays a point for every city in the city_data_df DataFrame as shown in the following image (see example) . The size of the point should be the humidity in each city.

city data map example

city_data_df

  1. Narrow down the city_data_df DataFrame to find "our" ideal weather condition and save this as ideal_city_df . I chose to use the suggested conditions from the example, however my units were already Imperial, so I converted to the units to Imperial and wrote the code accordingly:
  • Max temperature < 81 degrees but > 70
  • Wind speed < 10
  • Zero cloudiness
  1. Create a new DataFrame called hotel_df using a copy of ideal_city_df , only using and reording the following columns: city, country, coordinates, and humidity. After this, add a Hotel Name column to the DataFrame.
  2. For each city, use the Geoapify API to find the first hotel located within 10,000 meters of your coordinates. The search and output here will populate the Hotel Name column in hotel_df .
  3. Create a final map for hotel_df . We are first going to clean up the data by only displaying results from the previous step that did NOT say "No hotel found" as new (final) DataFrame called hotel_found_df . Add the hotel name and the country as additional information in the hover message for each city on the map.

hotel map example

hotel_df

Resources

Bootcamp References

Module 6 Instructions

starter_code

  • WeatherPy.ipynb
  • VacationPY.ipynb

Example Data:

output_data (original folder)

  • cities.csv
  • Fig1.png
  • Fig2.png
  • Fig3.png
  • Fig4.png

Special Thanks:

  • Jamie Miller
  • Mounika Mamindla
  • Lisa Shemanciik

External References

(where possible will provide link to website)

This Challenge provided many opportunities to try and test new ideas.

About

Create two Jupyter Notebooks: use API calls to determine weather conditions for 500 cities around the equator; use Geoapify API based on the weather analysis to plan future vacations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published