PostGIS provides series of abilities to the PostgreSQL object-relational database including saving, searching and changing spatial relationships. PostGIS is an external extension of the PostgreSQL.
PostgreSQL is an open source database and PostGIS makes the PostgreSQL become a really large-scale database. SuperMap introduces the engine “SDX+ for PostGIS” for accessing PostgreSQL database directly and utilizing the spatial information service database ability fully, like: spatial objects, spatial indexes, spatial functions and spatial operators and so on thereby to manage spatial data efficiently.
This article will introduce PostGIS through following aspects:
Deploy the PostGIS object-relational database environment
Create PostGIS databases
SDX+ for PostGIS
Create PostGIS-based datasources
Edit PostGIS spatial data
Display PostGIS spatial data
Deploy the PostGIS object-relational database environment
Install and configure PostgreSQL and PostGIS.
- Step one : For more details about how to install and configure PostgreSQL, please refer to Installing PostgreSQL“.
After finishing installing PostgreSQL, find out the pg_hba.conf file from the saving-data direcory of database (like D:\Program Files\PostgreSQL\9.6\data) and then add the contents (in the orange box) into the file as the following picture shows to make the PostgreSQL database service accessible by an IP address.
- Step two : Install and configure PostGIS
- Run the installing program like postgis23_pg95.exe.
- Here you can select “Create spatial database” to create a database following the guide dialog box after finishing the installation, or you can create a database through the tool pgAdmin after finishing the installation.
- Specify the installation path and then click Next.
- After installation, following dialog pops up to ask you some configurations on raster functions, and you can choose as your needs, here we click “Yes”.
Create a PostGIS database
First, you must ensure that the PostgreSQL database service has been started. And then create a PostgreSQL database by pgAdmin for managing PostGIS spatial data. The operations in detail are:
- Run pgAdmin. Right click “Databases” and select Create > Database…
- Specify a name, an owner, one kind of encoding types, etc. for the database you want to create.
- Click “Save” to finalize the creation.
SDX+ for PostGIS
SuperMap manages PostGIS spatial data in the PostgreSQL database through the engine “SDX+ for PostGIS” and all workings on maintaining tables in the PostgreSQL database are done by SDX+ for PostGIS.
Managements of PostGIS spatial data contain: create databases, create/remove datasources, create/remove datasets, add/remove records (geometry objects) add/remove fields into/from datasets, update filed values and data query, and so on.
- Create PostGIS datasources
- When you are creating PostGIS-based datasource with SuperMap iDesktop, you can specify either an existing database name or a new database name, and a corresponding PostgreSQL database is produced first and then the datasource is created. One PostgreSQL database can be used for creating only one PostGIS-based datasource.
- In the meanwhile, after creating the PostGIS-based datasource, there are series of system tables being added for datasource management.
- You are allowed to create or import a datasource into a PostGIS-based datasource. The dataset types supprted by the engine SDX+ for PostGIS contain: point, line, region, text, CAD, tabular, 3D point/line/region/model, EPS complex point/line/region/text, raster, image, mosaic datasets. Besides, if there is existed third-party data conforming to PostGIS spatial data structure in the specified database, the data also will be read and managed by the created PostGIS-based datasource.
- Edit PostGIS spatial data
All kinds of edit operations are allowed by SDX+ for PostGIS:
- Add/remove geometry objects (points, lines, polygons, text).
- Editing geometry objects includes editing vertexes of objects, splitting objects, processing doughnut polygons and so on.
- Geometric object operations includes merging, intersecting and so on.
- PostGIS Spatial data display
- SDX+ for PostGIS allows to visualize PostGIS spatial data, that is you can configure styles, create various thematic maps based on PostGIS spatial data.
- All operations supported by the engine “SDX+ for PostGIS” to PostGIS spatial data are implemented by docking PostGIS functions (including geometry objection operations and raster data operations). At present, the PostGIS functions docked by SDX+ for PostGIS are sufficient for mapping and basic spatial analysis. If the function you need is out of the range, please refer to PostGIS manual: https://postgis.net/docs/manual-2.4/