Difference between revisions of "TerraHS"

From HaskellWiki
Jump to navigation Jump to search
(139 intermediate revisions by the same user not shown)
Line 1: Line 1:
  +
[[Category:GIS]] [[Category:Packages]] [[Category:Libraries]] [[Category:Graphics]]
[[Category:GIS]]
 
   
 
== What is it ? ==
 
== What is it ? ==
   
  +
[[Image:Logo terrahs.png]] is a software component that enables the development of geographical applications in a functional language, using the data handling capabilities and spatial operations of [http://www.terralib.org/ TerraLib]. TerraLib is a C++ library that supports different spatial database management systems, and that includes a large number of spatial algorithms. As a result, we get a combination of the good features of both programming paradigms.
   
  +
*[[Why to use Haskell for GIS programming ? ]]
We have developed TerraHS, a software component that enables the development of geographical applications in a functional language, using the data handling capabilities of TerraLib. TerraLib is a C++ library that supports different spatial database management systems, and that includes a large number of spatial algorithms. As a result, we get a combination of the good features of both programming paradigms.
 
   
  +
== Features ==
   
  +
*'''Input and output formats:''' Layers or themes from TerraLib databases (just MySQL), Esri Shape File (*.shp), TIFF file.
  +
*'''Data types:''' Raster or image (just 8 bits), Vectors (Point, Line, Polygon and Cell), Temporal (DateTime, Interval)
  +
*'''Topological operators''': intersects, within, touches, crosses ...
  +
*'''Geometric operations:''' intersection, union, difference, rotation.
  +
*'''Metrical operations:''' perimeter, area, distance, centroid, shapeindex, compacity, fractal
  +
== Demos ==
   
  +
Example of vector data that can be exported to a TerraLib database, and then it can be visualised with [http://www.dpi.inpe.br/terraview_eng/index.php TerraView].
== Documentation ==
 
   
  +
[[Image:Terraview.png|TerraView]]
=== Installation notes for Linux ===
 
   
  +
The pattern for a main program in TerraHS has the following structure:
The installation procedure for software dependencies in debian package.
 
   
  +
<haskell>
dpkg -i package.deb
 
  +
module Main(main) where
   
  +
import TerraHS
The uninstallation procedure for software dependencies in debian package.
 
   
  +
host = "localhost";
dpkg -r package
 
  +
dbname = "demo_terrahs";
  +
user = "root";
  +
password = "root";
   
  +
main:: IO()
The installation procedure for software dependencies in source file (tar.gz) is:
 
  +
main = do
  +
-- loading a vector data from a shape file
  +
gos <- loadVectorFile "MG_MUN96.shp"
  +
-- open a connection
  +
db <- open (TeMySQL host user password dbname)
  +
-- saving in a database layer
  +
store db "layer_name" gos
  +
print "saved"
  +
</haskell>
   
  +
Two different outcomes from a image data and theirs respective operations (a)input image, (b) inverted image and (c) reverse image.
'''Installing'''
 
tar xvzf package.tar.gz
 
cd package
 
./configure
 
make
 
make install
 
   
  +
[[Image:Res_imagens.png]]
The uninstallation procedure for software dependencies in source file is:
 
   
  +
The following examples use this [http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/data_demo.zip data]:
cd package
 
make uninstall
 
   
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/Opening_SavingShapeFiles.hs Opening and saving shape file]
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/Opening_SavingShapeFilesINDB.hs Opening a shape file and saving in database]
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/Opening_SavingtiffImagens.hs Opening and save tiff image files]
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/SpatialOper.hs Simple spatial operations demo]
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/SavingGeoobject.hs Understanding how to create a geoobject data type]
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/OpeningTifffromDB.hs Opening a raster data from database]
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/savingtiffImagensInDB.hs Opening a tiff file and saving in database]
  +
*[http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/samples/GeoObjectExample.hs Loading geoobjects from a database and saving a shape file]
   
  +
Its possible to run in the ghci:
=== Installation notes for Linux ===
 
  +
<pre>
  +
#ghci SpatialOper.hs
  +
</pre>
  +
Printing some test values, e.g.:
   
  +
<pre>
  +
Main> main
  +
Loading package syb ... linking ... done.
  +
Loading package base-3.0.3.0 ... linking ... done.
  +
Loading package terrahs-0.8 ... linking ... done.
  +
TePoint (12.5,10.0)
  +
TeLine2D [(1.0,1.0),(1.0,2.0),(1.0,7.0)]
  +
TePolygon [TeLine2D [(1.0,1.0),(1.0,2.0),(3.0,2.0),(3.0,1.0),(1.0,1.0)]]
  +
False
  +
True
  +
False
  +
2.0
  +
</pre>
   
=== Papers and Thesis ===
+
or compile and run:
   
  +
<pre>
  +
#ghc SpatialOper.hs -package terrahs-0.8 -o main
  +
#main
  +
</pre>
   
  +
More details about the api in [http://www.dpi.inpe.br/~scosta/softwares/terrahs/documentation/html/TerraHS/ source documentation - online (HTML)]
*[http://www.dpi.inpe.br/gilberto/papers/costa_geoinfo2006.pdf TerraHS: Integration of Functional Programming and Spatial Databases for GIS Application Development]. Sergio Costa, Gilberto Camara, Danilo Palomo. VIII Brazilian Symposium in Geoinformatics, GeoInfo 2006, Campos do Jordão, 2006.
 
*[http://www.dpi.inpe.br/gilberto/papers/olga_geoinfo2007.pdf Rule-based Evolution of Typed Spatio-temporal Objects]. Olga Bittencourt, Gilberto Câmara, Lúbia Vinhas, Joice Mota. IX Brazilian Symposium in Geoinformatics, GeoInfo 2007, Campos do Jordão, 2007.
 
*[http://mtc-m18.sid.inpe.br/col/sid.inpe.br/mtc-m18@80/2008/07.14.18.25/doc/publicacao.pdf Estrutura baseada em grafos para representação unificada de fluxos locais para modelagem hidrológica distribuída]. Sérgio Rosim´s PhD Thesis in Computer Science at INPE, 2008.
 
   
  +
== Download and Installation ==
=== Reports ===
 
  +
TerraHS is a Haskell GIS application built using the TerraLib GIS library. In below, is available a debian packages for [http://www.terralib.org/ TerraLib]. TerraHS-0.8 uses the TerraLib-3.3.0 version.
   
  +
Optional, but is recommended to install the [http://www.dpi.inpe.br/terraview_eng/index.php TerraView] application.TerraView is a GIS application based on TerraLib, a GIS library to handle vector and raster data in geographical DBMS such as Access, PostgreSQL, MySQL and Oracle Spatial.
=== Demos ===
 
   
  +
We have developed some specific libraries to support some functionalities for TerraHS.
== Download and Installation ==
 
  +
  +
*'''Translib''', a library for translation among different geographic format files (no database connection), based in the TerraLib library. This library is required for TerraHS to deal whith shape files (*.shp).
  +
  +
*'''Terralib4c''' is a library that maps c++ Terralib functions and classes to C functions.
  +
  +
Other requirements are: GHC-6.8.3(or newer version) and MySQL-5.0.41.
  +
  +
=== Installation notes for Windows ===
  +
First, is necessary to install MySQL 5.0, and optionaly TerraView:
  +
  +
[[Image:Logo-win.png]][http://www.dpi.inpe.br/terraview/dow/terraView330.exe TerraView-3.3.0 for Windows]
  +
  +
Other libraries are available in:
  +
  +
[[Image:Logo-win.png]][http://www.dpi.inpe.br/~scosta/softwares/terrahs/terrahsextlib.exe TerraHSdependecies install for Windows (TerraLIB+Terralib4C+Translib)]
  +
  +
After that, download [http://www.dpi.inpe.br/~scosta/softwares/terrahs/terrahs-0.8.zip TerraHS] and unzip the archive. From a prompt, move into the created directory and run the following commands:
  +
  +
runhaskell Setup configure --extra-lib-dirs: C:\TerraHSExtLibs
  +
runhaskell Setup build
  +
runhaskell Setup install
  +
  +
The extra-lib-dirs depend of the path where was installed the TerraHSdependencies.
  +
=== Installation notes for Debian distributions ===
  +
  +
The MySQL is usualy available in the Linux package of your distribution, you just check if it already installed.
  +
  +
For debian distributions, is possible to install they from debian packages:
  +
  +
Ubuntu 9.04 (i386)
  +
  +
[[Image:Ubuntu-icon.png]][http://www.dpi.inpe.br/~scosta/softwares/debian_packages/terralib-3.3.0.deb TerraLib-3.3.0 for (Ubuntu 9.04 (i386))]
  +
  +
[[Image:Ubuntu-icon.png]][http://www.dpi.inpe.br/~scosta/softwares/debian_packages/terraview-3.3.0.deb TerraView-3.3.0 for (Ubuntu 9.04 (i386))]
  +
  +
[[Image:Ubuntu-icon.png]][http://www.dpi.inpe.br/~scosta/softwares/debian_packages/terrahsdependecies-0.1.deb TerraHSdependecies (TerraLib4c + Translib) for Ubuntu 9.04 (i386)]
  +
  +
The TerraLib4c and Translib can be downloaded in separated way:
  +
  +
[[Image:Ubuntu-icon.png]][https://sourceforge.net/projects/translib/files/translib-0.1.deb/download Translib for Ubuntu 9.04 (i386)]
  +
  +
[[Image:Ubuntu-icon.png]][https://sourceforge.net/projects/terralib4c/files/terralib4c-0.1.deb/download Terralib4c for Ubuntu 9.04 (i386)]
  +
  +
Ubuntu 9.04 (amd64)
  +
  +
[[Image:Ubuntu-icon.png]][http://www.dpi.inpe.br/~scosta/softwares/debian_packages/terralib-3.3.0_64bits.deb TerraLib-3.3.0 for (Ubuntu 9.04 (amd_64))]
  +
  +
[[Image:Ubuntu-icon.png]][http://www.dpi.inpe.br/~scosta/softwares/debian_packages/terrahsdependecies-0.1_64bits.deb TerraHSdependecies (TerraLib4c + Translib) for Ubuntu 9.04 (amd_64)]
  +
  +
  +
The installation procedure:
  +
  +
#sudo dpkg -i package.deb
  +
  +
The uninstallation procedure:
  +
  +
#sudo dpkg -r package
  +
  +
After that, download [http://hackage.haskell.org/package/terrahs TerraHS] in cabal package from Hackage and unzip the archive. From a prompt, move into the created directory and run the following commands:
  +
  +
runhaskell Setup configure
  +
runhaskell Setup build
  +
sudo runhaskell Setup install
  +
  +
It is done.
  +
  +
=== Installation notes for generic Linux ===
  +
  +
The TerraLib and TerraView source files and instalation notes:
  +
  +
*[http://www.terralib.org/ TerraLib]
  +
*[http://www.dpi.inpe.br/terraview_eng/index.php TerraView].
  +
  +
TerraLib4c and Translib are available as usual source Linux package in:
  +
  +
[[Image:Linux-icon.png]][https://sourceforge.net/projects/translib/files/translib-0.1.tar.gz/download Translib Source]
  +
  +
[[Image:Linux-icon.png]][https://sourceforge.net/projects/terralib4c/files/Source/terralib4c-0.1.tar.gz/download TerraLib4c Source]
  +
  +
The installation procedure:
  +
  +
#tar xvzf package.tar.gz
  +
#cd package
  +
#./configure
  +
#make
  +
#sudo make install
  +
  +
The uninstallation procedure:
  +
#cd package
  +
#sudo make uninstall
   
  +
The installation of TerraHS is the same of Debian distribution:
=== Softwares dependencies ===
 
   
  +
runhaskell Setup configure
TerraHS requires the instalation of two additional libraries:
 
  +
runhaskell Setup build
  +
sudo runhaskell Setup install
   
  +
== Papers, thesis and Reports ==
'''Translib''', a library for translation among different geographic format files (no database connection), based in the TerraLib library. This library is required for TerraHS to deal whith shape files (*.shp).
 
  +
Some papers and thesis that use TerraHS:
  +
* Sérgio Costa, Gilberto Câmara, et.al. '''Prototyping GIS Application in Functional Programming'''. In: GeoPantanal, 2009, Corumbá. Anais do II Geopantanal, 2009. [http://www.geopantanal2009.cnptia.embrapa.br/cd/pdf/p23.pdf download]
   
  +
*Costa, S. S., Câmara, G., & Palomo, D. (2007). TerraHS: Integration of Functional Programming and Spatial Databases for GIS Application Development. (pp. 127-149).''' Advances in Geoinformatics'''. Springer. [http://www.springerlink.com/content/ur1266l1j371554h/ link]
*[https://sourceforge.net/projects/translib/files/translib0.1.deb/download Ubuntu 9.04 (x86)]
 
*[https://sourceforge.net/projects/translib/files/translib0.1.deb/download Source, generic Linux]
 
   
  +
*Sergio Costa, Gilberto Câmara, Danilo Palomo. '''TerraHS: Integration of Functional Programming and Spatial Databases for GIS Application Development'''. VIII Brazilian Symposium in Geoinformatics, GeoInfo 2006, Campos do Jordão, 2006. [http://www.geopantanal2009.cnptia.embrapa.br/cd/pdf/p23.pdf download]
'''Terralib4c''', a library that maps c++ Terralib functions and classes to C functions. Required by Haskell to do binding with TerraLib api.
 
   
  +
*Olga Bittencourt, Gilberto Câmara, Lúbia Vinhas, Joice Mota.''' Rule-based Evolution of Typed Spatio-temporal Objects'''. IX Brazilian Symposium in Geoinformatics, GeoInfo 2007, Campos do Jordão, 2007.[http://www.dpi.inpe.br/gilberto/papers/olga_geoinfo2007.pdf download]
*[https://sourceforge.net/projects/terralib4c/files/terralib4c0.1.deb/download Ubuntu 9.04 (x86)]
 
*[https://sourceforge.net/projects/terralib4c/files/Source/terralib4c-0.1.tar.gz/download Source, generic Linux]
 
   
  +
*Sérgio Rosim. '''Estrutura baseada em grafos para representação unificada de fluxos locais para modelagem hidrológica distribuída'''. PhD Thesis in Computer Science at INPE, 2008.[http://mtc-m18.sid.inpe.br/col/sid.inpe.br/mtc-m18@80/2008/07.14.18.25/doc/publicacao.pdf download]
=== TerraHS ===
 

Revision as of 21:53, 2 December 2009


What is it ?

Logo terrahs.png is a software component that enables the development of geographical applications in a functional language, using the data handling capabilities and spatial operations of TerraLib. TerraLib is a C++ library that supports different spatial database management systems, and that includes a large number of spatial algorithms. As a result, we get a combination of the good features of both programming paradigms.

Features

  • Input and output formats: Layers or themes from TerraLib databases (just MySQL), Esri Shape File (*.shp), TIFF file.
  • Data types: Raster or image (just 8 bits), Vectors (Point, Line, Polygon and Cell), Temporal (DateTime, Interval)
  • Topological operators: intersects, within, touches, crosses ...
  • Geometric operations: intersection, union, difference, rotation.
  • Metrical operations: perimeter, area, distance, centroid, shapeindex, compacity, fractal

Demos

Example of vector data that can be exported to a TerraLib database, and then it can be visualised with TerraView.

TerraView

The pattern for a main program in TerraHS has the following structure:

module Main(main) where

import TerraHS

host = "localhost";
dbname =  "demo_terrahs";
user = "root";
password = "root";

main:: IO()
main = do
	-- loading a vector data from a shape file
	gos <- loadVectorFile "MG_MUN96.shp"
	-- open a connection
	db <- open (TeMySQL host user password dbname)
	-- saving in a database layer
	store db "layer_name" gos
	print "saved"

Two different outcomes from a image data and theirs respective operations (a)input image, (b) inverted image and (c) reverse image.

Res imagens.png

The following examples use this data:

Its possible to run in the ghci:

 #ghci SpatialOper.hs 

Printing some test values, e.g.:

 Main> main
 Loading package syb ... linking ... done.
 Loading package base-3.0.3.0 ... linking ... done.
 Loading package terrahs-0.8 ... linking ... done.
 TePoint (12.5,10.0)
 TeLine2D [(1.0,1.0),(1.0,2.0),(1.0,7.0)]
 TePolygon [TeLine2D [(1.0,1.0),(1.0,2.0),(3.0,2.0),(3.0,1.0),(1.0,1.0)]]
 False
 True
 False
 2.0

or compile and run:

#ghc SpatialOper.hs -package terrahs-0.8 -o main
#main

More details about the api in source documentation - online (HTML)

Download and Installation

TerraHS is a Haskell GIS application built using the TerraLib GIS library. In below, is available a debian packages for TerraLib. TerraHS-0.8 uses the TerraLib-3.3.0 version.

Optional, but is recommended to install the TerraView application.TerraView is a GIS application based on TerraLib, a GIS library to handle vector and raster data in geographical DBMS such as Access, PostgreSQL, MySQL and Oracle Spatial.

We have developed some specific libraries to support some functionalities for TerraHS.

  • Translib, a library for translation among different geographic format files (no database connection), based in the TerraLib library. This library is required for TerraHS to deal whith shape files (*.shp).
  • Terralib4c is a library that maps c++ Terralib functions and classes to C functions.

Other requirements are: GHC-6.8.3(or newer version) and MySQL-5.0.41.

Installation notes for Windows

First, is necessary to install MySQL 5.0, and optionaly TerraView:

Logo-win.pngTerraView-3.3.0 for Windows

Other libraries are available in:

Logo-win.pngTerraHSdependecies install for Windows (TerraLIB+Terralib4C+Translib)

After that, download TerraHS and unzip the archive. From a prompt, move into the created directory and run the following commands:

runhaskell Setup configure --extra-lib-dirs: C:\TerraHSExtLibs 
runhaskell Setup build 
runhaskell Setup install 

The extra-lib-dirs depend of the path where was installed the TerraHSdependencies.

Installation notes for Debian distributions

The MySQL is usualy available in the Linux package of your distribution, you just check if it already installed.

For debian distributions, is possible to install they from debian packages:

Ubuntu 9.04 (i386)

Ubuntu-icon.pngTerraLib-3.3.0 for (Ubuntu 9.04 (i386))

Ubuntu-icon.pngTerraView-3.3.0 for (Ubuntu 9.04 (i386))

Ubuntu-icon.pngTerraHSdependecies (TerraLib4c + Translib) for Ubuntu 9.04 (i386)

The TerraLib4c and Translib can be downloaded in separated way:

Ubuntu-icon.pngTranslib for Ubuntu 9.04 (i386)

Ubuntu-icon.pngTerralib4c for Ubuntu 9.04 (i386)

Ubuntu 9.04 (amd64)

Ubuntu-icon.pngTerraLib-3.3.0 for (Ubuntu 9.04 (amd_64))

Ubuntu-icon.pngTerraHSdependecies (TerraLib4c + Translib) for Ubuntu 9.04 (amd_64)


The installation procedure:

 #sudo dpkg -i package.deb

The uninstallation procedure:

 #sudo dpkg -r package

After that, download TerraHS in cabal package from Hackage and unzip the archive. From a prompt, move into the created directory and run the following commands:

runhaskell Setup configure 
runhaskell Setup build 
sudo runhaskell Setup install 

It is done.

Installation notes for generic Linux

The TerraLib and TerraView source files and instalation notes:

TerraLib4c and Translib are available as usual source Linux package in:

Linux-icon.pngTranslib Source

Linux-icon.pngTerraLib4c Source

The installation procedure:

#tar xvzf package.tar.gz
#cd package
#./configure
#make
#sudo make install

The uninstallation procedure:

 #cd package
 #sudo make uninstall

The installation of TerraHS is the same of Debian distribution:

runhaskell Setup configure 
runhaskell Setup build 
sudo runhaskell Setup install 

Papers, thesis and Reports

Some papers and thesis that use TerraHS:

  • Sérgio Costa, Gilberto Câmara, et.al. Prototyping GIS Application in Functional Programming. In: GeoPantanal, 2009, Corumbá. Anais do II Geopantanal, 2009. download
  • Costa, S. S., Câmara, G., & Palomo, D. (2007). TerraHS: Integration of Functional Programming and Spatial Databases for GIS Application Development. (pp. 127-149). Advances in Geoinformatics. Springer. link
  • Sergio Costa, Gilberto Câmara, Danilo Palomo. TerraHS: Integration of Functional Programming and Spatial Databases for GIS Application Development. VIII Brazilian Symposium in Geoinformatics, GeoInfo 2006, Campos do Jordão, 2006. download
  • Olga Bittencourt, Gilberto Câmara, Lúbia Vinhas, Joice Mota. Rule-based Evolution of Typed Spatio-temporal Objects. IX Brazilian Symposium in Geoinformatics, GeoInfo 2007, Campos do Jordão, 2007.download
  • Sérgio Rosim. Estrutura baseada em grafos para representação unificada de fluxos locais para modelagem hidrológica distribuída. PhD Thesis in Computer Science at INPE, 2008.download