|
| 1 | +(** |
| 2 | +--- |
| 3 | +title: Geo vs. Mapbox |
| 4 | +category: Geo map charts |
| 5 | +categoryindex: 6 |
| 6 | +index: 1 |
| 7 | +--- |
| 8 | +*) |
| 9 | + |
| 10 | +(*** hide ***) |
| 11 | + |
| 12 | +(*** condition: prepare ***) |
| 13 | +#r "nuget: Newtonsoft.JSON, 12.0.3" |
| 14 | +#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll" |
| 15 | + |
| 16 | +(*** condition: ipynb ***) |
| 17 | +#if IPYNB |
| 18 | +#r "nuget: Plotly.NET, {{fsdocs-package-version}}" |
| 19 | +#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}" |
| 20 | +#endif // IPYNB |
| 21 | + |
| 22 | +(** |
| 23 | +# Mapbox Maps vs Geo Maps |
| 24 | +
|
| 25 | +[](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb)  |
| 26 | +[]({{root}}{{fsdocs-source-basename}}.fsx)  |
| 27 | +[]({{root}}{{fsdocs-source-basename}}.ipynb) |
| 28 | +
|
| 29 | +*Summary:* This introduction shows the differences between Geo and Mapbox based geographical charts. |
| 30 | +
|
| 31 | +Plotly and therefore Plotly.NET supports two different kinds of maps: |
| 32 | +
|
| 33 | +- **Mapbox maps** are tile-based maps. If your figure is created with a `Chart.*Mapbox` function or otherwise contains one or more traces of type `scattermapbox`, |
| 34 | + `choroplethmapbox` or `densitymapbox`, the layout.mapbox object in your figure contains configuration information for the map itself. |
| 35 | + |
| 36 | +- **Geo maps** are outline-based maps. If your figure is created with a `Chart.ScatterGeo, `Chart.PointGeo`, `Chart.LineGeo` or `Chart.Choropleth` function or |
| 37 | + otherwise contains one or more traces of type `scattergeo` or `choropleth`, the layout.geo object in your figure contains configuration information for the map itself. |
| 38 | + |
| 39 | +_This page documents Geo outline-based maps, and the [Mapbox Layers documentation]({{root}}/6_0_geo-vs-mapbox.html) describes how to configure Mapbox tile-based maps._ |
| 40 | +
|
| 41 | +## Physical Base Maps |
| 42 | +
|
| 43 | +Plotly Geo maps have a built-in base map layer composed of "physical" and "cultural" (i.e. administrative border) data from the Natural Earth Dataset. |
| 44 | +Various lines and area fills can be shown or hidden, and their color and line-widths specified. |
| 45 | +In the default plotly template, a map frame and physical features such as a coastal outline and filled land areas are shown, at a small-scale 1:110m resolution: |
| 46 | +
|
| 47 | +*) |
| 48 | + |
| 49 | +open Plotly.NET |
| 50 | + |
| 51 | +let baseMapOnly = |
| 52 | + Chart.PointGeo([]) // deliberately empty chart to show the base map only |
| 53 | + |> Chart.withMarginSize(0,0,0,0) |
| 54 | + |
| 55 | +(*** condition: ipynb ***) |
| 56 | +#if IPYNB |
| 57 | +baseLayerOnly |
| 58 | +#endif // IPYNB |
| 59 | + |
| 60 | +(***hide***) |
| 61 | +baseMapOnly |> GenericChart.toChartHTML |
| 62 | +(***include-it-raw***) |
| 63 | + |
| 64 | +(** |
| 65 | +To control the features of the map, a `Geo` object is used that can be associtaed with a given chart using the `Chart.WithGeo` function. |
| 66 | +Here is a map with all physical features enabled and styled, at a larger-scale 1:50m resolution: |
| 67 | +*) |
| 68 | + |
| 69 | +let myGeo = |
| 70 | + Geo.init( |
| 71 | + Resolution=StyleParam.GeoResolution.R50, |
| 72 | + ShowCoastLines=true, |
| 73 | + CoastLineColor="RebeccaPurple", |
| 74 | + ShowLand=true, |
| 75 | + LandColor="LightGreen", |
| 76 | + ShowOcean=true, |
| 77 | + OceanColor="LightBlue", |
| 78 | + ShowLakes=true, |
| 79 | + LakeColor="Blue", |
| 80 | + ShowRivers=true, |
| 81 | + RiverColor="Blue" |
| 82 | + ) |
| 83 | + |
| 84 | +let moreFeaturesBaseMap = |
| 85 | + Chart.PointGeo([]) |
| 86 | + |> Chart.withMap myGeo |
| 87 | + |> Chart.withMarginSize(0,0,0,0) |
| 88 | + |
| 89 | +(*** condition: ipynb ***) |
| 90 | +#if IPYNB |
| 91 | +moreFeaturesBaseMap |
| 92 | +#endif // IPYNB |
| 93 | + |
| 94 | +(***hide***) |
| 95 | +moreFeaturesBaseMap |> GenericChart.toChartHTML |
| 96 | +(***include-it-raw***) |
| 97 | + |
| 98 | +(** |
| 99 | +## Cultural Base Maps |
| 100 | +
|
| 101 | +In addition to physical base map features, a "cultural" base map is included which is composed of country borders and selected sub-country borders such as states. |
| 102 | +
|
| 103 | +_Note and disclaimer: cultural features are by definition subject to change, debate and dispute. Plotly includes data from Natural Earth "as-is" and defers to the Natural Earth policy regarding disputed borders which read:_ |
| 104 | +
|
| 105 | +> Natural Earth Vector draws boundaries of countries according to defacto status. We show who actually controls the situation on the ground. |
| 106 | +
|
| 107 | +Here is a map with only cultural features enabled and styled, at a 1:50m resolution, which includes only country boundaries. See below for country sub-unit cultural base map features: |
| 108 | +*) |
| 109 | + |
| 110 | +let countryGeo = |
| 111 | + Geo.init( |
| 112 | + Visible=false, |
| 113 | + Resolution=StyleParam.GeoResolution.R50, |
| 114 | + ShowCountries=true, |
| 115 | + CountryColor="RebeccaPurple" |
| 116 | + ) |
| 117 | + |
| 118 | + |
| 119 | +let countryBaseMap = |
| 120 | + Chart.PointGeo([]) |
| 121 | + |> Chart.withMap countryGeo |
| 122 | + |> Chart.withMarginSize(0,0,0,0) |
| 123 | + |
| 124 | +(*** condition: ipynb ***) |
| 125 | +#if IPYNB |
| 126 | +countryBaseMap |
| 127 | +#endif // IPYNB |
| 128 | + |
| 129 | +(***hide***) |
| 130 | +countryBaseMap |> GenericChart.toChartHTML |
| 131 | +(***include-it-raw***) |
0 commit comments