<<

PARTICIPANT’S GUIDE

Virtual Machine Connection Details

Hostname: hackwe1.cs.uwindsor.ca : 6.0 (“Squeeze”) IP Address: 137.207.82.181 Middleware: Node.js, , PHP, Python DBMS: MySQL, PostgreSQL Connection Type: SSH Web Server: Apache 2.2 UserID: root Available Text Editors: nano, vi Password: Nekhiav3 UserID: hackwe Feel free to install additional packages or tools. Password: Imusyeg6

Google Maps API Important Paths and Links

Follow this quick tutorial to get started Home Directory https://developers.google.com/maps/documentation/javascript/tutorial /home/hackwe The most common objects you will use are LatLng objects which store a lati- tude and longitude, and Marker objects which place a point on a Map object APT Package Management Tool help..com/community/AptGet/Howto LatLng Object developers.google.com/maps/documentation/javascript/reference#LatLng City of Windsor Open Data Catalogue Marker Object www.citywindsor.ca/opendata/Pages/Open-Data- developers.google.com/maps/documentation/javascript/reference#Marker Catalogue.aspx Map Object Windsor Hackforge developers.google.com/maps/documentation/javascript/reference#Map hackf.org

WeTech Alliance wetech-alliance.com

XKCD xkcd.com PARTICIPANT’S GUIDE

Working with Geospatial (SHP) Data in

Node.js Python To manipulate shape files in Python 2.x, you’ll need the pyshp package. These Required Libraries instructions will quickly outline how to install and use this package to get GIS data out of *.shp files. node-shp: Github - https://github.com/yuletide/node-shp Installation - https://npmjs.org/package/shp To install pyshp you first must have installed in your python site- packages. (To install setuptools on Windows, follow these instructions: http:// Installation stackoverflow.com/a/309783) $ npm install shp Ubuntu/Debian

$ sudo -get install python-setuptools Usage (Simple Example) Once you’ve installed setuptools, easy_install the improved python package var Shp = require('shp'); manager, . You’ll want to use pip to install any of the additional libraries Shp.readFile('path/to/shpfile_base_name', function (error, data){ your project requires: console.log(JSON.stringify(data)); $ easy_install pip }); Lastly, pip install the pyshp :

$ pip install pyshp Using pyshp

Now that the pyshp library is installed, you can use it in your python project: >>> import shapefile >>> file = shapefile.Read(‘filename.shp’) >>> shapes = file.shapes() # list of shape objects >>> shape1_coords = shapes[0].points # list of coor- dinate tuples

Further instructions can be found in the official documentation for pyshp: http://code.google.com/p/pyshp/wiki/PyShpDocs PARTICIPANT’S GUIDE

Working with Geospatial (SHP) Data in Linux

Perl PHP Required Libraries Required Libraries

App::cpanminus phpclasses - http://www.phpclasses.org/package/1741-PHP-Read-vectorial- http://search.cpan.org/dist/App-cpanminus/lib/App/cpanminus.pm data-from-geographic-shape-files.html pecl - http://pecl.php.net/package/dbase Geo::ShapeFile http://search.cpan.org/~jasonk/Geo-ShapeFile-2.52/lib/Geo/ShapeFile.pm Installation Installation $ apt-get install - $ pecl install dbase 1. Make sure you have gcc installed, because cpan requires make Add “extension=dbase.so” to /etc/php5/apache2/php.ini 2. Make sure CPAN minus is installed ($ sudo cpan App:cpanminus) 3. Install Geo::ShapeFile ($ sudo cpanm Geo::ShapeFile) Usage (Simple Example) 4. Follow this example: (rename Arenas to the name of the .shp file you’re working with. The .shp files must be in the same directory as your .pl file) false); //sets the options to show the polygon points, 'noparts' => true would skip that and save time Usage (Simple Example) //Create Shape object use Geo::ShapeFile; $shp = new ShapeFile("filename.shp",$options); my $shapefile = new Geo::ShapeFile("Arenas"); //Dump the ten first records $i = 0; for(1 .. $shapefile->shapes()) { while ($record = $shp->getNext() and $i<10) { my $shape = $shapefile->get_shp_record($_); $dbf_data = $record->getDbfData(); # see Geo::ShapeFile::Shape docs for what to do $shp_data = $record->getShpData(); with $shape //Dump the information my %db = $shapefile->get_dbf_record($_); var_dump($dbf_data); } var_dump($shp_data); $i++; } ?>