02 Geographic scripting in uDig - halfway between user and developer
Open Source GISGeographic scripting in uDig - halfway between user and developer Geoinformation Research Group, Department of Geography University of Potsdam March 2013 Data in uDig Tutor: Andrea Antonello ydroloGIS nvironmental ngineering HydroloGIS S.r.l. - Via Siemens, 19 - 39100 Bolzano www.hydrologis.com
Which are the main vector geo-objects?The main spatial data types that are usually dealth with are: Point GeometryCollection MultiPoint LineString MultiLineString LinearRing Polygon MultiPolygon
(Multi)PointA Point models a single Coordinate, a MultiPoint models a collection ofpoints.
(Multi)LineStringThe LineString is what we generally call line. It has a length, but 0 area.
(Multi)PolygonPolygons 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 USAbut not attached to it, more than one polygon is merged into a single feature.
Vector data: Feature and FeatureTypeThe Feature represents probably the most central object for GISapplications. The FeatureType can be seen as the blueprint of the data.Vector data are composed of a geometry part and an attribute table. SimpleFeatureType: the_geom: LineString id: Integer road1 name: String length: Double id name length 1 road1 56.4 road2 2 road2 120.0 geometry attributes
FiltersA 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 applyboth to the alphanumeric values of an attribute table as well as to thegeometry.One example could be: give me all the cities of Canada that count morethan 10000 inhabitants.
Constraint Query LanguageThe Constraint Query Language is used to define expressions and filters inseveral parts of the uDig application.The uDig user help explains quite well how to use CQL. Online that can befound here.Examples: • CITY = Nelson • ATTR1 < (1 + ((2 / 3) * 4)) • ATTR1 < abs(ATTR2) • ATTR1 < 10 AND ATTR2 < 2 OR ATTR3 > 10
A few examples of CQL in uDigSelect every feature that contains a text rome.
Select all the cities in Italy that have more than 500000 inhabitants.
StyleStyle is that part that allows us to make maps look pretty and get the neededsymbolization and coloring of the contained data. The OGC defines theStyled Layer Descriptor (SLD) as the standard to style maps.To create SLD styles, the style editor of uDig can be used.
Raster data: GridCoverageA 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 followingschema contains the main definitions we will use: cols grid space raster values north rows 0,0 1200 1800 1800 1800 1200 1170 1130 1130 y (northing) west 2,1 1200 1170 1130 1100 east x res y res equator x (easting) south world space
When we talk about raster data in GIS we usually mean digitalelevation/terrain/surface models (DEM/DTM/DSM). DEMs can be used toextract various attributes useful for hydrologic, geomorphologic analyses.From the DEM maps like aspect, flowdirections, curvatures, gradient andextracted network can be calculated.Also ortophotos and in general georeferenced imagery is technicallyspeaking raster data.The difference between the two, is that imagery contains in each cell theinformation of the pixel color, while DEM or similar contain the value of thescientific entity (ex. the elevation value in a DEM).
CoordinateReferenceSystemWIKIPEDIA: "A spatial reference system (SRS) or coordinate referencesystem (CRS) is a coordinate-based local, regional or global system usedto locate geographical entities. A spatial reference system defines aspecific map projection, as well as transformations between differentspatial reference systems. Spatial reference systems are defined by theOGCs Simple feature access using well-known text, and support has beenimplemented by several standards-based geographic information systems.Spatial reference systems can be referred to using a SRID integer, includingEPSG codes defined by the International Association of Oil and GasProducers."
The DatumThe datum is a reference surface from which measurements are made(Wikipedia).Datums can be local, which are locally orientated ellissoid (no deviation onthe vertical, locally tangent), or global, which are used to cover the wholeglobe and designed to support satellitar measurements. global ellipsoid local ellipsoid geoid
Example DatumsRoma 40 local datum based on Hayford ellipsoid, with prime meridian on Monte MarioEuropean 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 earths mass center. Used for example in the classic GPS CRS (EPSG:4326)
The Universal Transverse Mercator (UTM)UTM maps the Earth with a transverse cylinder projection using 60 differentmeridians, each of which is a standard "UTM Zone". By rotating the cylinderin 60 steps (six degrees per step, about 800Km) UTM assures that all spotson the globe will be within 3 degrees from the center of one of the 60cylindrical projections.
Coordinate reprojection and transform, the (not so small) differenceOften 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 doesnt 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.
CoordinateReferenceSystems in uDigIn uDig data that have a projection information are reprojected on the fly. Thedata 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:
CoordinateReferenceSystems messRemeber: a CRS has an area of validity. On small portions one cantransform between lat/long and UTM32N without problems.
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.