02 geographic scripting in udig - halfway between user and developer

21

Click here to load reader

Upload: andrea-antonello

Post on 15-Apr-2017

1.132 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: 02 Geographic scripting in uDig - halfway between user and developer

nvironmental ngineeringydroloGISHydroloGIS S.r.l. - Via Siemens, 19 - 39100 Bolzano www.hydrologis.com

Open Source GIS

Geographic scripting in uDig - halfwaybetween user and developer

Geoinformation Research Group, Department of GeographyUniversity of Potsdam

March 2013

Data in uDigTutor: Andrea Antonello

Page 2: 02 Geographic scripting in uDig - halfway between user and developer

Which are the main vector geo-objects?

The main spatial data types that are usually dealth with are:

Point

MultiPoint

LineString MultiLineString

LinearRingPolygon MultiPolygon

GeometryCollection

Page 3: 02 Geographic scripting in uDig - halfway between user and developer

(Multi)Point

A Point models a single Coordinate, a MultiPoint models a collection of

points.

Page 4: 02 Geographic scripting in uDig - halfway between user and developer

(Multi)LineString

The LineString is what we generally call line. It has a length, but 0 area.

Page 5: 02 Geographic scripting in uDig - halfway between user and developer

(Multi)Polygon

Polygons have a length (perimeter) and an area. They can also have holes.

An example of MultiPolygons can be seen above. Alaska is part of the USA

but not attached to it, more than one polygon is merged into a single feature.

Page 6: 02 Geographic scripting in uDig - halfway between user and developer

Vector data: Feature and FeatureType

The Feature represents probably the most central object for GIS

applications. The FeatureType can be seen as the blueprint of the data.

Vector data are composed of a geometry part and an attribute table.

road1

road2

id name length

1

2

road1

road2

56.4

120.0

geometry attributes

SimpleFeatureType: the_geom: LineString id: Integer name: String length: Double

Page 7: 02 Geographic scripting in uDig - halfway between user and developer

Filters

A Filter defines a constraint that can be checked against an object.

A filter can be seen as the WHERE clause of an SQL statement. It can apply

both to the alphanumeric values of an attribute table as well as to the

geometry.

One example could be: give me all the cities of Canada that count more

than 10000 inhabitants.

Page 8: 02 Geographic scripting in uDig - halfway between user and developer

Constraint Query Language

The Constraint Query Language is used to define expressions and filters in

several parts of the uDig application.

The uDig user help explains quite well how to use CQL. Online that can be

found here.

Examples:

• CITY = 'Nelson'

• ATTR1 < (1 + ((2 / 3) * 4))

• ATTR1 < abs(ATTR2)

• ATTR1 < 10 AND ATTR2 < 2 OR ATTR3 > 10

Page 9: 02 Geographic scripting in uDig - halfway between user and developer

A few examples of CQL in uDig

Select every feature that contains a text rome.

Page 10: 02 Geographic scripting in uDig - halfway between user and developer

Select all the cities in Italy that have more than 500000 inhabitants.

Page 11: 02 Geographic scripting in uDig - halfway between user and developer

Style

Style is that part that allows us to make maps look pretty and get the needed

symbolization and coloring of the contained data. The OGC defines the

Styled Layer Descriptor (SLD) as the standard to style maps.

To create SLD styles, the style editor of uDig can be used.

Page 12: 02 Geographic scripting in uDig - halfway between user and developer

Raster data: GridCoverage

A GridCoverage is what in the real world we usually call Raster or Grid, i.e.

a rectangular regular grid of pixels, each containing a value. The following

schema contains the main definitions we will use:

cols

rows

x res

y re

s

north

wes

t

0,0

2,1

x (easting)

y (n

orth

ing)

grid space

world space

east

south

1200

1200

1200

1800

1170

1170

1800

1130

1130

1800

1130

1100

raster values

equator

Page 13: 02 Geographic scripting in uDig - halfway between user and developer

When we talk about raster data in GIS we usually mean digital

elevation/terrain/surface models (DEM/DTM/DSM). DEMs can be used to

extract various attributes useful for hydrologic, geomorphologic analyses.

From the DEM maps like aspect, flowdirections, curvatures, gradient and

extracted network can be calculated.

Also ortophotos and in general georeferenced imagery is technically

speaking raster data.

The difference between the two, is that imagery contains in each cell the

information of the pixel color, while DEM or similar contain the value of the

scientific entity (ex. the elevation value in a DEM).

Page 14: 02 Geographic scripting in uDig - halfway between user and developer

CoordinateReferenceSystem

WIKIPEDIA: "A spatial reference system (SRS) or coordinate reference

system (CRS) is a coordinate-based local, regional or global system used

to locate geographical entities. A spatial reference system defines a

specific map projection, as well as transformations between different

spatial reference systems. Spatial reference systems are defined by the

OGC's Simple feature access using well-known text, and support has been

implemented by several standards-based geographic information systems.

Spatial reference systems can be referred to using a SRID integer, including

EPSG codes defined by the International Association of Oil and Gas

Producers."

Page 15: 02 Geographic scripting in uDig - halfway between user and developer

The Datum

The datum is a reference surface from which measurements are made

(Wikipedia).

Datums can be local, which are locally orientated ellissoid (no deviation on

the vertical, locally tangent), or global, which are used to cover the whole

globe and designed to support satellitar measurements.

local ellipsoid

global ellipsoid

geoid

Page 16: 02 Geographic scripting in uDig - halfway between user and developer

Example Datums

Roma 40

local datum based on Hayford ellipsoid, with prime meridian on Monte

Mario

European Datum 50

local datum based on Hayford ellipsoid, tangent in Potsdam area,

with prime meridian in Greenwich. Used for UTM-ED50 CRS.

World Geodetic System WGS84

global datum with origin on the earth's mass center. Used for

example in the classic GPS CRS (EPSG:4326)

Page 17: 02 Geographic scripting in uDig - halfway between user and developer

The Universal Transverse Mercator (UTM)

UTM maps the Earth with a transverse cylinder projection using 60 different

meridians, each of which is a standard "UTM Zone". By rotating the cylinder

in 60 steps (six degrees per step, about 800Km) UTM assures that all spots

on the globe will be within 3 degrees from the center of one of the 60

cylindrical projections.

Page 18: 02 Geographic scripting in uDig - halfway between user and developer

Coordinate reprojection and transform, the (not so small) difference

Often reproject and transform are used the same way without much care.

There is a big difference though.

reproject

This is what we would call coordinate transform (CT). A CT can be

resolved in a well defined mathematical manner that doesn't lead to

precision loss (even if usually there is some minor due to data

precision and roundings).

transform

This is what we could call datum transform. Since datums are local

approximations of the geoid, transformations between datums are

based on statistical methods and lead most of the times to precision

loss.

Page 19: 02 Geographic scripting in uDig - halfway between user and developer

CoordinateReferenceSystems in uDig

In uDig data that have a projection information are reprojected on the fly. The

data from the Natural Earth dataset are in the geographic Lat/long WGS84.

Is it possible to reproject them in WGS 84 / UTM zone 32N?

Sure, open the CRS dialog and set it to the UTM zone of choice:

Page 20: 02 Geographic scripting in uDig - halfway between user and developer

CoordinateReferenceSystems mess

Remeber: a CRS has an area of validity. On small portions one can

transform between lat/long and UTM32N without problems.

Page 21: 02 Geographic scripting in uDig - halfway between user and developer

This work is released under Creative Commons Attribution ShareAlike (CC-BY-SA)

Much of the knowledge needed to create this training material hasbeen produced by the sparkling knights of the GeoTools, JTS anduDig community. Another essential source has been the Wikipediacommunity effort.

Particular thanks go to those friends that directly or indirectly helpedout in the creation and review of this series of handbooks.

This tutorial is brought to you by HydroloGIS.