# Assessing the damages of La Palma Volcano

## **Context**

<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>

Since 11 September 2021, a swarm of seismic activity had been ongoing in the southern part of the Spanish Canary Island of La Palma (Cumbre Vieja region). The increasing frequency, magnitude, and shallowness of the seismic events were an indication of a pending volcanic eruption; which occurred on 16th September, leading to evacuation of people living in the vicinity.

In this tutorial we are going to assess the number of buildings and population that may get affected by the lava flow and its deposits. We’ll also estimate the value of damaged residential properties affected by the volcano eruption.

## **Step-by-Step Guide:**

1. Access the *Data Explorer* section from your CARTO Workspace using the navigation menu.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fkqo1WMxBvKRrch38ThSN%2Fimage.png?alt=media&#x26;token=0cf7034c-1d42-4708-9827-a76cc9680d02" alt=""><figcaption></figcaption></figure>

2. In the Data Explorer page, navigate to CARTO Data Warehouse > demo\_data > demo\_table.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FOH359IaCnQMXk6PaYmrQ%2Fimage.png?alt=media&#x26;token=fd11acb0-af6e-4be6-a5ea-46eb7d5d14f7" alt=""><figcaption></figcaption></figure>

In this tutorial, we are going to use the following 3 tables:

* `lapalma_buildings`: it contains the buildings in La Palma as obtained from the Spanish cadaster website;
* `lapalma_sociodemo_parcels`: it contains a sample from Unica360’s dataset in the Data Observatory “Cadaster and Sociodemographics (Parcel)”;
* `lapalma_volcano_lavaflow`: it includes the lava flow from the Volcano eruption in La Palma, Spain as measured by the Copernicus satellite on 10/04/2021.

3. Spend some time exploring the three tables in the Data Explorer.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fx5AOqEYqpdvLDimsHPCC%2Fbristol7.gif?alt=media&#x26;token=ae8eea5b-2c20-4e14-9620-f75d5f090653" alt=""><figcaption></figcaption></figure>

4. Select `lapalma_buildings` and click on "*Create map"* button on the top.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FMEkaih62zcJ6IW0YgH4u%2Fimage.png?alt=media&#x26;token=a079f74a-0fad-4d13-9287-b4a3df4c613d" alt=""><figcaption></figcaption></figure>

This will open CARTO Builder with this table added as a layer to a map.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FGBfOYc3Yq8JipHa3pP2G%2Fimage.png?alt=media&#x26;token=4d656199-f5a4-4961-bbb2-543259f4335d" alt=""><figcaption></figcaption></figure>

5. Rename the layer to “La Palma Buildings” and the map title to "Assessing the damages of La Palma Volcano"

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FxDZjQ6LgwZXnfp4OHnpP%2Fimage.png?alt=media&#x26;token=c8b999f6-8294-46a6-a3bc-19ddaa1c50a4" alt=""><figcaption></figcaption></figure>

6. Click on the layer to access the layer panel. In this section, you can style the layer according to your preferences. We have set the **Fill Color** to `purple`, reduce the opacity to `0,1`. Then, we have set the **Stroke Color** to `dark blue`.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F24DiKZj0HGjY6klt6ytE%2Fimage.png?alt=media&#x26;token=3d7e121d-e1f6-4f69-a8e0-5895bfe8249d" alt=""><figcaption></figcaption></figure>

7. Let's add the `lapalma_sociodemo_parcels` source. To do so, follow the below steps:
   * Select the A*dd source from* button at the bottom left on the page.&#x20;
   * Click on the *Data Explorer* option.
   * Navigate to CARTO Data Warehouse > demo\_data > demo\_tables. Search for `lapalma_sociodemo_parcels`. Once you find it, select it and click on "Add Source".

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FOhGGF2y1Lb7yo6YKhUoh%2Fimage.png?alt=media&#x26;token=7f2918f4-ed4d-4727-820c-928cb673dc8d" alt=""><figcaption></figcaption></figure>

8. Once added, a new layer appears on the map. Rename it to "La Palma demographics".

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F2XMHf1QjCiHf4mcaHgcv%2Fimage.png?alt=media&#x26;token=62ca5359-ec31-4484-b330-5c95e960699e" alt=""><figcaption></figcaption></figure>

9. We'll now change the style of *La Palma demographics* layer. Access the layer panel and set the **Fill Color** to `green` and the **Outline** color to `black`. Also reduce the **Stroke width** to `1`. Then, style the size of the points based on the population living in the parcel. To do so, select `p_t` column in the **Radius** section and set the range from `2 to 25`.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FpGS60Imi4SZdApmjN7hQ%2Fimage.png?alt=media&#x26;token=ffee4e5f-d6ef-4f86-8789-17538dd49dfd" alt=""><figcaption></figcaption></figure>

Now, we are looking to analyse the number of buildings, their estimated values for residential properties and total population affected by the volcano lava extent. To perform this analysis, we'll use Workflows. &#x20;

10. Go back to the *Workspace* tab in your browser and access *Workflows*.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FC7jF41inzg0ix0MQT4KY%2Fimage.png?alt=media&#x26;token=689eccd8-f710-467a-b9e4-54548dd95514" alt=""><figcaption></figcaption></figure>

11. In *Workflows* page, use the "*New workflow*" button to start a new Workflow. Select **CARTO Data warehouse** as the connection you want to work with.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F84yaG4bgSxy8kE5j7dkY%2Fimage.png?alt=media&#x26;token=8bf6422e-4fd2-422a-b098-ffd3ecef28cc" alt=""><figcaption></figcaption></figure>

12. From the Sources panel located on the left side, navigate to *CARTO Data Warehouse > demo\_data > demo\_tables* and locate `lapalma_volcano_lavaflow`. Drag and drop the source table into the canvas.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FuhhtvJOylFIrQdPGGkdA%2Fpalma1.gif?alt=media&#x26;token=8ed31657-4189-44af-956d-84f0254ea377" alt=""><figcaption></figcaption></figure>

13. Repeat *Step 13* to add `lapalma_buildings` into the canvas.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FrAWgxXRw1q9Wruu1rJbg%2Fimage.png?alt=media&#x26;token=25fa4b85-2ae2-4b5f-b1d5-27c237e39d5a" alt=""><figcaption></figcaption></figure>

14. Now, use **Enrich Polygons** component to obtain the total of estimated property value of those residential properties affected by the lava flow as well as the total number of buildings affected.  Connect `lapalma_volcano_lavaflow` as the *target polygon* and `lapalma_buildings` as the *source*. In the Variables section, in the node, add `SUM` for `estimated_prop_value` column and `COUNT` aggregation for `numberOfBuildingUnits` column. The output result is the lava flow source with the addition of the two new properties.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FdRmL8kRkbVlFagV4kH4p%2Fimage.png?alt=media&#x26;token=487304b5-3670-4290-8081-5a01e092afd8" alt=""><figcaption></figcaption></figure>

15. Add `lapalma_sociodemo_parcels` source to the canvas.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FXZLzCsRfOZND3eoOhCmp%2Fimage.png?alt=media&#x26;token=fe48d250-02c9-42a9-be82-63618aabb56a" alt=""><figcaption></figcaption></figure>

15. To obtain the total population affected by the lava flow extent, we will add the **Enrich Polygons** again. This time, we'll link `lapalma_volcano_lavaflow` as the target and `lapalma_sociodemo_parcels` as the source. Then, in the Variables section add `SUM` of `p_t` column.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FxBVbuYQ9g3fGFDMLWKbs%2Fimage.png?alt=media&#x26;token=466a2b19-1bc8-49ff-8456-b55526f2d397" alt=""><figcaption></figcaption></figure>

16. Using the **Join** component, we'll join both Enriched Polygons output in a single table using the geoid as the common column. To achieve that, add the Join component to the canvas, use `geoid` as the common column for both sources and select `Inner` as the join type.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F1WhLR4u7vgrN0oVLLKKH%2Fimage.png?alt=media&#x26;token=5a7b488c-7813-40e2-8be1-1dcf18209f11" alt=""><figcaption></figcaption></figure>

17. Save the output result as a new table using the **Save as Table** component. Set the destination to *Organization > Private* of your CARTO Data Warehouse and rename the output table to `lapalma_volcano_lavaflow_enriched`. Then, click on "Run".

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FB1dZ3w3tmMGUPnOTPYgm%2Fimage.png?alt=media&#x26;token=44ab8e0e-7848-4f05-b5e5-21b86e8778c0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FXs2NORFDC7nsXptt54Ib%2Fimage.png?alt=media&#x26;token=cca8842e-d5db-4017-b1cb-12928e0a9425" alt="" width="375"><figcaption></figcaption></figure>

17. Now, in the same Workflow, let's perform another analysis. This time, we are going to create a 500 meter buffer around the lava flow, and perform the same aggregations as we have done on *Step 14* and *Step 15* to compute the total number of buildings and the estimated damaged value of the residential properties within this larger region. To do so, add the **Buffer** component and link it to `lapalma_volcano_lavaflow` source. Set the distance to `500` meters. Then, click on "Run".&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FM6EteountZ9S3pXafQSp%2Fimage.png?alt=media&#x26;token=d86f6db6-26b0-423e-9abb-8e03170da758" alt=""><figcaption></figcaption></figure>

16. Afterwards, we'll add **Enrich Polygons** component, this time connecting the Buffer output as the target source. In the source input we'll connect `lapalma_buildings` source. Add the same aggregated variables: `SUM` for `estimated_prop_values` and `COUNT` for `numberOfBuildingUnits`. You can review the output in the Data Preview.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F1uP1IzUzdmGeTAFESjZ5%2Fimage.png?alt=media&#x26;token=77a0bc70-577a-4d75-b642-5ecac32dc252" alt=""><figcaption></figcaption></figure>

17. Let's add **Enrich Polygons** component again, this time to enrich the buffered output of La Palma lava flow with La Palma sociodemographics. In the Variable section of the Enrich Polygons component, add `SUM` for `p_t` to obtain the population affected by this buffered extent.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FGEJsdIlAQundr0FmlVkm%2Fimage.png?alt=media&#x26;token=746df2cb-c32c-4459-9d4f-d548e2bb99c5" alt=""><figcaption></figcaption></figure>

18. We'll add the **Join** component to join the output from both Enrich Polygons components. In the Join node, select `geoid` as the common column from both inputs and set the Join type to `Inner`.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FunqQrnZ2Vmm7YqyNkw7O%2Fimage.png?alt=media&#x26;token=087c8741-f777-4323-ad2b-94d842963f66" alt=""><figcaption></figcaption></figure>

19. Use the **Select** component to keep just the necessary columns using the below statement:&#x20;

```sql
geoid,
geom_buffer as geom, 
estimated_prop_value_sum,
numberOfBuildingUnits_count,
p_t_sum_joined
```

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FH2TdvvEgtw5y9XpDAtn2%2Fimage.png?alt=media&#x26;token=515ac28c-e228-47d1-9718-4a42528cd07b" alt=""><figcaption></figcaption></figure>

20. Finally, save the results as a table using the **Save as Table** component. Navigate to *CARTO Data Warehouse > organization > private* and save your table as `lapalma_volcano_lavaflow_enriched_buffer`.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fw5nucvBPmA4Cpb48rD5R%2Fimage.png?alt=media&#x26;token=306188a6-407e-4dbb-80ce-e06b9ca8e568" alt=""><figcaption></figcaption></figure>

20. Now let's go back to Builder. We'll first add `lapalma_volcano_lavaflow_enriched` as a table data source following the below steps:
    * Access *Add source from..*&#x20;
    * Click on the *Data Explorer* option.
    * Navigate to *CARTO Data Warehouse > organization > private*. Search for `lapalma_volcano_lavaflow_enriched`. Once you find it, select it and click on "Add Source".

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FMXX3m6DhVJmQ03L1RHmt%2Fimage.png?alt=media&#x26;token=00006a42-3acd-4f29-b4bb-869bae9a4bee" alt=""><figcaption></figcaption></figure>

21. A new layer is added to the map. Rename it to "Lava flow" and move it to the bottom, just below *La palma buildings* layer.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F4OdK7V53O8SUQchXP35x%2Fimage.png?alt=media&#x26;token=0106755f-86c6-4552-be6a-5cf83752e696" alt=""><figcaption></figcaption></figure>

22. Access *Lava flow* layer panel and set the **Fill Color** in the layer styling to `light red`.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FSjlzAg5HwEmvwT9iRwsj%2Fimage.png?alt=media&#x26;token=0541746a-8000-4eeb-98d1-d364fea10ef2" alt=""><figcaption></figcaption></figure>

23. Now let's add the enriched lava flow which was buffered by 500 meters. To do so, follow&#x20;

    &#x20;these steps:

    * Access *Add source from..*&#x20;
    * Click on the *Data Explorer* option.
    * Navigate to *CARTO Data Warehouse > organization > private*. Search for `lapalma_volcano_lavaflow_enriched_buffer`. Once you find it, select it and click on "Add Source".

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2F0xkgTKodsE5K7BcUD6FC%2Fimage.png?alt=media&#x26;token=6ce4f358-8ee1-4e1c-a9fb-2a03d108d623" alt=""><figcaption></figcaption></figure>

24. Rename the recently added layer to 'Lava flow buffer' and move it to the bottom, just below Lava flow layer.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FBh8wD9h55a6OMERdJ0i9%2Fimage.png?alt=media&#x26;token=11694164-3dd4-4033-b96f-5ceafe374c38" alt=""><figcaption></figcaption></figure>

25. Set the layer style for *Lava flow buffer* to `very light red`. To do so, access the Layer panel and pick the color in the **Fill Color** section. Also, set the opacity in this section to 0.3 and disable the Stroke Color using the toggle button.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FLDSRGdQe7xVANS2sNSj3%2Fimage.png?alt=media&#x26;token=4f7abbc1-8b7f-481e-9838-715b26c3e472" alt=""><figcaption></figcaption></figure>

26. In the **Interactions** tab, enable interactions for both *Lava flow* and *Lava flow buffer* layers. For each column, set the right formatting and rename it to a user-friendly label.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2Fb1dOkdiMIvXh3FBlNg95%2Fimage.png?alt=media&#x26;token=54749c57-e915-4c11-975e-7734e2065f83" alt=""><figcaption></figcaption></figure>

27. Change the basemap to Google Terrain by navigating to the **Basemap** tag and selecting `Terrain` type.

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FVr90z0lwqnLUN0BoXOX8%2Fimage.png?alt=media&#x26;token=1bc289f2-dc6e-44f1-bbd7-a2f5e8669925" alt=""><figcaption></figcaption></figure>

28. Now, we can add a **map description** to provide further context about this map to our viewer users. You can use the below markdown description or add your own.&#x20;

```markdown
### La Palma Volcano Eruption Impact Analysis 🌋

![Image: Global Populated Places](https://app-gallery.cartocdn.com/builder/lapalmavolcano.jpg)

This interactive map provides an in-depth visualization of the impact caused by La Palma volcano eruption which took place in 2021. It helps understanding the extent of the eruption's effects on the local community and environment.

---
🔍 **Explore the Map to Uncover**:

- **🌋 Volcano Lava Flow Visualization**: Trace the path of the lava flow, providing a stark visualization of the affected zones.

- **🔴 Buffered Lava Flow Zone**: View the 500-meter buffer zone around the lava flow, marking the wider area influenced by the eruption.

- **🏠 Building and Parcel Analysis**: Investigate how buildings and sociodemographic parcels in La Palma were impacted, revealing the eruption's reach on properties and people.

- **💡 Interactive Insights on Impact**: Engage with the lava flow areas to discover key data, such as the estimated value of affected properties, the number of properties impacted, and detailed population statistics.

---
📚 **Interested in Replicating This Map?**
Access our tutorial in the CARTO Academy for step-by-step guidance.
```

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FfYy1BqD4SIcngOhzIKJO%2Fpalma2.gif?alt=media&#x26;token=d95ea101-10c0-4026-a1e0-47f46bb50750" alt=""><figcaption></figcaption></figure>

28. Finally we can make the map public and share the link to anybody in the organization. For that you should go to “Share” on the top right corner and set the map as Public. For more details, see [Publishing and sharing maps](https://docs.carto.com/carto-user-manual/maps/publishing-and-sharing-maps).

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FruJ0HfvU91ybzxpRt1T3%2Fimage.png?alt=media&#x26;token=19f4c7a9-4990-4668-9757-7471564715ef" alt=""><figcaption></figcaption></figure>

Finally, we can visualize the result!

{% embed url="<https://clausa.app.carto.com/map/a3143d06-fe65-41c4-b1bf-bee28bdac7ae>" %}
