OpenGeo

Introduction to PostGIS

Table Of Contents

Previous topic

Section 10: Projecting data

Next topic

Section 12: Tuning PostgreSQL for Spatial

Section 11: Basic Exercises

Try your hand at answering the following questions:

  1. How big is the largest building in Medford in square feet? In square metres?

    Note

    Our data is stored in the projection 2270, whose units are in feet. An appropriate metric projection is 2839.

  2. What is the elevation of the ‘South Medford’ high school building?

    Note

    The medford_buildings table contains the building elevations, and the jacksonco_schools table lists the name of the school.

  3. What are the expected percentages of children in poverty at each school with a Kindergarten class?

    Note

    Grades are listed as ranges, but as the lower possible limit, all schools that include Kindergarten classes will include a K in their grade.

  4. What is the length of ‘E Main St’?

  5. How much park area is there within the Medford city limits?

  6. How many buildings are located within wetlands?

  7. Which school is farthest from a park? Which is closest?

  8. Which schools have the most park area within 400 feet? Within 1 km?

  9. What are the expected percentages of unmarried families for each school?

  10. How many storm drains are within 500 feet of ‘Bear Creek’?

Things to Try: ST_Relate

One relational operator has intentionally been left out of the discussion so far. ST_Relate is a very powerful function that describes the spatial interactions between two geometries in great detail. It is however, much less intuitive to use than the functions described in previous sections. For a great description of how ST_Relate works in principle, look to the GeoTools Wiki [1]. While the syntax examples given may be in Java (eg. geometry1.relate(geometry2)) they are equivalent to those used in PostGIS (ST_Relate(geometry1, geometry2)).

Footnotes

[1]http://docs.codehaus.org/display/GEOTDOC/Point+Set+Theory+and+the+DE-9IM+Matrix