Geospatial Data

Reverse geocoding

Reverse geocoding is the process of bringing geographic coordinates (and also, in our case, the relation ID) into a description of the location. In other words, this is the process that is the reverse of the geocoding process. This function can be useful to get full geographic information about a certain place, if you have its coordinates or relation ID.

With the reverse command you can use following parameters:

Parameter Description
relation relation ID. If used, system will search by relation ID regardless of other parameters sent. Optional parameter.
lat Latitude. Optional parameter.
lon Longitude. Optional parameter.

Sample of reverse geocoding by relation ID.

    # SWITCHING TO THE GEO CONTEXT
- geo:
    provider: osm
    do:
    # Get information about place by relation ID
    - reverse:
        relation: 62366
        do:
Time Level Message
2018-05-29 23:38:42:851 info Stopped by exit command
2018-05-29 23:38:42:835 debug Page content: ...
2018-05-29 23:38:42:056 info Retrieving page (GET): https://nominatim.openstreetmap.org/reverse?osm_type=R&osm_id=62366&format=json
2018-05-29 23:38:42:047 debug Getting reverse geo information by relation ID: 62366
2018-05-29 23:38:42:038 debug Setting up geo provider: osm
2018-05-29 23:38:42:029 info Starting scrape
2018-05-29 23:38:42:002 debug Setting up default proxy
2018-05-29 23:38:41:993 debug Setting up surf
2018-05-29 23:38:41:956 info Starting digger: 1 [2158]
            <html>
<head></head>
<body>
<body_safe>
<address>
<continent>Europe</continent>
<country>Deutschland</country>
<country_code>de</country_code>
<state>Thüringen</state>
</address>
<boundingbox>50.2043467</boundingbox>
<boundingbox>51.6489423</boundingbox>
<boundingbox>9.8767193</boundingbox>
<boundingbox>12.6539178</boundingbox>
<display_name>Thüringen, Deutschland, Europe</display_name>
<lat>50.7333163</lat>
<licence>Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright</licence>
<lon>11.0747905</lon>
<osm_id>62366</osm_id>
<osm_type>relation</osm_type>
<place_id>179115036</place_id>
</body_safe>
</body>
</html>
            

Sample of reverse geocoding by coordinates of the place.

        # SWITCHING TO THE GEO CONTEXT
- geo:
    provider: osm
    do:
    # Get data about the place by coordinates
    - reverse:
        lat: 41.8775257
        lon: -87.62955615
        do:
    
Time Level Message
2018-05-29 23:59:30:408 info Stopped by exit command
2018-05-29 23:59:30:394 debug Page content: ...
2018-05-29 23:59:29:683 info Retrieving page (GET): https://nominatim.openstreetmap.org/reverse?lat=41.8775257&lon=-87.62955615&format=json
2018-05-29 23:59:29:674 debug Getting reverse geo information by lat/lon: 41.8775257/-87.62955615
2018-05-29 23:59:29:666 debug Setting up geo provider: osm
2018-05-29 23:59:29:657 info Starting scrape
2018-05-29 23:59:29:631 debug Setting up default proxy
2018-05-29 23:59:29:617 debug Setting up surf
2018-05-29 23:59:29:585 info Starting digger: 1 [2158]
            <html>
<head></head>
<body>
<body_safe>
<address>
<building>Monadnock Building</building>
<city>Chicago</city>
<country>United States of America</country>
<country_code>us</country_code>
<county>Cook County</county>
<house_number>53</house_number>
<neighbourhood>Loop</neighbourhood>
<postcode>60604</postcode>
<road>West Jackson Boulevard</road>
<state>Illinois</state>
</address>
<boundingbox>41.876976</boundingbox>
<boundingbox>41.8780754</boundingbox>
<boundingbox>-87.6297057</boundingbox>
<boundingbox>-87.6294066</boundingbox>
<display_name>Monadnock Building, 53, West Jackson Boulevard, Loop,
Chicago, Cook County, Illinois, 60604, United States of America</display_name>
<lat>41.8775257</lat>
<licence>Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright</licence>
<lon>-87.62955615</lon>
<osm_id>73671128</osm_id>
<osm_type>way</osm_type>
<place_id>85949297</place_id>
</body_safe>
</body>
</html>
                

Next we will learn about a number of complimentary commands that can be useful in different situations.