Skip to content

Commit

Permalink
Merge pull request #48 from developmentseed/develop
Browse files Browse the repository at this point in the history
Release v0.3
  • Loading branch information
olafveerman authored Apr 6, 2021
2 parents c79d6fa + 3c00618 commit b43e24a
Show file tree
Hide file tree
Showing 25 changed files with 926 additions and 221 deletions.
51 changes: 32 additions & 19 deletions content/study/posts/kenya.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,71 @@ platform:
layers:
- id: 11kv
name: Existing grid 11kv
category: contextual
category: input
mbLayer: 11kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 33kv
name: Existing grid 33kv
category: contextual
category: input
mbLayer: 33kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 66kv
name: Existing grid 66kv
category: contextual
category: input
mbLayer: 66kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 132kv
name: Existing grid 132kv
category: contextual
category: input
mbLayer: 132kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: 220kv
name: Existing grid 220kv
category: contextual
category: input
mbLayer: 220kv
info: This dataset contains electricity transmission lines with different voltage levels as well as unidentified voltage in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-kenya-electricity-network
- id: transformers
name: Distribution Transformers
category: contextual
category: input
mbLayer: transformers
info: The dataset contains Distribution Transformers in Kenya.The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-distribution-transformers
- id: substations
name: Primary Substations
category: contextual
category: input
mbLayer: substation
info: The dataset contains primary substations in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-primary-substations
- id: transmission
name: Transmission Stations
category: contextual
category: input
mbLayer: transmission-stations
info: The data contains transmission station locations in Kenya. The dataset was provided by Kenya Power and Lighting Company (KPLC).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-transmission-stations
- id: power
name: Power Stations
category: contextual
category: input
disabled: true
mbLayer: 11kv
info: The dataset contains location of Power Stations in Kenya. It was provided by Kenya Power and Lighting Company (KPLC).
Expand All @@ -87,7 +87,7 @@ layers:
url: https://energydata.info/dataset/kenya-power-stations
- id: population
name: Population and Household Dataset (2009 & 2016)
category: contextual
category: input
disabled: true
mbLayer: 11kv
info: Population and Household statistics for the years 2009 and 2016 as well as the enumeration areas.The dataset was provided by Kenya National Bureau of Statistics (KNBS).
Expand All @@ -96,15 +96,15 @@ layers:
url: https://energydata.info/dataset/kenya-population-and-household-dataset
- id: roads
name: Roads
category: contextual
category: input
mbLayer: roads
info: Road network in Kenya. The dataset was provided by Kenya Roads Board (KRB).
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-roads-1
- id: health
name: Healthcare Facilities
category: contextual
category: input
disabled: true
mbLayer: 11kv
info: Data on healthcare facility locations in Kenya. The dataset was provided by the Government of Kenya.
Expand All @@ -113,15 +113,15 @@ layers:
url: https://energydata.info/dataset/kenya-healthcare-facilities
- id: education
name: Schools
category: contextual
category: input
mbLayer: education
info: School locations in Kenya. It comprises Primary and Secondary Schools. The dataset was provided by Kenya Ministry of Education.
source:
name: energydata.info
url: https://energydata.info/dataset/kenya-schools
- id: minigrid
name: Overview of Off-Grid Electricity Service Areas
category: result
category: outcome
mbLayer: minigrid
visible: true
info: This dataset represents the locations of existing mini-grids, mini-grids under development, proposed KOSAP mini-grids, and potential SHS markets in Kenya. This is the output of preliminary GIS analysis funded by the World Bank and undertaken in 2017.
Expand All @@ -130,7 +130,7 @@ layers:
url: https://energydata.info/dataset/kenya-overview-of-off-grid-electricity-service-areas
- id: grid-expansion
name: Grid Expansion Projects
category: result
category: outcome
disabled: true
mbLayer: 11kv
info: This dataset represents potential grid expansion projects identified through a least-cost geospatial analysis undertaken over the period 2017-2018.
Expand All @@ -139,7 +139,7 @@ layers:
url: https://energydata.info/dataset/kenya-grid-expansion
- id: minigrid-expansion
name: Existing Mini-Grid Expansion Projects
category: result
category: outcome
mbLayer: minigrid-existing
visible: true
info: Potential expansion projects for existing mini-grids; the expansion projects were identified through a least-cost geospatial analysis undertaken over the period 2017-2018.
Expand All @@ -148,7 +148,7 @@ layers:
url: https://energydata.info/dataset/kenya-potential-expansion-of-existing-mini-grids
- id: minigrid-new
name: New Mini-Grid Projects
category: result
category: outcome
mbLayer: minigrid-proposed
visible: true
info: Potential mini-grid projects; these projects were identified through a least-cost geospatial analysis undertaken over the period 2017-2018.
Expand All @@ -157,9 +157,22 @@ layers:
url: https://energydata.info/dataset/kenya-potential-new-mini-grid-sites
- id: wind
name: Mean wind speed
category: contextual
category: input
mbLayer: wind
info: The mean wind speed is a measure of the wind resource. Higher mean wind speeds normally indicate better wind resources, but mean wind power density gives a more accurate indication of the available wind resource.
source:
name: Global Wind Atlas
url: https://globalwindatlas.info/
url: https://globalwindatlas.info/
legendData:
type: gradient
min: '< 2.5'
max: '> 9.75 m/s'
stops:
- '#BEE6FA'
- '#488FC6'
- '#7BC34C'
- '#F9E65B'
- '#F56E2B'
- '#C82333'
- '#A3305C'

57 changes: 57 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ The main information and metadata of each study is managed through a `yml` file,
| layers[].source | `object` | Link to the data source |
| layers[].source.name | `string` | Name of the source link |
| layers[].source.url | `string` | URL of the data source |
| layers[].legendData | `object` | Custom legend |
| layers[].legendData.type | `enum` one of [`gradient`, `line`, `circle`, `symbol`] | Type of legend |
| layers[].legendData.color | `string` | The color of the feature. Applies to `circle` and `line` |
| layers[].legendData.dashed | `boolean` | Use a dashed line. Applies to `line` |
| layers[].legendData.icon | `string` | The basename of the icon, without file extension. Applies to `symbol` |
| layers[].legendData.min | `string` | Minimum value printed on the x-axis. Applies to `gradient` |
| layers[].legendData.max | `string` | Maximum value printed on the x-axis. Applies to `gradient`
| layers[].legendData.stops | `array` | An array with RGB colors that indicate the stops. Applies to `gradient`

## Map configuration
The map of each study is configured using a `json` file that follows the Mapbox Style specification. For a full example, please see [`kenya-mb.json`](/content/study/posts/kenya-mb.json).
Expand Down Expand Up @@ -166,6 +174,55 @@ New icons can be added to [`/content/icons`](/content/icons). They should be in

[To top](#managing-studies)


# Legends
Broadly speaking, AEP supports two types of legends: symbology for features on the map like circles and lines and gradient legends for raster data like the Global Wind Atlas.

## Customizing vector legends
The platform will automatically determine the legend for vector layers. It's possible to override these defaults by specifying a `legendData` object on the layer configuration. For example:

### Line
![](media/line-legend.png)

``` yml
legendData:
type: line
color: '#00FF00'
dashed: true
```

### Symbol
![](media/symbol-legend.png)

``` yml
legendData:
type: symbol
color: 'electricity'
```

## Defining raster legends
The legend for external data layers can't be automatically determined by AEP and always have to be defined through configuration. The platform currently supports linear gradients, below is an example with 7 color stops.

![](media/wind-legend.png)


``` yml
legendData:
type: gradient
min: '< 2.5'
max: '> 9.75 m/s'
stops:
- '#BEE6FA'
- '#488FC6'
- '#7BC34C'
- '#F9E65B'
- '#F56E2B'
- '#C82333'
- '#A3305C'
```

[To top](#managing-studies)

# Troubleshooting
## Map shows an unexpected layer
If the map loads with a layer that can't be managed through the layer switcher, it's likely that you added a layer in the Mapbox Style that isn't referenced in the layer configuration of the `yml`. This is by design. It allows you to overlay a contextual layer on the map that the user don't have control over. A use case could be a layer that adds a disputed border.
Binary file added docs/media/line-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/symbol-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/wind-legend.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ exports.createSchemaCustomization = ({ actions, schema }) => {

const typeDefs = [
`
type LayerLegend {
type: String
min: String
max: String
stops: [String]
color: String
icon: String
dashed: Boolean
}
type PanelLayerSource {
name: String
url: String
Expand All @@ -19,6 +29,7 @@ exports.createSchemaCustomization = ({ actions, schema }) => {
mbLayer: String
info: String
source: PanelLayerSource
legendData: LayerLegend
}
type Platform {
Expand Down
21 changes: 16 additions & 5 deletions schema/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ const mbValidator = require('@mapbox/mapbox-gl-style-spec');
const Schema = require('validate');
const yml = require('js-yaml');

const fileExists = (val) => {
return fs.existsSync(path.join(__dirname, '../content/study/posts/', val));
};
const studyFileExists = (val) =>
fs.existsSync(path.join(__dirname, '../content/study/posts/', val));

const studySchema = new Schema({
title: { type: String, required: true },
Expand All @@ -24,7 +23,7 @@ const studySchema = new Schema({
]
],
zoomExtent: [{ type: Number }, { type: Number }],
mapConfig: { type: String, use: { fileExists }, required: true },
mapConfig: { type: String, use: { studyFileExists }, required: true },
study: {
consultant: { type: String, required: true },
period: { required: true },
Expand All @@ -41,7 +40,7 @@ const studySchema = new Schema({
name: { type: String, required: true },
category: {
type: String,
enum: ['contextual', 'result'],
enum: ['input', 'outcome'],
required: true
},
visible: { type: Boolean },
Expand All @@ -51,6 +50,18 @@ const studySchema = new Schema({
source: {
name: { type: String, required: true },
url: { type: String, required: true }
},
legendData: {
type: {
type: String,
enum: ['gradient', 'line', 'circle', 'symbol']
},
color: { type: String, match: /^#[0-9a-fA-F]{6}$/ },
dashed: { type: Boolean },
icon: { type: String },
min: { type: String },
max: { type: String },
stops: [{ type: String, match: /^#[0-9a-fA-F]{6}$/ }]
}
}
]
Expand Down
Loading

0 comments on commit b43e24a

Please sign in to comment.