Skip to content

Utilizes API calls from OpenWeatherMap and Google using python, jupyter notebook, gmaps, and matplotlib to analyze weather data in relation to the equator and plot cities on a map.

Notifications You must be signed in to change notification settings

lisb020/python-api-challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

python-api-challenge

Project Description

The goal of this project is to visulaize and analyze weather data versus location in the world to determine if the location correlates with temperature, humidity, cloudiness, or wind speed. The second part of the project places the humidity data on a heatmap and plots the location of hotels near certain cities uing the google API and gmaps. This project uses Python, Jupyter notebook, and the following libraries: pandas, requests, Matplotlib, os, numpy, time, scipy, datetime, and gmaps. You will need to acquire an OpenWeatherMap API and a Google API.

Part I - WeatherPy

Created a Python script to visualize the weather of 500+ random cities across the world of varying distance from the equator. Utilized a Python city library, and the OpenWeatherMap API to create a representative model of weather across world cities.

Ran linear regression on each relationship and then separated the plots into Northern Hemisphere (greater than or equal to 0 degrees latitude) and Southern Hemisphere (less than 0 degrees latitude):

  • Northern Hemisphere - Temperature (F) vs. Latitude

screenshot

  • Southern Hemisphere - Temperature (F) vs. Latitude

screenshot

  • Northern Hemisphere - Humidity (%) vs. Latitude

screenshot

  • Southern Hemisphere - Humidity (%) vs. Latitude

screenshot

  • Northern Hemisphere - Cloudiness (%) vs. Latitude

screenshot

  • Southern Hemisphere - Cloudiness (%) vs. Latitude

screenshot

  • Northern Hemisphere - Wind Speed (mph) vs. Latitude

screenshot

  • Southern Hemisphere - Wind Speed (mph) vs. Latitude

screenshot

The notebook:

  • Randomly selects at least 500 unique (non-repeat) cities based on latitude and longitude.
  • Performs a weather check on each of the cities using a series of successive API calls.
  • Includes a print log of each city as it's being processed with the city number and city name.
  • Saves a CSV of all retrieved data and a PNG image for each scatter plot.

Conclusion

  • As the latitude moves away from the equator, the max temperature decreases and more drastically in the northern hemisphere. The highest max temperatures are at 0 latitude/equator. The regression is not linear but does become linear when the northern and southern hemispheres are split up. The r2 value in the northern hemisphere of 0.76 demonstrates the strong correlation between latitude and max temperature in the northern hemisphere. The southern hemisphere does not correlate as well with an r2 value of 0.31. NOTE: the r2 values will change every time the notebook is ran because it is pulling in 500 random cities every time.
  • The humidity does not correlate with latitude. The linear regression with the low r2 value (0.14 and 0.03) for the northern and southern hemisphere demonstrate the low correlation.
  • The cloudiness does not correlate with latitude. The linear regression with the low r2 value (0.07 and 0.22) for the northern and southern hemisphere demonstrate the low correlation.
  • The wind speed does not correlate with latitude. The linear regression with the low r2 value (0.01 and 0.08) for the northern and southern hemisphere demonstrate the low correlation.

Part II - VacationPy

Uses jupyter-gmaps and the Google Places API.

  • Created a heat map that displays the humidity for every city from Part I.

  • Narrows down the DataFrame to the following weather conditions:

    • A max temperature lower than 80 degrees but higher than 70.

    • Wind speed less than 10 mph.

    • Zero cloudiness.

  • Uses Google Places API to find the first hotel for each city located within 5000 meters of the coordinates.

  • Plots the hotels on top of the humidity heatmap with each pin containing the Hotel Name, City, and Country.

screenshot

Libraries Required

File Description

WeatherPy

  • Contains the first part of the project

WeatherPy.ipynb

  • Contains the code in a jupyter notebook file that analyzes the weather vs locations for 500+ cities.

output_data

  • This folder contains a csv file (cities.csv) that is outputted by the WeatherPy.ipynb jupyter notebook file. This file contains the cities with their latitude and longitude, temperature, humidity, cloudiness, wind speed, country, and date.

Images

  • This folder contains all the screen shots that are created from the jupyter notebook file.

VacationPy

  • Contains the second part of the project

VacationPy.ipynb

  • Contains the code in a jupyter notebook file that plots hotels near cities using gmaps.

Images

  • This folder contains the screen shot of the map created from the jupyter notebook file.

About

Utilizes API calls from OpenWeatherMap and Google using python, jupyter notebook, gmaps, and matplotlib to analyze weather data in relation to the equator and plot cities on a map.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published