class: center, middle, inverse # Learn yourself a Python for greater good Nelen & Schuurmans in your area. --- # Arjen Developer by day. Poet by night. --- # Ernst Developer by day. Asleep at night. --- # Nelen & Schuurmans https://nxt.lizard.net --- # Outline * Introduction. * Use case. * Data collection. * Analysis. * Presentation. --- # Introduction * Web vs Desktop. * Geojson vs Shapefile. * Programming vs. Software engineering. --- # Python Recently Brian Timoney and James Fee have been writing about how geospatial work is more and more programming and less GUI-driven operations in the ArcGIS mold. They’ve been pointing a lot to Python for this. (Tom Macwright, 2012, http://www.macwright.org/2012/10/31/gis-with-python-shapely-fiona.html) --- # Use case Your colleague from the social studies department wants to know the approximate height of a bunch of cities so he can investigate if there is a correlation between criminal behaviour and living below the sea level. He thinks programming is clicking through wizards in Excel and that a big file means > 10MB. He sends you an Excel spreadsheet with the names of the cities and expects an answer by 17:00 this afternoon. He agreed with the PR & marketing department that they will release a press release next week. --- # Problems ## Your boss gets angry problems * You don't know which and how many cities you need to analyse or re-analyse. * You don't know the geo-location of the cities. * You know your department has access to the latest DEM of The Netherlands (AHN2) but it's too big to load in ArcGIS. --- # Problems ## Your boss didn't expect you to also solve *these* problems * The web guy from the marketing department wants to make an interactive online map and needs the data in Geojson. * Some of the international students heard of the project and inquired if it would be possible to get the difference between the AHN2 and the world DEM they are using so they get a sense of the accuracy of the world DEM. They are nice guys so they don't ask you to do crazy stuff, just hand over a shapefile. --- # Problems ## Your boss will suggest you for promotion problems * Additionaly, for each city you give the major land use classes and soil types so the people in the environmental sciences departments. * You not only give the height of each city but also the height along a line between 2 or possibly more cities; height profile graphs. --- # Requirements ```bash pip install requests shapely fiona ``` if you don't have `pip` installed ```bash wget https://bootstrap.pypa.io/get-pip.py python get-pip.py ``` or check: https://pip.pypa.io/en/latest/installing.html --- # Coding tips * Think about code structure: tracer bullet. * Think about your data structures. * Write your code in independent, concise modules. * Unix philosophy: use the right tool for the job. --- ### Data collection #### Required 1. File with names of cities. 2. Find geocoordinate with Google API for each city. 3. Get AHN2 elevation information with Lizard API for each city. #### Bonus 4. Get world DEM elevation information. #### More bonus 5. Get a height profile between two or more cities. 6. Get information about landuse and soil. --- # Analysis 1. Calculate the differences between AHN2 and world DEM. 2. (?). --- # Presentation 1. Write as CSV. 2. Write as Geojson. 3. Write as shapefile. 4. Write as PNG. --- # Synopsis * Programming is no longer a specialist job. * Data and algorithms are no longer centralised but distributed. * Python is great as a glue, data crunching language between web, server, modeling and Desktop GIS. * Programming is not the same as Software engineering. --- # Code & Presentation https://github.com/divisionblue/wur-python