+ All Categories
Home > Documents > Visualizing and Managing GIS-Data Jan Kneschke

Visualizing and Managing GIS-Data Jan Kneschke

Date post: 29-Oct-2021
Category:
Upload: others
View: 6 times
Download: 0 times
Share this document with a friend
25
1 Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt Visualizing and Managing GIS-Data Jan Kneschke Trainer & Consultant MySQL GmbH MySQLComCon 2004 Frankfurt/Main, Germany
Transcript
Page 1: Visualizing and Managing GIS-Data Jan Kneschke

1Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Visualizing and Managing GIS-Data

Jan KneschkeTrainer & Consultant

MySQL GmbH

MySQLComCon 2004Frankfurt/Main, Germany

Page 2: Visualizing and Managing GIS-Data Jan Kneschke

2Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

• Jan Kneschke• Located in Kiel, Germany• Maintainer of lighttpd, modlogan and pxtools• Speaker at the PHPConf 2001, 2003 and 2004• For PEAR: Image_GIS• For MySQL: paradox Storage-Engine• Trainer for .de, .at and .ch

About the Speaker

Page 3: Visualizing and Managing GIS-Data Jan Kneschke

3Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Usage of GIS Data

• Base of scientific work in:– Geography– Geology– Sociology

• Routing, Mapping• Geologic Analisys• Environment Planning• Demographics

Page 4: Visualizing and Managing GIS-Data Jan Kneschke

4Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Usage of GIS Data

• Main purpose of GIS is combining geographic data with external datasets

• Remember the pictures of El-Niño

Page 5: Visualizing and Managing GIS-Data Jan Kneschke

5Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

GIS Support in MySQL 4.1

• GIS support included in MySQL 4.1• Based on the OpenGIS specification• Implements a subset of the full specification

– Indexing of GIS datasets by using R-Trees– All datatypes available– Some functions missing

Page 6: Visualizing and Managing GIS-Data Jan Kneschke

6Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Users of the GIS Support

• Citymap of Paderborn– High Resolution Map Generator for Users– Many requests

• Land Register of several counties in Northern Germany – Replication of common data– Every Land Register holds the data for the houses, streets

and so on on the lowests level– Huge datasets

Page 7: Visualizing and Managing GIS-Data Jan Kneschke

7Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

GIS Data

• Geographic Information System• Binding geographic objects to coordinates• Simple Geometric Objects:

– Lines: Streets, Rivers– Polygons: Political Boundaries– Points: Cities, Hills, Mountains

• Groups of minor objects– Collections: States, Countries, Continents

Page 8: Visualizing and Managing GIS-Data Jan Kneschke

8Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Creating Datasets

CREATE TABLE geo (

geoobjid INT NOT NULL AUTO_INCREMENT,

line LINESTRING NOT NULL,

type ENUM('Border', 'Street', 'River', 'popPlace') NOT NULL;

name VARCHAR(32),

PRIMARY KEY (geoobjid),

SPATIAL KEY (line)

);

Page 9: Visualizing and Managing GIS-Data Jan Kneschke

9Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Importing Data

• WKT (Well Known Text)– Human readable– LINESTRING(0 0, 0 10, 10 10)

– POLYGON(0 0, 0 10, 10 10, 10 0, 0 0)

• WKB (Well Known Binary)– Machine Readable– 0102000000020000000000000000000000000000000000000000000000000024400000000000000000

– Same as LINESTRING(0 0, 10 0)– Coordinates are represented by 64bit doubles

Page 10: Visualizing and Managing GIS-Data Jan Kneschke

10Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Importing Data - Datasources

• Shape files (SHP)– Binary format, easy to parse– Very popular in the US– Example project: http://flightstats.us/– Importer written by Jeremy Cole– libmygis

• ArcInfo (E00)– Base of the Digital Chart of the World (DCW)– Human Readable– Converters available in C, Perl and PHP

Page 11: Visualizing and Managing GIS-Data Jan Kneschke

11Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Importing Data - ArcInfo

• Pairs of Points• Building up connected Lines• Grouped together to Polygons

1.4212879E+01 5.3864784E+01 1.4213489E+01 5.3884834E+01

1.4212705E+01 5.3893837E+01 1.4208732E+01 5.3902344E+01

1.4196489E+01 5.3910194E+01 1.4182546E+01 5.3914932E+01

1.4206500E+01 5.3916485E+01 1.4224365E+01 5.3926537E+01

Page 12: Visualizing and Managing GIS-Data Jan Kneschke

12Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Importing Data - INSERT

• Plain INSERT• GeomFromText() to convert from WKT to internal

format• It's a bulk insert ! Use Multi-Row INSERTs

INSERT INTO de (line, type) VALUES

(GeomFromText('LINESTRING(-69.2893 -17.9578,-69.2963 -17.9504, ...)',

'Border');

Page 13: Visualizing and Managing GIS-Data Jan Kneschke

13Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Selecting Data

• It is SQL, use a SELECT• AsText(), AsBinary()

– Converting to WKT or WKB

SELECT AsText(line)

FROM geo

LIMIT 1;

LINESTRING(-70.3742 -18.3497, ...)

Page 14: Visualizing and Managing GIS-Data Jan Kneschke

14Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Selecting Data - MBR

• Minimum Bounding Rectangle• Every object has a MBR• For a point it is a point • For a horizantal or vertical line it is a line• For everything else it is polygon with a

area

SELECT AsText(Envelope(

GeomFromText('POINT(0 0)')));

POLYGON((0 0,0 0,0 0,0 0,0 0))

Page 15: Visualizing and Managing GIS-Data Jan Kneschke

15Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Selecting Data - Zooming

• Take a rectangle range from your data• Define a MBR around it• SELECT the data

SELECT AsText(line)

FROM geo

WHERE MBRCONTAINS(

GeomFromText(

'LINESTRING(-69.2 -18.5, -69.4 -17)'),

line);

Page 16: Visualizing and Managing GIS-Data Jan Kneschke

16Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Selecting Data

• Data is only a set of LINESTRINGs• Perfect for Drawing• What is resulting MBR for all the Lines (or in this case

the country) ?

SET @a = '';

SELECT @a := CONCAT(@a, IF(LENGTH(@a) > 0, ',',''), AsText(line))

FROM geo

WHERE MBRContains(GeomFromText('LineString(-69.1 -18.5, -70.9 -16)'), line);

SELECT AsText(Envelope(GeomFromText(CONCAT('GeometryCollection(', @a, ')'))));

Page 17: Visualizing and Managing GIS-Data Jan Kneschke

17Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Visualizing GIS Data

• Leaving the DB Area• Theory

– Projections– Coordinate Systems– Distance Calculations

• Practical Issues– Output Formats– Data Handling

Page 18: Visualizing and Managing GIS-Data Jan Kneschke

18Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Projection

• Mapping a 3 dimensional object on 2 dimensions• One of the following is loosing accuracy:

– Distance (equidistant)– Bearing – Scale– Direction (azimuthal)– Shape(conformal)– Area (equiareal)

• Equator has about 40.000km, Northpole just a few kilometers, but still it is the same coordinate system when it comes to longitude and latitude

Page 19: Visualizing and Managing GIS-Data Jan Kneschke

19Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Mapping

• Building a graphical projection• Take a reference object

– Cylindrical– Pseudocylindric– Conic– Pseudoconic– Azimuthal

• Choose what you want to preserve– Mercator– Azimuthal Equistant

Page 20: Visualizing and Managing GIS-Data Jan Kneschke

20Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Mapping - Mercator

Page 21: Visualizing and Managing GIS-Data Jan Kneschke

21Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Mapping - Azimuthal

Page 22: Visualizing and Managing GIS-Data Jan Kneschke

22Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Back to Code

• PEAR::Image_GIS– Parser for E00– Mapping for Mercator– Output for SVG and PNG– Very simple interface

<?php

require_once 'Image/GIS.php';

$map = new Image_GIS();

$map->addDataFile('ponet.e00', 'black');

$map->saveImage('somewhere.png');

?>

Page 23: Visualizing and Managing GIS-Data Jan Kneschke

23Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Image_GIS output

• South-America– Chile– A lot of cliffs at the south, pacific border– At the right bottom: border to fireland

Page 24: Visualizing and Managing GIS-Data Jan Kneschke

24Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

GIS Example

• Most visitors• Lower Saxony• Germany

Page 25: Visualizing and Managing GIS-Data Jan Kneschke

25Copyright 2004 MySQL AB Die populärste Open-Source-Datenbank der Welt

Further Reading

• GIS Support in MySQL: http://www.mysql.com/gis• Rendering in PHP: http://pear.php.net/image_gis• OpenGIS: http://www.opengeospatial.org/• German Free GIS-data: http://www.opengeodb.de/• Digital Chart of the World: http://data.geocomm.com/• GEOnet Names Server

http://earth-info.nga.mil/gns/html/index.html


Recommended