Geocoding
In Adding geographic data to a node with the Location module we introduced the concept of geocoding. Geocoding is the process of creating spatial data from nonspatial information. Geocoding can be converting an address into latitude and longitude coordinate, or turning the name “Mount Everest” into a polygon. Going in the opposite direction, turning geospatial data into nongeospatial data, such as a coordinate into an address, is called reverse-geocoding.
Note
The process of geocoding, especially address conversion, usually involves a large amount of data and heavy processing power. This means that you are unlikely to create your own geocoding service, and it is why most of these modules integrate with existing services.
Modules
We have already worked through an example where the Location module geocoded the address that you entered for the Drupal company content type. To achieve similar results for the Geofield module, we will use the Geocoder and Addressfield modules. One other module that handles geocoding for Drupal 7 is the Geonames module, which will be briefly discussed.
Geocoder and Addressfield
To integrate with the OpenLayers and Geofield modules, the easiest way to allow users to enter an address and have it automatically geocoded is to install the Addressfield and Geocoder modules. For our example website, we will create a new content type to store Drupal events. The content type will contain the name of the event, a description of the event, a date, an address, ...
Get Mapping with Drupal now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.