<<

A spatial allows users to make standard SQL queries and also geographical queries to access and analyze data. SpatialSQL Currently , there are several spatial , or geo-databases, available on the market, including Oracle Spatial, IBM DB2 QueryingSpatialObjects Spatial Extender , ArcSDE (ESRI) over proprietary RDBMS, BasedonGeographicInformation PostgreSQL with PostGIS (Refractions Research) and MySQL with spatial extensions. Microsoft also recently announced that AnOpenSourceApproach the next release of SQL Server will include spatial data support. This section focuses on an open source product, ChiekoMAENE PostGIS, and its spatial functions. Maps&StateDocumentsLibrarian GovernmentandGeographicInformationandDataServices PostGIS is an extension which adds capabilities to an open NorthwesternUniversity cͲ[email protected] source object-relational database, PostgreSQL. PostGIS complies with the Open Geospatial Consortium (OGC, formerly known as OpenGIS) for SQL specification, and has become the standard spatial database backend for all the other open source GIS tools, such as Mapserver as the project References: presented on the left shows. PostGIS http://postgis.refractions.net/ OGCSimpleFeatureSpecificationforSQL Although PostGIS has implemented a variety of OGC functions to manage, http://www.opengeospatial.org/standards/sfs manipulate and create spatial data, new users may find only a few functions ProductSurveyonGeoͲdatabases useful. For this session, only the most basic spatial relationship functions are http://www.gimͲinternational.com/files/productsurvey_v_pdfdocument_14. examined with examples of the use in a library setting.

CONTAINS()DISTANCE(WITHIN() INTERSECTS() ) CONTAINS() WITHIN() INTERSECTS() DISTANCE()

SELECT *FROM tableWHERE SELECT *FROM tableWHERE SELECT *FROM tableWHERE SELECT *FROM tableWHERE CONTAINS (the_geom,objectͲa) WITHIN (the_geom,objectͲa) INTERSECTS (the_geom,objectͲ DISTANCE (the_geom,objectͲa)< a) 2000 Returns 1 (TRUE) if the object Returns 1 (TRUE) if the object is spatially contains another object. “spatially within” another object. Returns 1 (TRUE) if the object Returns the Cartesian distance For instance, the example above For instance, the example above spatially intersects another object. between two objects in projected selects all objects from a table selects all objects that are spatially For instance, the example above units. For instance, the example (table) that contains another object within, or are completely contained selects all objects that intersect (i.e. above selects all objects from a (object-a). Don’t’ confuse by, another object (object-a). touches or overlays) another table (table) which are within 2,000 CONTAINS() with WITHIN() object (object-a). projected units of an object operator.. CONTAINS(A,B) is This type of query is useful in (object-a). interpreted as “A contains B” finding spatial objects whose This type of query is useful in which equals to “B is within A”. centroid falls in a particular area (or selecting spatial objects that This type of query is useful in areas) such as a city of a contain a linear feature object, finding spatial objects near a This type of query is useful in neighborhood. For example, one such as a river. For example, one specific location. For example, one identifying spatial objects that may need to find photographs of may need to find maps or aerial may need to identify cultural contain a particular spot, such as a historic buildings in a particular photographs covering a specific institutions such as museums and house or a construction site. For neighborhood. By recording an river. In such a case, use the river libraries near one’s house. If example, one may need maps and address of such buildings and then as another object (object-a) to geographic locations of such aerial photographs that contain a converting the addresses to select maps and aerial photograph institutions are recorded in a particular house. With geographic coordinates in GIS and sheets that the river touches or database, finding them by distance electronically indexed map and air also storing neighborhood intersects. criteria is easy. Also, if descriptions photo sheet information and a boundary information in a of each institution are available, house address, one will be able to database, one will be able to query SELECT * FROM setting up more complex criteria to query the map and photo sheets the buildings by naming map_airphoto_sheets_table narrow the search result will be that are available to study a specific neighborhoods. WHERE possible. location. INTERSECTS(the_geom, the SELECT * FROM river) SELECT * FROM SELECT * FROM historic_buildings WHERE institutions_table WHERE map_airphoto_sheets_table WITHIN(the_geom, DISTANCE(the_geom, WHERE CONTAINS(the_geom, neighborhood) the_location) < 1234 (distance in a house_address) projected unit) Many items in libraries are geographic objects, or objects with spatial information such as place name or street address. Examples include historic photographs, aerial photographs, topographic and fire insurance maps. However, the ways in which most libraries locate information are somehow limited to analog tools, such as AerialPhotographs catalog records, index cards and index maps. Wouldn’t it be better if we could find these objects based on spatial information?

The popularity of mapping sites such as Google Maps indicates that Internet users are comfortable with finding geographic objects by simply typing a street address.

Libraries can implement the same idea. This project introduces the concept of “spatial queries” using open source software, PostGIS and GeocoderUS. A combination of these tools enables users to find photographs and maps by querying an object-relational database with spatial information such as a street address or Pictures intersection. The query returns objects that have a proximity or spatial relationship to the input information. The project result is a “spatially enabled” SQL data server which supports such queries as, “find and show me photographs near this location” or “find and show me maps that contain this location.”

Maps

IMPLEMENTATIONEXAMPLE–MAPS&AIRPHOTOSFINDER http://maps.lib.uic.edu 3. 1. 2. The initial idea for this project came The solution to this is GIS. Once the The first step to create a spatial query    IMPLEMENTATION IDEA from our topographic maps and aerial SOLUTION indexing information is stored in an system is creating spatial objects (map photograph users who needed to find electronic database, GIS will enable and aerial photo indexes) in GIS and the right sheets that cover their study users to find the spatial objects they then saving them in a database. For the area typically described with a street need by making a simple query like project, metadata (i.e. series name, address or a street intersection. Their “find all photographs that fall in (or sheet name, index number, published information search would be easy if near) this location.” Next, we would year, publisher, etc.) as well as all the map series and aerial make the query system and spatially geographic coordinates of all the map photograph sets used the same indexed objects accessible via the and aerial photograph sheets were indexing system. In reality this is not Internet so that users will benefit stored in the GIS format the case. Maps and air photos are from GIS without having GIS Then the data were imported to a organized in various different ways software on their computers. spatial data management database due to their various sizes and formats system, PostgreSQL. With a and also their historical nature, and The main components used in the combination of a spatial indexing tool, thus it makes pulling the information project are (diagram on the left): PostGIS, this database can accept both difficult. spatial (i.e. data with geographic 1) Web server, Microsoft IIS, coordinates) and non-spatial objects 2) Data server, PostgreSQL with (i.e. data tables) and also query and PostGIS extension, manipulate the objects using the SQL 3) Online mapping software, UMN interface.

Geocode MapServer, service 4) Address-to-coordinates Once a database is created, objects can maps.lib conversion software, GeocoderUS . uic.edu be accessed, retrieved and presented by plus Census TIGER database in a series of queries and requests over address – sends X Y BerkeleyDB, the web using various web server-side coordinates all of which are open source except scripting languages, such as Perl, and for a web server (IIS – comes with PHP. Examples of spatial queries are Gets the coordinate Windows XP.) presented on the right. s Find base map layers MapServ Create a Note: the project could be downsized A map server such as UMN Mapserver er PostGIS map to just two main components (web & used in this project, or a mapping Makes data servers) to create a simple online service such as Google Maps will be spatial query – spatial query system without mapping needed to graphically present the finds map sheets component. retrieved objects in space, or on a map.

Acknowledgment:Mapsandaerialphotographsfinder project(maps.lib.uic.edu) wassupported byandimplementedattheUniversity ofIllinois atChicagoLibrary.