1 / 25

Web-Based Open Source GIS: Decision Support Tools Explaining the Software Stack Presented by

Web-Based Open Source GIS: Decision Support Tools Explaining the Software Stack Presented by Aaron Racicot – GIS Programmer aaronr@ecotrust.org April 19th, 2006. A Citizen of Salmon Nation. Outline. Introduction - Ecotrust Benefits/Limitations of Open Source OCEANSystem

gamma
Download Presentation

Web-Based Open Source GIS: Decision Support Tools Explaining the Software Stack Presented by

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web-Based Open Source GIS: Decision Support Tools Explaining the Software Stack Presented by Aaron Racicot – GIS Programmer aaronr@ecotrust.org April 19th, 2006 A Citizen of Salmon Nation

  2. Outline • Introduction - Ecotrust • Benefits/Limitations of Open Source • OCEANSystem • Problem description • Technology Overview - Software Stack • FORESTSystem • Problem description • Technology Overview - Software Stack • Where is it all going?

  3. Who am I… B.S. Computer Science M.S. Environmental Science Telemark/BC Skiing Rafting Guide Mountain Rescue Open Source User/Developer GIS Programmer Split Personality

  4. Ecotrust - Salmon Nation

  5. Benefits/Limitations of Open Source Benefits • Software cost = $0 • Source code is available and modifiable • User and development communities flourish • Development cycles are VERY fast Limitations • Total cost is NOT = $0 • Many applications are not as polished as the proprietary counterparts • Compatibility with proprietary software can be an issue

  6. Software Stacks… Desktop Desktop Software Stack

  7. Software Stacks... Server Server Software Stack

  8. Software Stack... DSTs (Ecotrust) DST Software Stack

  9. Work Flow – Real-Time Web DST Real-Time Web Decision Support Tools Web User Request Web Services Data Gathering Data Formatting Data Processing Static Data Storage Map Formatting Map Production Web User Response

  10. Work Flow – What OSGIS is good at Real-Time Web Decision Support Tools Web User Request Web Services Data Gathering Data Formatting Data Processing Static Data Storage Map Formatting Map Production The Problem Is The Arrows! Connecting a web request to server side GIS analysis is tricky Web User Response

  11. Data Flow... DSTs (Ecotrust)

  12. Raster based DST Siuslaw Watershed Restoration Initiative Data Gathering Data Formatting Data Processing PHP Mapscript GRASS

  13. Raster based DST - Code class Grass_GIS { var $data_dir; // Where the GRASS data dir is var $rc_dir; // Where the GRASS rc dir is var $bin_dir; // Where the GRASS bin dir is var $location; var $mapset; function Grass_GIS($data_dir, $rc_dir, $bin_dir, $location, $mapset){ $this->data_dir = $data_dir; $this->rc_dir = $rc_dir; $this->bin_dir = $bin_dir; $this->location = $location; $this->mapset = $mapset; } function Grass_GIS_copy($grass_gis){ $this->data_dir = $grass_gis->data_dir; $this->rc_dir = $grass_gis->rc_dir; $this->bin_dir = $grass_gis->bin_dir; $this->location = $grass_gis->location; $this->mapset = $grass_gis->mapset; } function set_location($location) {$this->location = $location;} function set_mapset($mapset) {$this->mapset = $mapset;} function set_data_dir($data_dir) {$this->data_dir = $data_dir;} function set_rc_dir($rc_dir) {$this->rc_dir = $rc_dir;} function set_bin_dir($bin_dir) {$this->bin_dir = $bin_dir;} function run_command($cmd){ $std_output = ""; $grass_exec = ""; // Check that all the required info is available.. if ($this->data_dir != NULL && $this->rc_dir != NULL && $this->bin_dir != NULL && $this->location != NULL && $this->mapset != NULL){ // Here we will write out the script to run... $fp_data = fopen($this->data_dir."/grass_run.sh","w"); // write out text header fwrite($fp_data,"export GISBASE=".$this->bin_dir." \n"); fwrite($fp_data,"export GISDBASE=".$this->data_dir." \n"); fwrite($fp_data,"export GISRC=".$this->rc_dir."/.grassrc6 \n"); fwrite($fp_data,"export ETC=".$this->bin_dir."/etc \n"); fwrite($fp_data,"export PATH=".$this->bin_dir."/bin:".$this->bin_dir."/scripts:".$this->bin_dir. "/garden/bin:\$PATH:/usr/bin:/usr/local/bin/ \n"); fwrite($fp_data,"export LOCATION_NAME=".$this->location." \n"); fwrite($fp_data,"export MAPSET=".$this->mapset." \n"); fwrite($fp_data,"export LOCATION=".$this->data_dir."/".$this->location."/".$mapset." \n"); fwrite($fp_data,"\n"); fwrite($fp_data,$cmd."\n"); fflush($fp_data); fclose($fp_data); $fp_data = fopen($this->rc_dir."/.grassrc6","w"); fwrite($fp_data,"GISDBASE: ".$this->data_dir."\n"); fwrite($fp_data,"LOCATION_NAME: ".$this->location."\n"); fwrite($fp_data,"MAPSET: ".$this->mapset."\n"); fwrite($fp_data,"PAINTER: ppm\n"); fwrite($fp_data,"MAPLP: stuff.ppm\n"); fflush($fp_data); fclose($fp_data); $grass_exec = sprintf("chmod u+x ".$this->data_dir."/grass_run.sh"); exec($grass_exec,$std_output,$std_error); $grass_exec = sprintf($this->data_dir."/grass_run.sh"); exec($grass_exec,$std_output,$std_error); }

  14. Raster based DST - Code define("GRASSDATA_DIR", "/var/www/html/apps/siuslaw_target/data/GRASSDATA/"); $location_name = "OR_siuslaw“; $mapset_name = "land_targets“; $session_grass_dir = $session_tmp_dir."/GRASSDATA"; // Make a Dir to work in echo " Make a directory to work in inside this session<br>"; $dir_exec = sprintf("mkdir ".$session_grass_dir); exec($dir_exec,$arr,$err1); $dir_exec = sprintf("mkdir ".$session_grass_dir."/rc"); exec($dir_exec,$arr,$err1); $template_path = GRASSDATA_DIR."siuslaw_epa_template"; echo " Copying over new GRASS GIS template<br>"; $dir_exec = sprintf("cp -R ".$template_path." ".$session_grass_dir."/".$location_name); exec($dir_exec,$arr,$err1); // Make a MAPSET echo " Setting up the siuslaw specific area<br>"; $dir_exec = sprintf("mkdir ".$ session_grass_dir."/".$location_name."/".$mapset_name); exec($dir_exec,$arr,$err1); // Copy over the projection info from the PERMANENT area echo " Setting projections<br>"; $dir_exec = sprintf("cp ".$template_path."/PERMANENT/PROJ* ".$ session_grass_dir."/".$location_name."/".$mapset_name."/"); exec($dir_exec,$arr,$err1); $grass_session = new Grass_GIS($session_grass_dir, $session_grass_dir."/rc", "/usr/local/grass-6.0.0", $location_name, $mapset_name); $grass_session->run_command("g.list type=rast");

  15. Vector based DST PHP -> PHPMapscript -> PostGIS PostGIS Mapserver

  16. Vector based DST - Code // Now connect to the db $host_str = "host=localhost"; $db_str = "dbname=shelf_closure_db"; $usr_str = "user=web_user"; $string = $host_str." ".$db_str." ".$usr_str; $connection = pg_connect($string); if (!$connection){ pg_close($connection); echo "Error: Cannot connect to the database <br>\n"; } else { echo "Connected to the SCA database <br>\n"; } // Create a dynamic VIEW in PostGIS echo "<b>* Create postgresql VIEW * </b><BR>\n"; $exec_str = sprintf("CREATE VIEW ". $previous_session_name."_".$previous_session_id." AS ". "SELECT bk.the_geom, sum(tr.total_lbs*tb.percent) as total_lbs ". "FROM tow%02d_3kblk_intersect as tb, trawl%02d". " as tr, cablk3km as bk, port as pt ". "where tb.blk_gid=bk.gid ".$species_sql." ".$port_sql." ".$gear_sql. " and tb.tow%02d_id=tr.tow_id2 ". "GROUP BY bk.the_geom HAVING count(tr.tow_id2)>2", $start_year_short,$start_year_short,$start_year_short); $result_pg_exec = pg_exec($connection, $exec_str); if (!$result_pg_exec) { printf("<B>%s</B><BR>\n", pg_errormessage());}

  17. Vector based DST - Code // Execute the pgsql2shp to create the output echo "<B>* Execute pgsql2shp create the shapefile in session directory *</B><br>"; $dir_exec = sprintf("/usr/local/pgsql/bin/pgsql2shp -u web_user -f ". $session_tmp_dir."data/target_areas/test_output.shp shelf_closure_db ". "\"SELECT * from ".$previous_session_name."_".$previous_session_id."\""); exec($dir_exec,$arr,$err1); for ($ii=0;$ii<count($arr);$ii++) { echo $arr[$ii]."<br>\n"; } // Drop the dynamic table echo "<b>* DROP the postgresql VIEW * </b><BR>\n"; $result_pg_exec = pg_exec($connection, "DROP VIEW ". $previous_session_name."_".$previous_session_id); if (!$result_pg_exec) { printf("<B>%s</B><BR>\n", pg_errormessage()); }

  18. 13 Step Tool Install 1) First install Fedora Core4 with updates 2) Ming wget http://easynews.dl.sourceforge.net/sourceforge/ming/ming-0.3beta1.tar.gz tar -xzvf ming-0.3beta1.tar.gz cd ming-0.3beta1 make make static cd php_ext/ make make install echo "Don't forget to add 'extension=php_ming.so' to php.ini!" 3) Pdflib wget http://www.pdflib.com/products/pdflib/download/602src/PDFlib-Lite-6.0.2.tar.gz tar -xzvf PDFlib-Lite-6.0.2.tar.gz cd PDFlib-Lite-6.0.2 ./configure make make install 4) Update ldconfig Add /usr/local/lib to /etc/ld.so.conf Run : /sbin/ldconfig 5) Proj.4 tar -xzvf proj-4.4.9.tar.gz cd proj-4.4.9 cd nad/ ls cp ../../proj-nad27-1.2.tar.gz . tar -xzvf proj-nad27-1.2.tar.gz cd .. ./configure make make install 6) GDAL Installed the ECW SDK (do a configure, make and install) Installed the MrSid SDK (moved to /usr/local) wget http://gdal.org/dl/gdal-1.3.1.tar.gz tar -xzvf gdal-1.3.1.tar.gz cd gdal-1.3.1 ./configure --with-ecw --with mrsid=/usr/local/GeoExpressSDK/ make ogr-all make install which gdalinfo 7) GEOS wget http://geos.refractions.net/geos-2.2.1.tar.bz2 tar -xjvf geos-2.2.1.tar.bz2 cd geos-2.2.1 ./configure make make install 8) POSTGRESQL tar -xzvf postgresql-8.1.2.tar.gz cd postgresql-8.1.2 NOTE the LDFLAGS here... this is to support GEOS for postGIS LDFLAGS=-lstdc++ ./configure --with-perl --prefix=/usr/local/pgsql_8_1_2 gmake gmake install Add the shared library path to /etc/ld.so.conf : /usr/local/pgsql_8_1_2/lib Run /sbin/ldconfig Run make install in the ./doc directory to install the documentation Finally add the following to the profile file to make paths available: PATH=$PATH:/usr/local/pgsql/bin MANPATH=$MANPATH:/usr/local/pgsql/man export MANPATH Add the postgis user useradd postgis passwd [postgis@localhost pgsql]$ postmaster -D ./data/ > ./data/logfile.txt 2>&1 &

  19. 13 Step Tool Install 9) POSTGIS Just make sure that the Postgresql is configured with the LDFLAGS variable set and that the GEOS software is downloaded and installed from Refractions. ./configure --with-proj --with-geos --with-pgsql make make install Now we can create the database: createdb -O aaronr test_db createlang -U aaronr plpgsql test_db psql -f /usr/local/pgsql_8_1_2/share/postgresql/contrib/lwpostgis.sql -d test_db 10) PHP ./configure --prefix=/usr/local/php4 --program-suffix=4 --enable-force-cgi-redirect --with-config-file-path=/etc/httpd/ --with-gd=/usr/local/ --with-jpeg --with-png --with-tiff --with-zlib --with-freetype-dir --without-ttf --with-mysql --with-regex=system --enable-dbase --enable-dbx --enable-versioning --with-pgsql=/usr/local/pgsql_8_1_2/ make make install strip sapi/cgi/php cp sapi/cgi/php /var/www/cgi-bin/php4 cp php.ini-dist /etc/httpd/php.ini Made the following mod to /etc/httpd/php.ini: ; Directory in which the loadable extensions (modules) reside. ;extension_dir = "./" extension_dir = "/etc/httpd/php_mods" mkdir /etc/httpd/php_mods Added the following to /etc/httpd/conf/httpd.conf # # For PHP scripts as CGI-BIN # AddType application/x-httpd-php-cgi .php4 .phtml Action application/x-httpd-php-cgi /cgi-bin/php4 Now re-start the server: /etc/rc.d/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] 11) MAPSERVER ./configure --with-jpeg --with-gd --with-freetype --with-zlib --with-png --with-pdf --without-tiff --with-proj --with-threads --with-ogr --with-gdal --with-postgis --with-wfs --with-wmsclient --with-wfsclient --enable-debug --with-php=/src/php/php-4.4.2 make cp legend mapserv scalebar /var/www/cgi-bin/ cp mapscript/php3/php_mapscript.so /etc/httpd/php_mods/ 12) GRASS CFLAGS="-g -Wall" ./configure --with-gdal=/usr/local/bin/gdal-config --with-postgres-includes=/usr/local/pgsql/include/ --with-postgres-libs=/usr/local/pgsql/lib/ make make install 13) R-Statistics tar -xzvf R-2.1.1.tar.gz cd R-2.1.1 ./configure make make install

  20. Where to go for more info OSGIS • Maptools - http://www.maptools.org • FreeGIS - http://freegis.org/ • Open Source GIS - http://opensourcegis.org/ Standards • OGC - http://www.opengeospatial.org/ Desktop • GRASS - http://grass.itc.it/ • QGIS - http://qgis.org/ • UDIG - http://udig.refractions.net/confluence/display/UDIG/Home • JUMP – http://jump-project.org/ • OpenEV - http://openev.sourceforge.net/ Server/Web • Mapserver - http://mapserver.gis.umn.edu/ • GRASS - http://grass.itc.it/ • PostGIS - http://postgis.refractions.net/ Tools • Remote Sensing - http://remotesensing.org/tiki-index.php • GDAL/OGR - http://gdal.maptools.org/index.html • PROJ.4 - http://proj.maptools.org/ • R-Statistics - http://www.r-project.org/ • GMT - http://gmt.soest.hawaii.edu/

  21. The End Tool Screen Shots Follow

  22. Backup - GRASS

  23. Backup – R-Statistics

  24. Backup – PostGIS Geometry WKT Geometry

  25. Backup - QGIS

More Related