class: center, middle # Python for GIS and Geoscience Doctoral schools of Ghent University
December 12, 16 and 19, 2024 Joris Van den Bossche, Stijn Van Hoey https://github.com/jorisvandenbossche/DS-python-geospatial --- class: center, middle # Who are you? Go to https://hackmd.io/GaohdyaETeuUAI1F8sjXPw?both
--- ### Joris Van den Bossche
jorisvandenbossche
* Open source software developer and teacher * Pandas, GeoPandas, scikit-learn, Apache Arrow --- ### Stijn Van Hoey
stijnvanhoey
* Freelance developer and teacher * Research software engineer at [Fluves](https://www.fluves.com/) .center[ ![:scale 90%](./static/img/work_stijn_1.png)] --- class: middle, section_background # Setting up a working environment --- ## Setting up a working environment For the setup instructions, see the [setup page](https://jorisvandenbossche.github.io/DS-python-geospatial/setup.html). --- class: left, middle 0. If not already downloaded the course material, installed conda and setup the environment, see [setup instructions section 1 and 2](https://jorisvandenbossche.github.io/DS-python-geospatial/setup.html) 1. Next, make sure to complete 3 and 4 of the [setup instructions](https://jorisvandenbossche.github.io/DS-python-geospatial/setup.html). > If you succesfully done all steps, put up your `green sticky note` on your laptop screen... Next: - Surf to and fill in [the questionnaire](https://hackmd.io/GaohdyaETeuUAI1F8sjXPw?both) - In Jupyter Lab, start with the 'notebooks/00-jupyter_introduction.ipynb'. > Installation or setup issues? Put up your `red sticky note` on your laptop screen. --- class: center, middle When you see something like this... ![:scale 100%](./static/img/startup.png) ...relax, you're ready to start! --- class: center, middle ![:scale 100%](https://i.ytimg.com/vi/PlaYMh-u-2w/maxresdefault.jpg) --- class: middle, left ### Time is divided between - group sessions: we explain new concepts (aka 'theory') - practise sessions: you work on exercises or case studies In case of questions, remarks, suggestions, you can always interrupt us and just ask. During practise sessions, use the `red sticky note` on top of your laptop screen to let us know you have a question. ### Status check We will regularly ask for a check (ready with exercise, installation succesfull...). Use the `green sticky note` on top of your laptop screen to say 👍. ### Feel lost? Just ask either one of us, we are here to help you. --- class: middle, center ![:scale 80%](./static/img/issuetracker.png) Report bugs, typo's, suggestions... as issues ([New issue](https://github.com/jorisvandenbossche/course-python-geospatial/issues/new)) or see the [contributing guidelines](https://github.com/jorisvandenbossche/course-python-geospatial/blob/main/CONTRIBUTING.md) --- class: middle, section_background # Working with Python --- # Conda ### Why using conda? - Consistent package manager across Windows, Mac and Linux - Many precompiled packages available - Less problems with installation -- ### Why different environments? - Manage the dependencies of a specific project/paper/group/... - You can install different version of Python and other packages alongside on your computer - Easily share environments with other --- ## Small overview of conda commands Creating a new environment: ``` conda create -n my_env python=3.10 pandas # or from environment file conda env create -f environment.yml ``` Activating an environment: ``` conda activate my_env ``` Install a new package: ``` conda install matplotlib # if not working, try: pip install ... ``` List all installed packages: `conda list` List all your environments: `conda info -e` See the docs: https://docs.conda.io/projects/conda/en/latest/user-guide/index.html --- class: center, middle ### Keep track of your python ecosystem
with an `environment.yml`
``` conda env export > environment.yml ``` --- # Writing Python code ## IPython console
.center[![:scale 75%](./static/img/ipython.png)] --- ## Interactive Development Environment (IDE) * [**Spyder**](https://pythonhosted.org/spyder/) is shipped with Anaconda. The familiar environment for Matlab/Rstudio-users. * [**VS Code**](https://code.visualstudio.com/) is also shipped with Anaconda. General purpose editor with powerful plugin ecosystem. * [**PyCharm**](https://www.jetbrains.com/pycharm/): Popular for web-development and Django applications, powerful when doing 'real' development (packages, libraries, software) * [Eclipse + **pyDev plugin**](http://www.pydev.org/): If you already work in Eclipse, add the python environment * ... --- ## Jupyter Lab/Notebook
(*previously called IPython notebook*)
**Jupyter notebook** provides an **interactive** scripting environment,
ideal for exploration, prototyping,... .center[![:scale 70%](./static/img/notebook.png)] -- ...the stuff we're dealing with in this course! --- class: center, middle # How are you feeling? ![:scale 100%](http://esq.h-cdn.co/assets/15/51/980x490/landscape-1450137389-john-cleese.JPG) ### https://forms.gle/trjSSDhzD656j63LA Please fill in the questionnaire. --- class: center, middle # Closing notes --- class: center, middle # Python's scientific/GIS ecosystem #### ## Inspired by figure by Jake VanderPlas --- class: center, middle, bgheader background-image: url(./static/img/ecosystem-gis-overview_6.svg) background-size: cover --- class: center, middle, bgheader background-image: url(./static/img/ecosystem-gis-overview_5.svg) background-size: cover --- class: center, middle, bgheader background-image: url(./static/img/ecosystem-gis-overview_3.svg) background-size: cover --- class: center, middle, bgheader background-image: url(./static/img/ecosystem-gis-overview_2.svg) background-size: cover --- class: center, middle, bgheader background-image: url(./static/img/ecosystem-gis-overview_1.svg) background-size: cover --- class: center, middle, bgheader background-image: url(./static/img/ecosystem-gis-overview.svg) background-size: cover --- # A rich ecosystem of packages
![:scale 60%](https://pysal.org/pysal1.png) Python Spatial Analysis Library (https://pysal.org). Collection of packages for: * detection of spatial clusters, hot-spots, and outliers * construction of graphs from spatial data * spatial regression and statistical modeling on geographically embedded networks * spatial econometrics * exploratory spatio-temporal data analysis * ... --- # A rich ecosystem of packages
Building up on / integrating with GeoPandas: **MovingPandas** (https://anitagraser.github.io/movingpandas/): working with movement data **Momepy** (http://docs.momepy.org/en/latest/): quantitative analysis of urban morphology **geoplot** (https://residentmario.github.io/geoplot/): high-level Python geospatial plotting library (combining GeoPandas, matplotlib and cartopy) **...** Check out the [GeoPandas ecosystem](https://geopandas.org/en/stable/community/ecosystem.html#geopandas-ecosystem). --- # A rich ecosystem of packages
Building up on / integrating with xarray: **Satpy** (https://satpy.readthedocs.io/en/stable/): package for earth-observing satellite data processing **xesmf** (https://xesmf.readthedocs.io/): Universal Regridder for Geospatial Data **verde** (https://www.fatiando.org/verde/): interpolating spatial data on regular grids **...** Check out the [Xarray ecosystem](https://docs.xarray.dev/en/stable/ecosystem.html). --- # A rich ecosystem of packages
Several more domain/application specific packages: **MetPy** (https://unidata.github.io/MetPy): working with weather data **xgcm** (https://xgcm.readthedocs.io/en/latest/index.html): working with output from General Circulation Models **osmnx** (https://github.com/gboeing/osmnx): street networks **...** --- # A rich ecosystem of packages
**Machine learning**: scikit-learn, tensorflow, pytorch, keras, chainer, ... **Performance**: Numba, Cython, Numexpr, Pythran, C/Fortran wrappers, ... **Visualisation**: Bokeh, Seaborn, Plotnine, Altair, Plotly, Mayavi, HoloViews, datashader, vaex ... **Data structures and parallel/distributed computation**: Xarray, Dask, Distributed, Cupy, ... Specialized packages in many **scientific fields**: astronomy, natural language processing, image processing, geospatial, ... **Packaging and distribution**: pip/wheels, conda, Anaconda, Canopy, ... --- class: center, middle ### Reading advice [Good Enough Practices in Scientific Computing](https://arxiv.org/pdf/1609.00037v1.pdf) > "*However, while most scientists are careful to validate their laboratory and field equipment, most do not know how reliable their software is*" --- class: center, middle # Thanks ### Joris Van den Bossche
jorisvandenbossche
### Stijn Van Hoey
stijnvanhoey