introducing postgis - the most powerful gis a database …files.meetup.com/19722453/6 - introducing...

33
Introducing PostGIS - The most powerful GIS a Database Could ProvidePresenter: Ali Tahir Institute of GIS, NUST Islamabad A. Tahir, PostGIS, Islamabad 2016

Upload: lynga

Post on 24-May-2018

221 views

Category:

Documents


2 download

TRANSCRIPT

“Introducing PostGIS - The most powerful GIS a

Database Could Provide”

Presenter: Ali Tahir

Institute of GIS, NUST

Islamabad

A. Tahir, PostGIS, Islamabad 2016

(Education) • Post-doc, Cardiff University, UK

• PhD, University College Dublin, Ireland

• Masters (GIS), University of Nottingham, UK

• BSc (CS), Oxford Brookes University, UK

(Current Engagements) • Assistant Professor, IGIS, NUST

• CEO, GIS Plus Total Solutions (Pvt.) Ltd.

A. Tahir, PostGIS, Islamabad 2016

Brief Introduction

A. Tahir, PostGIS, Islamabad 2016

Few Players

• “A GIS can be defined as a computer application capable of

performing virtually any conceivable operation on geographic

information, from acquisition and compilation through

visualization, query, and analysis to modeling, sharing, and

archiving” (Longley et al., 1999, 2010)

A. Tahir, PostGIS, Islamabad 2016

Geographical Information Systems (GIS)

Source: (geoawesomeness.com)

A. Tahir, PostGIS, Islamabad 2016

5 most influential living people contributed

to GIS in 21st Century

ESRI

Uni. of California OSM

Google Maps

TOMTOM

• Open source software developer and

information technology professional

• Developed PostGIS as a side business with few other

folks

• Currently engaged in:

• PostGIS consulting

• Mapserver consulting

• General geospatial consulting:

Source: (http://blog.cleverelephant.ca/)

A. Tahir, PostGIS, Islamabad 2016

Paul Ramsey

• Hardware

• Software

• People

• Procedures

• Data

– Raster (continuous phenomenon)

– Vector (discrete feature)

A. Tahir, PostGIS, Islamabad 2016

GIS Components

A. Tahir, PostGIS, Islamabad 2016

Raster Examples

Spatial data types

A. Tahir, PostGIS, Islamabad 2016

Vector Examples

• Environmental management Land record management

• Natural resource management Energy use and planning

• Asset management (gas, electric, water, fiber optics)

• Agriculture Deforestation

• Urban planning Public health

• Transportation planning Defense

• Disaster management Crime analysis

• Navigation and routing Wildlife management

• Banking sector Tourism

A. Tahir, PostGIS, Islamabad 2016

GIS Application Areas

A. Tahir, PostGIS, Islamabad 2016

PostGIS can help

• A spatial/geographical database

• An extension of PostgreSQL

• A spatial support such as other DBMS (Oracle spatial, DB2 Spatial Extender, MS SQL Server etc.)

• Supports spatial data types (point, line, polygon, raster)

• Spatial indexing (R-tree) for efficient query search

• Spatial functions (a range of functions are available)

• All is happening within PostgreSQL

• The original developer of Postgis is a company called Refractions Research

A. Tahir, PostGIS, Islamabad 2016

What is PostGIS

A. Tahir, PostGIS, Islamabad 2016

What is PostGIS

• Conversion • Show the text representation of this point (ST_AsText)

• Convert this text string into a valid PostGIS geometry (ST_GeomFromText)

• Retrieval • How long is this line? (ST_Length)

• What is the perimeter of Pakistan? (ST_Perimeter)

• Comparison • Is China next to Pakistan? (ST_Touches)

• Is Paris in China? (ST_Contains)

• Generation • Calculate a 20km exclusion limit around Moose Factory!

(ST_Buffer)

• Consolidate Islamabad and Rawalpindi! (ST_Union)

A. Tahir, PostGIS, Islamabad 2016

PostGIS Spatial Functions

• Compiling from source

• Binary installers

– Windows

– OSX

– Redhat/Centos/Scientific Linux

– Ubuntu

– OpenSUSE and SUSE

• Enabling PostGIS

A. Tahir, PostGIS, Islamabad 2016

Download & Installation

• PostGIS (Spatial Database)

• GeoServer (Spatial web / Application server)

• GeoWebCache (Tile Caching)

• OpenLayers (JavaScript mapping library)

• GeoExt (ExtJS + OpenLayers)

• QGIS (Desktop GIS tool)

A. Tahir, PostGIS, Islamabad 2016

OpenGeoSuite

A. Tahir, PostGIS, Islamabad 2016

PostGIS Walkthrough

A. Tahir, PostGIS, Islamabad 2016

PostGIS Walkthrough

A. Tahir, PostGIS, Islamabad 2016

spatial_ref_system table

• The geometry_columns view defines the dimension,

geometry, and spatial reference system for each spatial table

in the PostGIS database that contains a geometry type.

A. Tahir, PostGIS, Islamabad 2016

Metadata table

• SELECT postgis_full_version();

• CREATE TABLE "smallworld" (

gid serial PRIMARY KEY,

"placename" varchar(50),

"comment" varchar(255),

"year" numeric,

"geom" geometry(Point,4326) );

• INSERT INTO smallworld ( geom, placename, comment, year)

VALUES (101 , 'Fairbanks', 'Into the Wild ...', 1992, ST_GeomFromText('POINT(-147.68920897258 64.8302537436281)', 4326));

A. Tahir, PostGIS, Islamabad 2016

Spatial queries

SELECT geom FROM smallworld;

0101000020E6100000E8AAF9FF0D7662C0EA1099E022355040

0101000020E6100000CFC2DFBFD7D965402330B95D63A044C0

0101000020E6100000D753F09FD2365AC043259A5810D24340

SELECT ST_AsText(geom) from smallworld;

POINT(-147.68920897258 64.8302537436281)

POINT(174.807586609872 -41.2530324129332)

POINT(-104.856605515189 39.6411238434471)

A. Tahir, PostGIS, Islamabad 2016

Spatial queries

• SELECT Name, ST_Perimeter(geom) FROM countries LIMIT 5;

"Aruba" ; 0.534111478028311 "Afghanistan" ; 48.4555439234347

"Angola" ; 56.3041942788958 "Anguilla" ; 0.436150640401324

"Albania" ; 8.70897648956512

• SELECT ST_Distance(

ST_GeomFromText('POINT(-104.8566 39.6411)'), -- Denver

ST_GeomFromText('POINT(-73.9991 40.7217)') -- New York );

30.8764149896001

A. Tahir, PostGIS, Islamabad 2016

Spatial queries

• Well-known text (WKT) • ST_GeomFromText(text, srid) returns geometry

• ST_AsText(geometry) returns text

• ST_AsEWKT(geometry) returns text

• Well-known binary (WKB) • ST_GeomFromWKB(bytea) returns geometry

• ST_AsBinary(geometry) returns bytea

• ST_AsEWKB(geometry) returns bytea

• Geographic Mark-up Language (GML) • ST_GeomFromGML(text) returns geometry

• ST_AsGML(geometry) returns text

• Keyhole Mark-up Language (KML) • ST_GeomFromKML(text) returns geometry

• ST_AsKML(geometry) returns text

• GeoJSON • ST_AsGeoJSON(geometry) returns text

• Scalable Vector Graphics (SVG) • ST_AsSVG(geometry) returns text

• And many more (see functions under public schema in pgadmin)

A. Tahir, PostGIS, Islamabad 2016

Spatial functions

A. Tahir, PostGIS, Islamabad 2016

Demo.

A. Tahir, PostGIS, Islamabad 2016

PostGIS Support

A. Tahir, PostGIS, Islamabad 2016

What’s Next!

A. Tahir, PostGIS, Islamabad 2016

OpenStreetMap

OpenStreetMap “The Free Wiki

World Map”

<node id="83211617" lat="33.644460" long=" 72.989947 " > <tag k="amenity" v="university"/> <tag k="name" v=“National University of Sciences and Technology"/> </node>

A. Tahir, PostGIS, Islamabad 2016

Few working applications

• Annual GIS DAY

http://gisday.igis.nust.edu.pk

A. Tahir, PostGIS, Islamabad 2016

Ali Tahir, Ph.D.

Institute of Geographical Information Systems (IGIS)

National University of Sciences and Technology (NUST)

H-12 campus, Islamabad

[email protected]

051-90854476

GIS Plus Total Solutions (Pvt.) Ltd.

Technology Incubation Center, CIE Building

Innovation Drive, H-12 campus NUST, Islamabad

[email protected]

0322-5020145

A. Tahir, PostGIS, Islamabad 2016

Contact

A. Tahir, PostGIS, Islamabad 2016

Thanks