Where spatial data comes from
There are several ways for you to obtain spatial data.
- Derive it from business data
- You can derive spatial data from business data, such as addresses. This process is called geocoding.
You can use a geocoder to translate business data into coordinates to enable spatial functions to operate on the data. For example, Figure 1 shows a BRANCHES and a CUSTOMERS table, each of which has an ADDRESS column. A user-defined function implemented a geocoder to obtain the geospatial coordinates that correspond to the addresses in these columns, and placed the coordinates into the formerly empty LOCATION columns in these tables.
- Generate it from spatial functions
- You can generate spatial data directly from coordinates using spatial constructor functions or by using other spatial functions to create new geometries from existing ones. For example, suppose that the bank whose branches are defined in the BRANCHES table wants to know how many customers are located within five miles of each branch. Before the bank can obtain this information from the database, it needs to define the zone that lies within a specified radius around each branch. The function ST_Buffer can create such a definition. Using the coordinates of each branch as input, ST_Buffer can generate the coordinates that demarcate the perimeters of the zones. Figure 2 shows the BRANCHES table with information that is supplied by ST_Buffer.
- Import it from external sources
- Spatial data in shapefile format is available from many sources throughout the internet. For example, you can download national and world-wide data and maps for features such as countries, states, cities, rivers, and more. These files typically contain data that is applied to maps: street networks, flood plains, earthquake faults, and so on. By using such data in combination with spatial data that you produce, you can augment the spatial information available to you. For example, if a public works department needs to determine what hazards a residential community is vulnerable to, it could use ST_Buffer to define a zone around the community. The public works department could then import data on flood plains and earthquake faults to see which of these problem areas overlap this zone.