mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[DOCS] Updates maps reverse geocoding tutorial (#139058)
* [DOCS] Updates maps reverse geocoding tutorial * [DOCS] Adds name of file to download * [DOCS] Updates images and code for tutorial * Update docs/maps/reverse-geocoding-tutorial.asciidoc Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
6561ba86d2
commit
fa5b622c84
5 changed files with 49 additions and 48 deletions
Binary file not shown.
Before Width: | Height: | Size: 308 KiB |
BIN
docs/maps/images/reverse-geocoding-tutorial/csa_regions.png
Normal file
BIN
docs/maps/images/reverse-geocoding-tutorial/csa_regions.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
Binary file not shown.
Before Width: | Height: | Size: 915 KiB After Width: | Height: | Size: 1.8 MiB |
Binary file not shown.
Before Width: | Height: | Size: 258 KiB After Width: | Height: | Size: 472 KiB |
|
@ -2,7 +2,7 @@
|
|||
[[reverse-geocoding-tutorial]]
|
||||
== Map custom regions with reverse geocoding
|
||||
|
||||
*Maps* comes with https://maps.elastic.co/#file[predefined regions] that allow you to quickly visualize regions by metrics. *Maps* also offers the ability to map your own regions. You can use any region data you'd like, as long as your source data contains an identifier for the corresponding region.
|
||||
*Maps* comes with https://maps.elastic.co/#file[predefined regions] that allow you to quickly visualize regions by metrics. *Maps* also offers the ability to map your own regions. You can use any region data you'd like, as long as your source data contains an identifier for the corresponding region.
|
||||
|
||||
But how can you map regions when your source data does not contain a region identifier? This is where reverse geocoding comes in. Reverse geocoding is the process of assigning a region identifier to a feature based on its location.
|
||||
|
||||
|
@ -17,7 +17,7 @@ You’ll learn to:
|
|||
When you complete this tutorial, you’ll have a map that looks like this:
|
||||
|
||||
[role="screenshot"]
|
||||
image::maps/images/reverse-geocoding-tutorial/csa_regions_by_web_traffic.png[]
|
||||
image::maps/images/reverse-geocoding-tutorial/csa_regions_by_web_traffic.png[Map showing custom regions]
|
||||
|
||||
|
||||
[float]
|
||||
|
@ -29,6 +29,7 @@ You’ll use the <<get-started, web logs sample data set>> that comes with Kiban
|
|||
To install web logs sample data set:
|
||||
|
||||
. On the home page, click *Try sample data*.
|
||||
. Expand *Other sample data sets*.
|
||||
. On the *Sample web logs* card, click *Add data*.
|
||||
|
||||
|
||||
|
@ -36,13 +37,14 @@ To install web logs sample data set:
|
|||
=== Step 2: Index Combined Statistical Area (CSA) regions
|
||||
GeoIP level of detail is very useful for driving decision-making. For example, say you want to spin up a marketing campaign based on the locations of your users or show executive stakeholders which metro areas are experiencing an uptick of traffic.
|
||||
|
||||
That kind of scale in the United States is often captured with what the Census Bureau calls the Combined Statistical Area (CSA). Combined Statistical Area is roughly equivalent with how people intuitively think of which urban area they live in. It does not necessarily coincide with state or city boundaries.
|
||||
That kind of scale in the United States is often captured with what the Census
|
||||
Bureau calls the Combined Statistical Area (CSA). CSA is roughly equivalent with how people intuitively think of which urban area they live in. It does not necessarily coincide with state or city boundaries.
|
||||
|
||||
CSAs generally share the same telecom providers and ad networks. New fast food franchises expand to a CSA rather than a particular city or municipality. Basically, people in the same CSA shop in the same IKEA.
|
||||
|
||||
To get the CSA boundary data:
|
||||
|
||||
. Download the "Combined Statistical Areas (CSAs)" zip file from https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html[Census Bureau’s website].
|
||||
. Go to the https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html[Census Bureau’s website] and download the `cb_2018_us_csa_500k.zip` file.
|
||||
. Uncompress the zip file.
|
||||
. In Kibana, open the main menu, and click *Maps*.
|
||||
. Click *Create map*.
|
||||
|
@ -55,7 +57,7 @@ To get the CSA boundary data:
|
|||
. Set index name to *csa* and click *Import file*.
|
||||
. When importing is complete, click *Add as document layer*.
|
||||
. Add Tooltip fields:
|
||||
.. Click *+ Add* to open field select.
|
||||
.. Click *+ Add* to open the field select.
|
||||
.. Select *NAME*, *GEOID*, and *AFFGEOID*.
|
||||
.. Click *Add*.
|
||||
. Click *Save & close*.
|
||||
|
@ -63,24 +65,24 @@ To get the CSA boundary data:
|
|||
Looking at the map, you get a sense of what constitutes a metro area in the eyes of the Census Bureau.
|
||||
|
||||
[role="screenshot"]
|
||||
image::maps/images/reverse-geocoding-tutorial/csa_regions.jpeg[]
|
||||
image::maps/images/reverse-geocoding-tutorial/csa_regions.png[Map showing metro area]
|
||||
|
||||
[float]
|
||||
=== Step 3: Reverse geocoding
|
||||
To visualize CSA regions by web log traffic, the web log traffic must contain a CSA region identifier. You'll use {es} {ref}/enrich-processor.html[enrich processor] to add CSA region identifiers to the web logs sample data set. You can skip this step if your source data already contains region identifiers.
|
||||
|
||||
. Open the main menu, then click *Dev Tools*.
|
||||
. Open the main menu, and then click *Dev Tools*.
|
||||
. In *Console*, create a {ref}/geo-match-enrich-policy-type.html[geo_match enrichment policy]:
|
||||
+
|
||||
[source,js]
|
||||
----------------------------------
|
||||
PUT /_enrich/policy/csa_lookup
|
||||
{
|
||||
"geo_match": {
|
||||
"indices": "csa",
|
||||
"match_field": "coordinates",
|
||||
"enrich_fields": [ "GEOID", "NAME"]
|
||||
}
|
||||
PUT /_enrich/policy/csa_lookup
|
||||
{
|
||||
"geo_match": {
|
||||
"indices": "csa",
|
||||
"match_field": "geometry",
|
||||
"enrich_fields": [ "GEOID", "NAME"]
|
||||
}
|
||||
}
|
||||
----------------------------------
|
||||
|
||||
|
@ -95,29 +97,29 @@ POST /_enrich/policy/csa_lookup/_execute
|
|||
+
|
||||
[source,js]
|
||||
----------------------------------
|
||||
PUT _ingest/pipeline/lonlat-to-csa
|
||||
{
|
||||
"description": "Reverse geocode longitude-latitude to combined statistical area",
|
||||
"processors": [
|
||||
{
|
||||
"enrich": {
|
||||
"field": "geo.coordinates",
|
||||
"policy_name": "csa_lookup",
|
||||
"target_field": "csa",
|
||||
"ignore_missing": true,
|
||||
"ignore_failure": true,
|
||||
"description": "Lookup the csa identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"remove": {
|
||||
"field": "csa.coordinates",
|
||||
"ignore_missing": true,
|
||||
"ignore_failure": true,
|
||||
"description": "Remove the shape field"
|
||||
}
|
||||
}
|
||||
]
|
||||
PUT _ingest/pipeline/lonlat-to-csa
|
||||
{
|
||||
"description": "Reverse geocode longitude-latitude to combined statistical area",
|
||||
"processors": [
|
||||
{
|
||||
"enrich": {
|
||||
"field": "geo.coordinates",
|
||||
"policy_name": "csa_lookup",
|
||||
"target_field": "csa",
|
||||
"ignore_missing": true,
|
||||
"ignore_failure": true,
|
||||
"description": "Lookup the csa identifier"
|
||||
}
|
||||
},
|
||||
{
|
||||
"remove": {
|
||||
"field": "csa.geometry",
|
||||
"ignore_missing": true,
|
||||
"ignore_failure": true,
|
||||
"description": "Remove the shape field"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
----------------------------------
|
||||
|
||||
|
@ -132,16 +134,16 @@ POST kibana_sample_data_logs/_update_by_query?pipeline=lonlat-to-csa
|
|||
+
|
||||
[source,js]
|
||||
----------------------------------
|
||||
PUT kibana_sample_data_logs/_settings
|
||||
{
|
||||
"index": {
|
||||
"default_pipeline": "lonlat-to-csa"
|
||||
}
|
||||
PUT kibana_sample_data_logs/_settings
|
||||
{
|
||||
"index": {
|
||||
"default_pipeline": "lonlat-to-csa"
|
||||
}
|
||||
}
|
||||
----------------------------------
|
||||
|
||||
. Open the main menu, and click *Discover*.
|
||||
. Set the data view to *kibana_sample_data_logs*.
|
||||
. Set the data view to *Kibana Sample Data Logs*.
|
||||
. Open the <<set-time-filter, time filter>>, and set the time range to the last 30 days.
|
||||
. Scan through the list of *Available fields* until you find the `csa.GEOID` field. You can also search for the field by name.
|
||||
. Click image:images/reverse-geocoding-tutorial/add-icon.png[Add icon] to toggle the field into the document table.
|
||||
|
@ -150,7 +152,7 @@ PUT kibana_sample_data_logs/_settings
|
|||
Your web log data now contains `csa.GEOID` and `csa.NAME` fields from the matching *csa* region. Web log traffic not contained in a CSA region does not have values for `csa.GEOID` and `csa.NAME` fields.
|
||||
|
||||
[role="screenshot"]
|
||||
image::maps/images/reverse-geocoding-tutorial/discover_enriched_web_log.png[]
|
||||
image::maps/images/reverse-geocoding-tutorial/discover_enriched_web_log.png[View of data in Discover]
|
||||
|
||||
[float]
|
||||
=== Step 4: Visualize Combined Statistical Area (CSA) regions by web traffic
|
||||
|
@ -160,12 +162,12 @@ Now that our web traffic contains CSA region identifiers, you'll visualize CSA r
|
|||
. Click *Create map*.
|
||||
. Click *Add layer*.
|
||||
. Click *Choropleth*.
|
||||
. For *Boundaries source*:
|
||||
. For *Boundaries source*:
|
||||
.. Select *Points, lines, and polygons from Elasticsearch*.
|
||||
.. Set *Data view* to *csa*.
|
||||
.. Set *Join field* to *GEOID*.
|
||||
. For *Statistics source*:
|
||||
.. Set *Data view* to *kibana_sample_data_logs*.
|
||||
.. Set *Data view* to *Kibana Sample Data Logs*.
|
||||
.. Set *Join field* to *csa.GEOID.keyword*.
|
||||
. Click *Add layer*.
|
||||
. Scroll to *Layer Style* and Set *Label* to *Fixed*.
|
||||
|
@ -176,7 +178,6 @@ Now that our web traffic contains CSA region identifiers, you'll visualize CSA r
|
|||
.. Click *Save and add to library*.
|
||||
|
||||
[role="screenshot"]
|
||||
image::maps/images/reverse-geocoding-tutorial/csa_regions_by_web_traffic.png[]
|
||||
image::maps/images/reverse-geocoding-tutorial/csa_regions_by_web_traffic.png[Final map showing custom regions]
|
||||
|
||||
Congratulations! You have completed the tutorial and have the recipe for visualizing custom regions. You can now try replicating this same analysis with your own data.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue