# How to optimize location planning for wind turbines

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

In this tutorial, you'll learn how to conduct wind farm site feasibility analysis at scale. This will include assessing terrain, demographics and infrastructure to understand which locations in West Virginia & Virginia are best suited for a wind farm.

While this tutorial focuses on wind farm sites, you can adapt this methodology to conduct site feasibility analysis for... just about anything!&#x20;

Check out this webinar for an overview of this tutorial:

{% embed url="<https://www.youtube.com/watch?index=13&list=PLGi6hymK320iGtaN8ODq6XZRDVLPJ3Lbw&v=xgjeHmAmeqA>" %}

### You will need...

* USA H3 [Spatial Features](https://carto.com/blog/carto-spatial-features-urbanity-climatology-elevation) data, which can be accessed via the CARTO Data Warehouse.
* Powerline data, sourced from the [Homeland Infrastructure Foundation](https://hub.arcgis.com/datasets/fedmaps::u-s-electric-power-transmission-lines/explore?location=43.006436%2C-87.946834%2C14.83) and loaded into your data warehouse (you can also use the CARTO Data Warehouse).
* US state boundaries, which you can access directly via the CARTO Data Warehouse or subscribe to in the Spatial Data Catalog.&#x20;
* We'll also be leveraging OpenStreetMap data for major highways and protected areas which you can subscribe to from the Google Data Marketplace [here](https://console.cloud.google.com/marketplace/product/openstreetmap/geo-openstreetmap?hl=en-GB\&rapt=AEjHL4ONQ7I48NthCyRdphJ_B_SbBE8AviRLNNC89IZECBisuBmRsks3JuHIQy_xZ9nadgeXpDYZR_IwmSSeOE-d1s-rBELRbQhLVYl9bQfeCxmt38buRxw\&project=cartodb-gcp-marketing-team) with a Google BigQuery account. More information on accessing this data can be found in step 1.&#x20;

***

## Step 1: Accessing OpenStreetMap data

\
For this analysis, we first need to access highway and protected area (see definition [here](https://wiki.openstreetmap.org/wiki/Tag:boundary%3Dprotected_area)) data, which we will source from [OpenStreetMap](https://www.openstreetmap.org/) - a fantastic global free database often dubbed “Wikipedia for maps.” While the crowdsourced nature of this dataset means quality and consistency can vary, major highways and protected areas are typically accurate due to their significance.

You can access this data for free from the Google BigQuery OpenStreetMap [public dataset](https://wiki.openstreetmap.org/wiki/BigQuery_dataset) by modifying the below code, either in your BigQuery console, CARTO Builder SQL console or a **Custom SQL Select** component in Workflows.. This code extracts protected areas which intersect our study area (the five named states in the first CTE)  and are >=0.73km² in size. Why? This is the [average area](https://h3geo.org/docs/core-library/restable/) of a H3 cell at resolution 8, which is the [geographic support system](https://carto.com/solutions/spatial-indexes/) we’ll be using for this analysis (keep reading for more information).&#x20;

```
WITH
 aoi AS ( SELECT ST_UNION_AGG(geom) AS geom
 FROM `carto-data.ac_xxxxxxxx.sub_carto_geography_usa_state_2019`
 WHERE do_label IN ('West Virginia', 'Virginia')),


geoms AS (
 SELECT
   (SELECT osm_id) osmid,
   (SELECT value FROM UNNEST(all_tags) WHERE KEY = "boundary") AS boundary,
   (SELECT value FROM UNNEST(all_tags) WHERE KEY = "name") AS name,
   (SELECT geometry) AS geom
 FROM bigquery-public-data.geo_openstreetmap.planet_features)


SELECT geoms.*
FROM geoms, aoi
WHERE ST_CONTAINS(aoi.geom, geoms.geom) AND geoms.boundary = 'protected_area') AND ST_AREA(geoms.geom) >= 737327.598
```

To access major highways, you can modify this code by replacing the boundary key with "highway" and change the final WHERE statement to `WHERE ST_CONTAINS(aoi.geom, geoms.geom) AND geoms.highway IN ('motorway', 'motorway_link', 'trunk', 'trunk_link')`.&#x20;

You can read our full guide to working with the BigQuery OpenStreetMap dataset [here](https://carto.com/blog/osm-bigquery).

***

## Step 2: Filtering out unsuitable areas

With all of our data collated, we first should filter our support geography (H3 Spatial Features) to only suitable locations. For the purposes of this tutorial, that is:

* Must be within 25 miles of a >=400KV powerline.
* Must be within 15 miles of a motorway or trunk level highway.
* Must not intersect a large protected area (please note Native American lands are not included as many Native American communities are [reported to be](https://www.windpowermonthly.com/article/966022/us-focus-tribal-wind-ambition-victim-policy-void) pro wind farm developments).

To achieve this, follow these steps:

1. In the CARTO Workspace, create a new workflow and select the connection where you have the relevant tables saved.
2. Drag all four tables (H3 Spatial Features, power lines, major highways and protected areas) onto the canvas. We've created a copy of the Spatial Features dataset limited to our study area, but this step is optional.
3. Connect the Spatial Features table to a **H3 Center** component which will transform each cell into a point geometry.&#x20;
4. Connect the power lines and major highways to an **ST Buffer** component each, and set the buffer distance 15 miles for both components.&#x20;
5. Next, use two consecutive **Spatial Filter** components to filter the H3 Centers to those which intersect each buffer (see below).&#x20;
6. At this stage, you are likely to have many duplicates where multiple buffers overlap. Remove these by using a **Group by** component and set the group colum to H3, and select H3\_geo as an aggregation column with the type "any" to retain the geometry data.&#x20;

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FbuHzsBdJVRrmyOSQgXPI%2Ftutorial_wind_filtering_workflow_v4.png?alt=media&#x26;token=c1f1a479-81cb-4f35-af67-733a6e81488e" alt=""><figcaption><p>Filtering to feasible locations</p></figcaption></figure>

In the final step for this section, add a final Spatial Filter, selecting the results of Group by as the top (source) input, and the bottom as the protected (filter) input.&#x20;

The bottom output of this is all of the features which do not match this criteria; every H3 cell which **is** within 15 miles of a major highway or a major power line but **is not** within a large protected area. Add another **Group by** component here (Group by: H3, Aggregate: H3 (any)) to remove duplicates.&#x20;

These are our areas where a wind farm is feasible - now let's see where it's optimal!

***

## Step 3: Optimal locations for a wind farm

In this section, we'll be ranking the feasible locations based on where has optimal conditions for a wind farm. For this example, we are looking for locations with high wind speed and a small local population. We'll be extending the above workflow as follows:

<figure><img src="https://3015558743-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFEElAdsRIl9DzfMhbRlB%2Fuploads%2FaiKhDc9lrazZjK6lB1AP%2Ftutorial_wind_optimizing_workflow.png?alt=media&#x26;token=e37ea30d-2f98-4114-adec-8aa0da320d7f" alt=""><figcaption><p>Optimizing locations for wind farms</p></figcaption></figure>

1. First, we want to connect the wind speed and population data to the H3 grid we just created. Connect the output of the final Group by component from step 2 to the bottom input of a **Join** component. Connect the original Spatial Features source to the top input of the Join. Ensure the join columns are set to the H3 index column, and set the join type to right.&#x20;
2. Now, add a Create Column component and connect this to the output of the previous step. Call this field avg\_wind and use `AVG(wind_jan, wind_feb... wind_dec)` to calculate the average annual wind speed.&#x20;
3. Now we'll use the **Normalize** component so we can use these two different measures together. Connect the first Normalize component to the output of Create Column and select avg\_wind as the variable, then repeat this for the Population variable.
4. Add a final **Create Column** component. Call the column Index, and set the formula to `avg_wind_norm + (1-population_norm)`.&#x20;

And that's it! The result of this Index calculation will be a score out of 2; 2 being the ideal wind farm location, with the highest wind speed but smallest population. Check this out below!

{% embed url="<https://clausa.app.carto.com/map/ac7dd9b4-2b9b-4af2-9e27-580414b1a79a>" %}
The results!
{% endembed %}

You can learn also about this example by following our publication in the CARTO blog:&#x20;

{% embed url="<https://carto.com/blog/location-planning-for-wind-turbines>" %}


---

# 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/creating-workflows/step-by-step-tutorials/how-to-optimize-location-planning-for-wind-turbines.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.
