THINK OPEN, THINK FUTURE How to open polygons and doors using Python Marco Bernasocchi @mbernasocchi
Marco Bernasocchi MSc in GIS @ UNIZH Developer, Consultant, Teacher & foremost Geek Skier, Climber, Diver marco@opengis.ch
This Talk Open What?? Open Source! Does that do polygons also? I want it! I want it NOW Python, really!? Discussion & questions Download from http://goo.gl/vikqv9
Closed Source
Closed Source
Free/Libre Open Source Software Free to: Use, Learn, Change, Share free software is a matter of liberty, not price. To understand the concept, you should think of free as in free speech, not as in free beer.
You say who does that? Let me show you...
UBUNTU LINUX
GIMP
INKSCAPE
LIBRE OFFICE
FIREFOX
VLC
RHYTHMBOX
PYCHARM
APACHE/WORDPRESS
QGIS/InaSAFE
Impossible Business Model!? NOPE!
What about my polygons? They will be in the best hands with thanks to: Open Source Geospatial Foundation (OSGeo.org) Many passionated contributors Companies that do OS dev
OSGeo.org Is the reference organization http://live.osgeo.org (Live DVD/USB stick) whit many GIS related open source software Guarantees Quality and Long term Commitment Official and In Incubation Projects
(F)OSS GIS users NASA, ESA United Nations IGN (France), BKG (Germany) US Postal Service European Weather Forecast Centre (ECMWF) OpenStreetMap and Wikipedia Google, Microsoft and Apple GIS software vendors: ESRI, Autodesk Telcos: NTT (Japan)
Why FOSSGIS? Flexibility Speed of Development Ability to influence a project Cost sharing Scalability: No per-seat licensing costs Reuse instead of re-inventing the wheel More interesting and rewarding jobs
New Aspects with FOSSGIS Project versus product Different support channels Power users should invest financially in their key projects they use Quality assurance issues (testing) FOSS-GIS users have more responsibilities than consumers of a commercial product
OSGEO.ORG official projects Databases: Postgis, SpatiaLite, Rasdaman, etc. Geospatial Libraries: GDAL, OGR, PROJ4, GEOS, FDO, etc. Web Mapping Server: UMN Mapserver, Geoserver, MapGuide, QGIS Server, deegree Web Mapping Clients: OpenLayers, MapGuide, GeoExt, MapFish, MapBender, QGIS Webclient
OSGEO.ORG official projects Desktop GIS: GRASS GIS, Quantum GIS, gvsig Geospatial Toolboxes und ETL-Tools: SEXTANTE, OTB, Geokettle, SAGA Metadata Catalog: GeoNetwork Other Projects: Public Geospatial Data (OpenStreetmap, NaturalEarth), Education and Curriculum
Relationship-Diagram Foss4G
Real Example: QGIS Quantum GIS (QGIS) is a user friendly Open Source GIS. QGIS is an official project of the Open Source Geospatial Foundation (OSGeo). It runs on Linux, Unix, Mac OSX, Windows and Android and supports numerous vector, raster, and database formats and functionalities. QGIS Desktop QGIS Server QGIS Web Client QGIS on Android
Real Example: Msc Thesis
Real Example: GsoC 2011 5 ECTS 6000$ Eternal Glory ;)
Real Example: GIS in Uster Mixed Environment (FOSSGIS, commercial) Many different applications and databases (Postgis, Oracle, MySQL, SQL-Server) Usage of FME and OGR for data-transfer New Desktop-GIS and Webgis implemented with QGIS
FOSSGIS in Uster
QGIS in Uster QGIS-Server and Webclient for all webgis topics Wastewater and GEP topics Underground cadastre (Leitungskataster) Greenspace cadastre Nature and environment topics Denkmalschutzkataster Pupil assignments (Schülerzuteilung) Accident statistics (Unfallstatistik)
QGIS wastewater management
QGIS wastewater viewer
QA Database synchronisation
Simplified City Model with Buildings
Live Population Statistics
Live Population Statistics
Live Population Statistics Google Earth
Common Challenges Combination and integration with existing databases and applications Quality assurance of basic data Data exchange with National and regional gov GIS project management Missing cooperation and lack of comprehension for the big picture
I want it NOW! Get INVOLVED: TRY existing projects CONTRIBUTE to existing projects CREATE a new project SHARE your existing project
TRY Google open source whatever you need osalt.com - Find Open Source Alternatives to commercial software Github.com find source of thousends of projects ohloh.net statistics about OS projects
Contribute Testing/Bug reports Writing/Documentation Support Tutorials Start a group Share Remix Graphics/Design Programming
Who to ask? MAINTAINERS who manage the project you're interested in WEBSITES for the project may have a "get involved" section PROFESSORS may let you make your projects open source and guide you in getting involved EMPLOYERS because Open Source team experience IS 21st century employment
What about my bills? Summer-of-Codes (Google SOC, Ruby SOC, etc.) Internships at OS-friendly companies (Red Hat, Mozilla, Untangle, Canonical, etc.) Kickstarter Join (or start!) a company that uses open source
Ok, how do I make my project Open Source? Attach a license Share the code with others Use some social media for marketing
License, WTF!?!? Lots of licenses to choose from... to protect your work GPL Is now, and will forever be free BSD Is free, but new versions don't have to be free too Apache Similar to BSD Lots and lots more: IBM, Intel, MIT, Mozilla, Python, Microsoft Sun,...
And for the Data? Does wikipedia.org sound familiar? Creative Commons!
Ahh! now I get the opening doors in the title Open Source Opportunity Open Source Employment Open Source Involvement Open Source Social responsibility
Good, good, and now lets Snake Snake, not snack... Lets introduce a member of a family of nonvenomous snakes (some of which are some of the largest snakes in the world) found in Africa, Asia and Australia.
Behold the mighty Python
Or the geek friendly version of it...
What is Python? (adapted from Guido van Rossum, BDFL) O-O rapid prototyping language Not just a scripting language Not just another Perl Easy to learn, read, use Extensible (add new modules) C/C++/Fortran/whatever Java (through Jython) Embeddable in applications
Touchy-feely properties Open Source (OSI Certified) Mature (23 years old) Supportive user community copyrighted but use not restricted no "viral" license owned by independent non-profit, PSF plenty of good books, too Simple design, easy to learn reads like pseudo-code Suitable as first language Suitable as last language :-)
High-level properties Extremely portable Compiles to interpreted byte code Unix/Linux, Windows, Mac, PalmOS, WindowsCE, RiscOS, VxWorks, QNX, OS/2, OS/390, AS/400, PlayStation, Sharp Zaurus, BeOS, VMS compilation is implicit and automatic Memory management automatic reference counting for most situations GC added for cycle detection Safe : no core dumps due to your bugs
What is it used for? rapid prototyping web programming (client and server side) ad hoc programming ("scripting") steering scientific applications extension language XML processing database applications GUI applications education
Who is using it? Google (various projects) NASA (several projects) NYSE (one of only three languages "on the floor") Industrial Light & Magic (everything) Yahoo! (Yahoo mail & groups) RealNetworks (function and load testing) RedHat (Linux installation tools) LLNL, Fermilab (steering scientific applications) Zope Corporation (content management) ObjectDomain (embedded Jython in UML tool) Alice project at CMU (accessible 3D graphics) More success stories at www.pythonology.com
Language properties Everything is an object Packages, modules, classes, functions Exception handling Dynamic typing, polymorphism Static scoping Operator overloading Indentation for block structure Otherwise conventional syntax
High-level data types Numbers: int, long, float, complex Strings, Unicode: immutable Lists and dictionaries: containers Other types for e.g. binary data, regular expressions, introspection Extension modules can define new built-in data types
Interfaces to... XML DOM, expat XMLRPC, SOAP, Web Services Relational databases MySQL, PostgreSQL, Oracle, ODBC, Sybase, Informix Java (via Jython) Objective C COM, DCOM (.NET too) Many GUI libraries cross-platform platform-specific Tk, wxwindows, GTK, Qt MFC, Mac (classic, Cocoa), X11
Compared to Java Code up to 5 times shorter and more readable Dynamic typing Multiple inheritance, operator overloading Quicker development no compilation phase less typing Yes, it may run a bit slower but development is much faster and Python uses less memory (studies show) Similar (but more so) for C/C++
Example function def gcd(a, b): "greatest common divisor" while a!= 0: a, b = b%a, a return b # parallel assignment
Example class class Stack: "A well-known data structure" def init (self): # doc string # constructor self.items = [] def push(self, x): self.items.append(x) # the sky is the limit def pop(self): x = self.items[-1] # what happens if it s empty? del self.items[-1] return x def empty(self): return len(self.items) == 0
References and plugs Links: http://docs.python.org/tutorial/ http://en.wikiversity.org/wiki/introduction_to_programming http://en.wikibooks.org/wiki/introduction_to_programming http://code.google.com/edu/languages/google-python-class/ind ex.html http://diveintopython.org http://www.slideshare.net/nowells/introduction-to-python-51823 13
Questions & Discussion Thank you for the attention http://opengis.ch @mbernasocchi marco@opengis.ch
And action... Open terminal and type python or better ipython