Mapping the precipitation impact of Hurricane Milton with raster data
Last updated
Was this helpful?
Last updated
Was this helpful?
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 interactive 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:
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
EPSG:4326
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:
If not installed, download it from Python.org.
Create and Activate a Virtual Environment
Run the following command to create a virtual environment and activate it:
For Linux/macOS:
For Windows:
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):
On Ubuntu/Debian:
On Windows: If you're using OSGeo4W, install GDAL from there. Alternatively, you can use conda:
Now, install GDAL inside your virtual environment:
If GDAL fails to install inside the virtual environment, you might need to specify the correct version matching your system dependencies.
Extract Metadata from the Precipitation Raster
Once the environment is set up, download the PRISM precipitation raster file available in this bucket and store it in the same project directory where your virtual environment is located.
Inspect the raster file’s metadata using GDAL:
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.
Convert GeoTIFF to Cloud Optimize GeoTIFF (COG)
To ensure compatibility with CARTO, convert the GeoTIFF into a Cloud Optimized GeoTIFF (COG) with Google Maps Tiling Schema:
Your raster data is now ready for uploading to CARTO.
There're two options to upload your raster COG to your data warahouse:
Using import interface: Recommended for small files (<1GB) that don’t require advanced settings.
Using CARTO raster loader: Ideal for larger files (>1GB) or when you need more control (e.g., chunk size, compression).
Navigate to Data Explorer → Click "Import data" (top right). Upload your COG raster file and store it in CARTO Data Warehouse > Shared Dataset for compatibility with other demo datasets.
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.
The CARTO Raster Loader is a Python utility that can import a COG raster file to Google BigQuery and Snowflake as a CARTO raster table. In our case, we'll be importing data to BigQuery.
Install CARTO Raster Loader
The raster-loader
library can be installed from pip
; installing it in the virtual environment we created earlier.
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:
Execute the uploading process to BigQuery
The basic command to upload a COG to BigQuery as a CARTO raster table is:
Once the upload process has been successful, you'll be able to visualize and analyze it directly from CARTO.
We’ll use CARTO Workflows to analyze which POIs were impacted by extreme precipitation during Hurricane Milton.
Go to Workflows page, and select "Create workflow". Choose the CARTO Data Warehouse connection, as we'll be working with sample data available there.
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 in the Source URL parameter.
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.
Set a name for your Workflows, we'll call it "Analyzing Hurricane Milton impact".
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".
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.
Using the ST Buffer component, set a buffer of around 10 meters
from the POIs point location.
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.
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.
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.
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.
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
.
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.
Go to maps, and click on "Create a map" option.
A Builder map opens in a new tab. Rename the Builder map "Analyzing Hurricane Milton impact".
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
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)
Let's style the layers following the below configuration:
POIs Layer:
Visualization:
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
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:
Now let's add some Widgets 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:
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.
Customize the Legend by setting the right label for your properties.
Access the Map settings for viewers and activate the tools you want end-users to access.
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.
Congrats, you're done! Your map should look similar to this: