# Mapping the precipitation impact of Hurricane Milton with raster data

<div align="left"><figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FhB2W9xXbzzo0kEuXMe3S%2Fintermediate%20banner.png?alt=media&#x26;token=4acd2cc7-c7e8-46c0-9669-6f6b73c030dd" alt="Intermediate difficulty banner" width="175"><figcaption></figcaption></figure></div>

## **Context**

In this tutorial, you'll learn how to visualize and analyze raster precipitation data from Hurricane Milton in CARTO. We’ll guide you through the preparation, upload, and styling of raster data, helping you extract meaningful insights from the hurricane’s impact.

Hurricane Milton was a Category 3 storm that made landfall on October 9, 2024. At its peak, it was the fifth-most intense Atlantic hurricane on record, causing a tornado outbreak, heavy precipitation, and strong winds.

By the end of this tutorial, you’ll create an **i**nteractive dashboard in CARTO Builder, combining raster precipitation data with Points of Interest (POIs) and hurricane track to assess the storm’s impact.

**In this guide, you'll learn to:**

1. [**Prepare Hurricane Milton raster dataset**](#prepare-hurrican-milton-raster-dataset)
2. [**Upload your raster data using CARTO Raster Loader**](#upload-your-raster-data-using-carto-raster-loader)
3. [**Analyze impact of Hurricane Milton precipitation on Points of Interest**](#analyze-impact-of-hurricane-milton-precipitation-on-points-of-interest)
4. [**Create an interactive dashboard to visualize the impact**](#create-an-interactive-dashboard-to-visualize-the-impact)

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fg2wezYQaaLKC4LfDBsgj%2Fimage.png?alt=media&#x26;token=c8f13683-2169-418b-b4e5-54c06920be67" alt=""><figcaption></figcaption></figure>

## Prepare Hurrican Milton raster dataset

Before analyzing the storm's impact, we need to set up the environment and prepare the precipitation raster dataset from PRISM, recorded on November 10, 2024. This dataset provides critical insights into rainfall distribution, helping us assess the storm's intensity and affected areas.

**Required raster data format**

Before uploading raster data to your data warehouse, ensure it meets the following requirements::

* Cloud Optimized GeoTiff (COG)
* Google Maps Tiling Schema

1. **Set up your Python environment**

To ensure a clean and controlled setup, use a **Python virtual environment** where we’ll execute the **data preparation and upload process**.

**Check Python Installation**

Ensure Python 3 is installed by running:

```bash
python3 --version
```

If not installed, download it from [Python.org](https://www.python.org/downloads/).

**Create and Activate a Virtual Environment**

Run the following command to create a **virtual environment** and activate it:

**For Linux/macOS:**

```bash
python3 -m venv carto_raster_env
source carto_raster_env/bin/activate
```

**For Windows:**

```bash
python3 -m venv carto_raster_env
carto_raster_env\Scripts\activate
```

2. **Install GDAL in the Virtual Environment**

GDAL is required to process raster data. However, if GDAL is not installed in your virtual environment, you may need to install it manually.

First, **install system dependencies**:

**On macOS (via Homebrew):**

```bash
brew install gdal
```

**On Ubuntu/Debian:**

```bash
sudo apt update && sudo apt install gdal-bin libgdal-dev
```

**On Windows:** If you're using **OSGeo4W**, install GDAL from there. Alternatively, you can use **conda**:

```bash
conda install -c conda-forge gdal
```

Now, install GDAL inside your virtual environment:

```bash
pip install GDAL
```

If GDAL fails to install inside the virtual environment, you might need to specify the correct version matching your system dependencies.

3. **Extract Metadata from the Precipitation Raster**

Once the environment is set up, download the **PRISM precipitation raster file** available in this [bucket](https://storage.googleapis.com/academy_data_sample/milton_hurricane/ppt_20241010.tif) and store it in the same project directory where your virtual environment is located.

Inspect the raster file’s metadata using GDAL:

```sh
gdalinfo usa_precipitation_10102024.tif
```

This command provides details such as:

* Projection and coordinate system
* Pixel resolution
* Band information
* NoData values (if any)

Understanding this metadata is crucial before performing reprojection, resampling, or further transformations.

4. **Convert GeoTIFF to Cloud Optimize GeoTIFF (COG)**&#x20;

To ensure compatibility with CARTO, convert the GeoTIFF into a Cloud Optimized GeoTIFF (COG) with Google Maps Tiling Schema:

```bash
gdalwarp -of COG \
-co TILING_SCHEME=GoogleMapsCompatible \
-co COMPRESS=DEFLATE \
-co OVERVIEWS=IGNORE_EXISTING \
-co ADD_ALPHA=NO \
-co RESAMPLING=NEAREST \
-co BLOCKSIZE=512 \
usa_precipitation_10102024.tif usa_precipitation_10102024_cog.tif

```

Your raster data is now ready for uploading to CARTO.

***

## Upload your raster data using CARTO Raster Loader

There're two options to upload your raster COG to your data warahouse:

* [Using import interface](#using-import-interface): Recommended for small files (<1GB) that **don’t require advanced settings**.
* [Using CARTO raster loader](#installation-of-raster-loader): Ideal for **larger files (>1GB)** or when you **need more control** (e.g., chunk size, compression).

### Using import interface

Navigate to **Data Explorer** → Click **"**&#x49;mport dat&#x61;**"** (top right). Upload your **COG raster file** and store it in *CARTO Data Warehouse > Shared Dataset* for compatibility with other demo datasets.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FJbfe1S2959FcZhR5sQyc%2Fimage.png?alt=media&#x26;token=6dcd4d51-5422-4c40-bea0-2def7c9273a1" alt=""><figcaption></figcaption></figure>

Once your raster has been successfully uploaded, you'll be able to inspect the raster source in the Map Preview as well as inspecting its metadata and details.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FWmpNnt3me1OTNDtQHkdb%2Fimage.png?alt=media&#x26;token=895e751d-2f02-4864-9d75-a7381bdbec21" alt=""><figcaption></figcaption></figure>

### Using CARTO raster loader <a href="#installation-of-raster-loader" id="installation-of-raster-loader"></a>

The [CARTO Raster Loader](https://raster-loader.readthedocs.io/en/latest/user_guide/cli.html#using-the-raster-loader-with-snowflake) is a Python utility that can import a COG raster file to Google BigQuery, Snowflake and Databricks as a CARTO raster table. In our case, we'll be importing data to BigQuery.

1. **Install CARTO Raster Loader**

The `raster-loader` library can be installed from `pip`; installing it in the virtual environment we created earlier.&#x20;

```
pip install raster-loader
```

2. **Authenticate to Google Cloud**

In order to create raster tables in BigQuery using Raster Loader, you will need to be authenticated in Google Cloud. Run this command:

```
gcloud auth application-default login
```

3. **Execute the uploading process to BigQuery**

The basic command to upload a COG to BigQuery as a CARTO raster table is:

```
carto bigquery upload \
  --file_path usa_precipitation_10102024_cog.tif \
  --project your_project \
  --dataset your_dataset \
  --table usa_precipitation_10102024_cog \
  --overwrite
```

Once the upload process has been successful, you'll be able to visualize and analyze it directly from CARTO.

***

## Analyze impact of Hurricane Milton precipitation on Points of Interest

We’ll use CARTO Workflows to analyze which POIs were impacted by extreme precipitation during Hurricane Milton.

1. Go to Workflows page, and select "*Create workflow*". Choose the **CARTO Data Warehouse  connection,** as we'll be working with sample data available there.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FRuxKf2w5tY34nd1EXJeU%2Fimage.png?alt=media&#x26;token=2148aed9-fb54-45a2-839f-787c2a0c4d9a" alt=""><figcaption></figcaption></figure>

2. To identify the impacted POIs we'll use the **Hurricane Milton Track** boundary. To import this dataset, use the **Import from URL** component including this [URL](https://storage.googleapis.com/academy_data_sample/milton_hurricane/hurricane_milton_track.csv) in the Source URL parameter.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FFxex0EG8pvjIf8b5IZYE%2Fimage.png?alt=media&#x26;token=ee452fe0-886c-4233-9136-71fe1aa194b1" alt=""><figcaption></figcaption></figure>

3. Now, let's add **OSM POIs for the USA**, available in *`CARTO Data Warehouse > demo_tables > osm_pois_usa`* from the Sources panel by dragging the source into the canvas.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FeGJXhayX0HPteTzujxZ8%2Fimage.png?alt=media&#x26;token=7fa5b45d-db21-48d5-943d-1c53d1bfa41f" alt=""><figcaption></figcaption></figure>

4. Set a name for your Workflows, we'll call it "Analyzing Hurricane Milton impact".&#x20;
5. Now, we want to identify the POIs that fall within the Hurricane Milton track on the 10th of November, 2024. To do so, we'll use the **Spatial Filter** component using the "Intersects" method. When configured, click "Run".

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FLXRmbJQHA5sJEeLZFqgk%2Fimage.png?alt=media&#x26;token=1441b145-9f70-46f5-b0a2-77f69b6e1481" alt=""><figcaption></figcaption></figure>

CARTO Workflows contains **Raster components** to perform analysis between vector and raster sources. In our case, we're interested on retrieving the precipitation values from our raster source to enrich the POIs dataset. To do so, we want to convert first our points to polygons so we can use the Extract and aggregate raster component.

6. Using the **ST Buffer** component, set a buffer of around `10 meters` from the POIs point location.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fo2jtMN8xVAwXahxDrWj9%2Fimage.png?alt=media&#x26;token=ce31c7f8-1eb3-4163-bb51-72af05f9e5e5" alt=""><figcaption></figcaption></figure>

6. Now, let's add our raster source into the canvas, that should be saved in the Shared folder of our CARTO Data Warehouse. You can use the **Map Preview** to visualize the raster data in Workflows.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FajlmCFcFOULJqR805CDr%2Fimage.png?alt=media&#x26;token=6afa9340-519f-41a2-9db9-d2d355bf5796" alt=""><figcaption></figcaption></figure>

6. Add the **Extract and aggregate raster** Component and connect both the buffered POIs and the raster precipitation source. Set the aggregated `band_1` with the operation `AVG`, and use the `osm_id` as the column to group by. This will ensure that every POI is enriched with the raster avg precipitation on the intersecting pixel.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FWYJreHp8Zz20w7O5S1gR%2Fimage.png?alt=media&#x26;token=ab84acf3-f09f-433a-8dd1-b2c8f6ddb414" alt=""><figcaption></figcaption></figure>

7. As we want the enriched POIs for visualization purpose, we'll need to join these stats back with the original OSM spatial column. To do so, we'll first use the **SELECT** component to retrieve just the spatial column and the identifier from the original source.

```
SELECT osm_id, geom
```

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FZPPBMInMGZklHGZB0F7n%2Fimage.png?alt=media&#x26;token=6976d53a-f009-458a-a5af-1752651da1ed" alt=""><figcaption></figcaption></figure>

8. Now, use the **JOIN** component to add the spatial column into our enriched POIs using the `osm_id` in both sources and the `Left` method.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FMhyrUanyF31NEcOCAiJ7%2Fimage.png?alt=media&#x26;token=538ab734-187d-4ba5-a09a-13c264d764f2" alt=""><figcaption></figcaption></figure>

8. Finally, we'll save the resulting outputs that we want to use in Builder as tables. For that, add one **Save as table** component for the Hurricane Milton track and another one for the enriched POIs, saving both in *`CARTO Data Warehouse > Shared`*.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FBt7tTJvlYwtX41ZF4H4B%2Fimage.png?alt=media&#x26;token=4146006c-45b9-4199-bf37-c413c27622bb" alt=""><figcaption></figcaption></figure>

Once you're buildings have been enriched by the avg precipitation from Hurrican Milton, we're able to visualize the impact using CARTO Builder, our map making tool where you can easily create interactive dashboards visualizing both vector and raster sources.

***

## Create an interactive dashboard to visualize the impact

1. Go to maps, and click on "Create a map" option.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FeIwk7c8WFstcy4tWboV4%2Fimage.png?alt=media&#x26;token=2c47b8d3-9c89-4283-a868-451c6993e49b" alt=""><figcaption></figcaption></figure>

2. A Builder map opens in a new tab. Rename the Builder map "Analyzing Hurricane Milton impact".
3. Using the "Add sources from" button, load the enriched POIs, the Hurricane Milton track and the raster precipitation sources into the map:

* *CARTO Data Warehouse > Shared > hurricane\_milton\_pois*
* *CARTO Data Warehouse > Shared > hurricane\_milton\_track*
* *CARTO Data Warehouse > Shared > usa\_precipitation\_101024*

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FPa4ReEaZYmud01RG7wW7%2Fimage.png?alt=media&#x26;token=7eb0e79f-0ae0-47d9-9f80-588d67106a21" alt=""><figcaption></figcaption></figure>

4. Rename the layers to the following, ensuring they keep the below order from top to bottom:

a. POIs (hurricane\_milton\_pois)

b. Hurricane Milton track (hurricane\_milton\_track)

c. Precipitation (usa\_precipitation\_10102024)

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fs2wygMJDsgEX3QlRQO5R%2Fimage.png?alt=media&#x26;token=eadd6348-2bcd-4482-b0f8-68c6030b5bff" alt=""><figcaption></figcaption></figure>

5. Let's **style the layers** following the below configuration:

**POIs Layer:**

* Visualization:&#x20;
  * Zoom visibility: `from 5 to 21`
* Simbol:
  * Radius:
    * Fixed: `3 px`
* Fill color:
  * Colored by band\_1\_avg
  * Palette: `4 Steps` using `ColorBrewer PuBu-4`
  * Color scale: `Quantile`
* Stroke&#x20;
  * Stroke color:
    * Simple: `#0d1b33`
  * Stroke width:
    * Fixed: `0.5 px`

**Hurricane Milton track Layer:**

* Fill color:
  * Simple: `#c1d2f9`
  * Opacity: `1%`
* Stroke color:
  * Simple: `#2168d8`
  * Stroke width:
    * Fixed: `3.7 px`

**Precipitation:**

* Layer opacity: `10%`
* Palette: `7 Steps` and `SunsetDark @CARTOColors`

Your map layers should look similar to this:&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F858Wig867htOkAqAZFgy%2Fimage.png?alt=media&#x26;token=dd21c081-13c9-436f-8c7a-02e9ba03b1eb" alt=""><figcaption></figcaption></figure>

6. Now let's add some [**Widgets**](https://academy.carto.com/building-interactive-maps/widgets-and-sql-parameters) linked to the POIs to allow users retreiving insights. We'll add the following widgets:

**Formula widget**

* Title: `Affected POIs`
* Operation: `COUNT`
* Format: `12.3k`

**Histogram Widget**

* Title: `POIs distribution by Avg Precipitation`
* Property: `band_1_avg`
* Format: `12.3`

**Category Widget 1**

* Title: `POIs by Max Precipitation`
* Operation: `MAX`
* Group by property: `name`
* Aggregation column: `band_1_avg`

**Table Widget:**

* Title: `Table View`
* Properties:
  * `osm_id` as `Id`
  * `name` as `Name`
  * `group_name` as `Group name`
  * `subgroup_name` as `Subgroup name`
  * `band_1_avg` as `Avg Precipitation`

Your map should look similar to this:

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FrYJyEJWwMvAb0DrdN7zG%2Fimage.png?alt=media&#x26;token=8169da87-9376-4db8-a1b7-4263f49b4c07" alt=""><figcaption></figcaption></figure>

7. Now, we'll enable **Interactions** by adding properties to both the POIs and raster layers so users can retrieving insights by clicking on the map.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FEKWQSm7bCw5UQoGs3XHx%2Fimage.png?alt=media&#x26;token=f9739395-d87e-4ad2-9e76-66eaede0e1d6" alt=""><figcaption></figcaption></figure>

7. Customize the **Legend** by setting the right label for your properties.
8. Access the **Map settings for viewers** and activate the tools you want end-users to access.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FIzdR0y5wmzx81C6nBwYw%2Fimage.png?alt=media&#x26;token=7e3701f8-c720-41c0-babc-16a503641921" alt=""><figcaption></figcaption></figure>

7. Then, go to **Preview mode** and check that the map looks as desired. Once your map is ready, you can share it with specific users, SSO groups or the entire organization.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F7iISYKh5DTFl2RWb17tW%2Fimage.png?alt=media&#x26;token=0f34d350-8385-4d95-9bee-4ed97451f145" alt=""><figcaption></figcaption></figure>

Congrats, you're done! Your map should look similar to this:

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FOjiBaOr1MLwQvhMZb6Ur%2Fimage.png?alt=media&#x26;token=a2906733-56db-44a0-88f9-358b1e7685e4" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://academy.carto.com/building-interactive-maps/data-visualization/mapping-the-precipitation-impact-of-hurricane-milton-with-raster-data.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
