Skip to content

Using Jupyter Notebook, Pandas Library, CityPy, Python, APIs and JSON Traversals, to get more than 500 random latitudes and longitudes and analyze weather data

Notifications You must be signed in to change notification settings

DougUOT/World_Weather_Analysis

Repository files navigation

World_Weather_Analysis

Using Jupyter Notebook, Pandas Library, CityPy, Python, APIs and JSON Traversals, to get more than 500 random cities around the world in order to show the relationship between Latitude and an assortment of weather parameters

Overview of Project

Mytrip is a top travel technology company specializing in internet-related services in the hotel and lodging industry. We will gather and present information for clients through the pursuit page; the customer will filter based on their preferred travel criteria to find their hotel anyplace on the planet. We will utilize a Jupiter notebook and the CityPI module to play out this undertaking to get random cities and latitudes. We will use the Matplotlib to create a series of scatter plots to show the relationship between the latitude and various weather parameters for over 500 cities. This data will help the company to predict the best time of year for customers to plan their vacation

Follow below the goals for this project:

  1. Objective 1: Retrieve Weather Data
  2. Objective 2: Deliverable 2: Create a Customer Travel Destinations Map
  3. Objective 3: Create a Travel Itinerary Map

Resources

Basic Project Plan

Here is a blueprint of the primary project plan:

  • Task: Collect and analyze weather data across cities worldwide.
  • Purpose: PlanMyTrip will use the data to recommend ideal hotels based on clients' weather preferences.
  • Method: Create a Pandas DataFrame with 500 or more of the world's unique cities and their weather data in real-time. This process will entail collecting, analyzing, and visualizing the data.

The data analysis will be parsed into three principal parts or stages:

1.1. Collect the Data

  • Use the NumPy module to generate more than 1,500 random latitudes and longitudes.
  • Use the citipy module to list the nearest city to the latitudes and longitudes.
  • Use the OpenWeatherMap API to request the current weather data from each unique city in the list.
  • Parse the JSON data from the API request.
  • Collect the following data from the JSON file and add it to a DataFrame:
    • City, country, and date
    • Latitude and longitude
    • Maximum temperature
    • Humidity
    • Cloudiness
    • Wind speed

2.1 Exploratory Analysis with Visualization

  • Create scatter plots of the weather data for the following comparisons:

    • Latitude versus temperature
    • Latitude versus humidity
    • Latitude versus cloudiness
    • Latitude versus wind speed
  • Determine the correlations for the following weather data:

    • Latitude and temperature
    • Latitude and humidity
    • Latitude and cloudiness
    • Latitude and wind speed
  • Create a series of heatmaps using the Google Maps and Places API that showcases the following:

    • Latitude and temperature
    • Latitude and humidity
    • Latitude and cloudiness
    • Latitude and wind speed

3.1 Visualize Travel Data

Create a heatmap with pop-up markers to display information on specific cities based on a customer's travel preferences. Complete these steps:

  • Filter the Pandas DataFrame based on user inputs for a minimum and maximum temperature.
  • Create a heatmap for the new DataFrame.
  • Find a hotel from the cities' coordinates using Google's Maps and Places API, and the Search Nearby feature.
  • Store the name of the first hotel in the DataFrame.
  • Add pop-up markers to the heatmap that display information about the city, current maximum temperature, and a hotel in the city.

Results & Code

1) Objective 1: Retrieve Weather Data

1.1. Collect the Data

  • Use the NumPy module to generate more than 1,500 random latitudes and longitudes.
  • Use the citipy module to list the nearest city to the latitudes and longitudes.
  • Use the OpenWeatherMap API to request the current weather data from each unique city in your list.
  • Parse the JSON data from the API request.
  • Collect the following data from the JSON file and add it to a DataFrame:
    • City, country, and date
    • Latitude and longitude
    • Maximum temperature
    • Humidity
    • Cloudiness
    • Wind speed

Retrieve Data

Data retrieving and skipping city that was not found

Creating a Panda DataFrame with weather parameters by city and latitudes

2) Objective 2: Deliverable 2: Create a Customer Travel Destinations Map

2.1 Exploratory Analysis with Visualization

* Create the scatter plots of the weather data for the following comparisons:
  • Latitude versus temperature

  • Latitude versus humidity

  • Latitude versus cloudiness

  • Latitude versus wind speed

* Determine the correlations for the following weather data:

We use the geographic coordinate system (GCS) to reference any point on Earth by its latitude and longitude coordinates. All latitude lines above the equator are considered as a Northern Hemisphere. All latitude lines below the equator are considered as Southern Hemisphere. We used Linear Regression to Find the Relationship Between Variables or weather parameters.

  • Latitude and temperature

Northern Hemisphere for Max Temp

Southern Hemisphere for Max Temp

  • Latitude and humidity

Northern Hemisphere for Humidity

Southern Hemisphere for Humidity

  • Latitude and cloudiness

Northern Hemisphere for Cloudiness

Southern Hemisphere for Cloudiness

  • Latitude and wind speed

Northern Hemisphere for Wind Speed

Southern Hemisphere for Wind Speed

* Create a series of heatmaps using the Google Maps and Places API that showcases the following:
  • Latitude and temperature

  • Latitude and humidity

  • Latitude and cloudiness

  • Latitude and wind speed

3) Objective 3: Create a Travel Itinerary Map

3.1 Visualize Travel Data

Create a heatmap with pop-up markers to display information on specific cities based on a customer's travel preferences. Complete these steps:

  • Filter the Pandas DataFrame based on user inputs for a minimum and maximum temperature.
  • Create a heatmap for the new DataFrame.

  • Find a hotel from the cities' coordinates using Google's Maps and Places API, and the Search Nearby feature.

  • Store the name of the first hotel in the DataFrame.

  • Add pop-up markers to the heatmap that display information about the city, current maximum temperature, and a hotel in the city.

Heatmap of temperatures for the vacations spots

Heatmap of temperatures for the vacations spots with pop-up markers for each city, with hotel name, city, country and Max temp.

3.2 Create a Travel Itinerary Map

Creating a vacation itinerary to travel between four cities. The country selected was Brazil. The cities selected were Rio de Janeiro, Vila Velha, Ilheus and Jardim.

Adding information on the markers on map, such as city name, the country code, the weather description and maximum temperature for the city

Follow below the Itinerary map and route between the four cities mentioned above. The route starts in Rio de Janeiro and finishes and the same town. The letter A is related to the start point, and the letter E is the endpoint on the markers. The second waypoint in Vila Velha represents the travel map as the letter B. The third waypoint is Ilheus or letter C. The last waypoint in Jardim is the letter D. After the last way stop, the route continues until Rio de Janeiro, at the same start point as mentioned above.

Follow below the map, with information on the markers, such as city name, the country code, the weather description and maximum temperature for the city

Limitations

Related to section 3.2 Create a Travel Itinerary Map, due to the zoom and scale of the map used in this project (file: WeatherPy_travel_map.PNG), the letter E overlaps with the letter A. Applying the zoom on the map will make it possible to confirm that both letters are at the same point; this is because the starting point and the endpoint on the route refer to the same city, Rio de Janeiro.

About

Using Jupyter Notebook, Pandas Library, CityPy, Python, APIs and JSON Traversals, to get more than 500 random latitudes and longitudes and analyze weather data

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages