Exploring Postgis with a Full Analysis Example

Exploring Postgis with a Full Analysis Example

Exploring PostGIS with a Full Analysis Example J.C. MARTINEZ, E. COLL, J. IRIGOYEN Department of Cartographic Engineering, Geodesy and Photogrammetry Polytechnic University of Valencia Camino de Vera, 46022, Valencia SPAIN Abstract: -. This paper explains PostGIS functioning through a small spatial analysis. For this purpose the analysis is firstly performed on a traditional way using a GIS Desktop program (ArcGIS from ESRI), and secondly the same analysis is carried out using SQL language and spatial extensions included on PostGIS, extensions that follow the ‘Simple Features for SQL’ guidelines, from the Open Geospatial Consortium. Finally, the result from the spatial analysis are assessed and compared. Key-Words: - PostGIS, PostgreSQL, ArcGIS, Spatial Database, SQL Spatial, Open Geospatial Consortium 1 Introduction 2 Spatial analysis principles The software PostGIS [8] (developed by Refractions The purpose is to found the optimum location for a Research Inc.) add a medium to store geographic laboratory with the following requirements: objects to the relational database PostgreSQL. In this way, a PostgreSQL server can be used as a backend - Located on brushes area (type of soil code equal for a Geographic Information Systems (GIS). As one to 300) of the most common task working with a GIS is the - Located on soil suitable for building (type of soil spatial analysis, this paper firstly describes the use code higher than 0) necessary steps and secondly discusses the problems - Located close to sewer network (distance lower that appear when trying to carry out a spatial analysis than 300m.) with PostGIS, using a spatial database. Thus, for - Located away from rivers (up to 20m. for small each stage of the analysis, the different queries rivers and up to 40m. for big ones) statements are described and commented. - Area bigger than 5 000 m2. In order to contrast the obtained results, the same analysis is performed also with a commercial program: ArcGIS, from ESRI [1]. The main 2.1 Available Cartography difference between them is that PostGIS is a program Datasets provided for the spatial analysis consist on distributed under GPL licence, and ArcGIS is four layers on shape format [4], and a table on dbf privative software. Furthermore PostGIS is only a format: spatial database, while ArcGIS is also a complete solution of GIS Desktop. Thus, to visualize, design, - Layer ‘suelos’ (Fig. 1). Polygonal data layer that etc. PostGIS layers, is necessary to use other consists of 43 features describing soil types. software like the ones used in this article: JUMP Attribute table schema: (shape: polygon, tsuelo: 1.1.2 [5] and QGIS 0.6 [10]. short int {0, 1, 2, 3},{unsuitable, lower The hardware and the software employed in the suitability, medium suitability, high suitability}). analysis described in this paper are: - Layer ‘usos’ (Fig. 2). Polygonal data layer that consists of 76 features describing the different - ArcGIS 9.0 running under Windows XP SP2 kind of soil uses. Attribute table schema: (shape: operating system polygon, tuso: short int {100,200,300, - PostGIS 0.9.0, PostgreSQL 7.4.6, GEOS 2.0.1 400,500,600,700},{Urban, Agriculture, Thicket, under Suse Linux 9.1 operating system. Wood, Water, Wetland, Badlands}). - Hardware: Notebook with Pentium Centrino - Layer ‘river’ (Fig. 3). Lineal data layer that processor 1.5 GHz. (Intel). 512Mb RAM consists of 106 features describing the existing rivers. Attribute table schema: (shape: line, trio: short int {1, 2},{Minor, Major}). - Layer ‘alcanta’ (Fig. 4). Lineal data layer that consists of 6 features describing the sewer network. Attribute table schema: (shape: line, id: short int {0}). The attribute id is not used, but it has been created as a layer on a shape format must have at least one field, apart from the geometric one (in ArcGIS 9). Fig. 4. Layer ‘alcanta’ - Table ‘riodist’ with the correspondences within rivers and distances in order to complete the proximity analysis. Fig. 1. Layer ‘suelos’ Trio dist 1 40 2 20 The first step in both spatial analyses, the ArcGIS one as well as the PostGIS one, has been the conversion from the original shape format to the corresponding spatial databases (geodatabase in ArcGIS, or PostGIS tables in PostGIS). The conversion from shape to geodatabase is not compulsory as the analysis operations can be performed in both format. Anyway the conversion adds consistency to the comparison as it increases the criterion standards between both programs. Fig. 2. Layer ‘usos’ 3 Análisis con ArcGIS In order to perform the spatial analysis, the selected version has been the 9.x, as it adds the new analysis operation engine from ArcInfo that is enclosed in ArcGIS by means of ArcToolbox. The tool modelbuilder [3] has been used in this paper as it allows designing the flowchart in a visual way (Fig. 5). In this way the model, which defines all the spatial operations to perform, can be used to run, modify or repeat on a simple way all the analysis process. Fig. 3. Layer ‘rios’ The parameters considered in each analysis operation can be seen from the programming code in Jscript, corresponding to the ArcGIS analysis model. The code is the following one: // --------------------------------------------------- // ArcGIS generated script //modified by authors // --------------------------------------------------- // Create the Geoprocessor object var gp = WScript.CreateObject("esriGeoprocessing.GPDispatch.1"); // Set the necessary product code gp.SetProduct("ArcInfo"); // Load required toolboxes... gp.AddToolbox("C:/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx"); gp.AddToolbox("C:/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx"); gp.AddToolbox("C:/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx"); // Local variables... var test = "C:\\test"; var bd_mdb = test + "\\bd.mdb"; // Original Data var alcanta_shp = test + "\\alcanta.shp"; var rios_shp = test + "\\rios.shp"; var suelos_shp = test + "\\suelos.shp"; var usos_shp = test + "\\usos.shp"; var riodist_dbf = test + "\\riodist.dbf"; // Geodatabase Featureclasses var alcanta = bd_mdb + "\\alcanta"; var rios = bd_mdb + "\\rios"; var suelos = bd_mdb + "\\suelos"; var usos = bd_mdb + "\\usos"; var riodist = bd_mdb + "\\riodist"; // Intermediate Data var alcantabuf = bd_mdb + "\\alcantabuf"; var riosbuf = bd_mdb + "\\riosbuf"; var vrios_lyr = test + "\\vrios.lyr"; var vrios_lyr2 = test + "\\vrios.lyr"; var vrios = bd_mdb + "\\vrios"; var inter = bd_mdb + "\\inter"; var difbuf = bd_mdb + "\\difbuf"; var final = bd_mdb + "\\final"; var vinter = test + "\\vinter.lyr"; // Process: Create Personal GDB... gp.CreatePersonalGDB_management(test, "bd"); // Process: Feature Class To Feature Class... gp.FeatureClassToFeatureClass_conversion(alcanta_shp, bd_mdb, "alcanta", "", "id id VISIBLE", "DISABLED", "DISABLED", "", "0"); // Process: Buffer... gp.Buffer_analysis(alcanta, alcantabuf, "300,000000 Meters", "FULL", "ROUND", "ALL", ""); Fig. 5. Spatial analysis (modelbuilder) // Process: Feature Class To Feature Class (2)... gp.FeatureClassToFeatureClass_conversion(rios_shp, bd_mdb, - PostgreSQL JDBC extension objects "rios", "", "trio trio VISIBLE", "DISABLED", "DISABLED", "", corresponding to the geometries. "0"); // Process: Make Feature Layer... - OGC access functions defined by the Simple gp.MakeFeatureLayer_management(rios, vrios_lyr, "", "", "trio Features Specification (SFS). trio VISIBLE"); // Process: Table To Table... PostGIS verifies OGC specification [7] called gp.TableToTable_conversion(riodist_dbf, bd_mdb, "riodist", "", "trio trio VISIBLE;dist dist VISIBLE", ""); SFS ‘Simple Features for SQL’ [6], that’s the // Process: Add Join... document where the spatial predicates and operators gp.AddJoin_management(vrios_lyr, "trio", riodist, "trio", are described. Spatial predicates are functions which "KEEP_COMMON"); compare two spatial objects and return a boolean // Process: Copy Features... true/false result indicating the existence (or absence) gp.CopyFeatures_management(vrios_lyr2, vrios, "", "0", "0", "0"); of a particular spatial relationship. Some examples // Process: Buffer (2)... of spatial predicates are Contains(), Intersects(), gp.Buffer_analysis(vrios, riosbuf, "riodist_dist", "FULL", Touches(), and Crosses(). The spatial operators take "ROUND", "ALL", ""); two geometries and return a new derived geometric // Process: Erase... gp.Erase_analysis(alcantabuf, riosbuf, difbuf, ""); result. Examples of the operators include // Process: Feature Class To Feature Class (3)... Difference(), Union(), Buffer() and Intersection(). gp.FeatureClassToFeatureClass_conversion(suelos_shp, The current SFS version is the 1.1, and it is based on bd_mdb, "suelos", "", "tsuelo tsuelo VISIBLE", "DISABLED", SQL92, therefore object-relational concepts (that are "DISABLED", "", "0"); integrated on SQL99) are not included. However // Process: Feature Class To Feature Class (4)... gp.FeatureClassToFeatureClass_conversion(usos_shp, bd_mdb, PostgreSQL would be able to work with them, as it is "usos", "", "tuso tuso VISIBLE", "DISABLED", "DISABLED", "", an object-relational database. "0"); // Process: Intersect... gp.Intersect_analysis(suelos + ";" + usos, inter, "ALL", "", "INPUT"); 4.1 Spatial analysis // Process: Make Feature Layer (2)... As a previous step to the spatial analysis, some tasks gp.MakeFeatureLayer_management(inter, vinter, "[tsuelo] > 0 are necessary, like creating the database or importing AND [tuso] = 300", "", "FID_suelos FID_suelos VISIBLE;tsuelo the layers from the shape format. Thus, a script has tsuelo VISIBLE;FID_usos

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us