class: title-slide, center, middle # GIS in Archaeology ## 02 - Working with QGIS ### Martin Hinz #### Institut für Archäologische Wissenschaften, Universität Bern 02/10/24 .footnote[ .right[ .tiny[ based on [Datapolitan-Training/qgis-training](https://github.com/Datapolitan-Training/qgis-training). You can download a [pdf of this presentation](https://berncodalab.github.io/gia/lectures/02/gis_in_archaeology_02.pdf). ] ] ] --- <!-- opening shapefile --> #Let's Get Started 1. [Click this link](https://github.com/BernCoDALab/gia/raw/main/lectures/01/data/points.zip) and download the file to your desktop 2. Unzip the file 3. [Click this link](https://github.com/BernCoDALab/gia/raw/main/lectures/01/data/background.tiff) and download the other file also to your desktop 3. Open QGIS  --- ## Layers  #### Image Source: http://www.geocontrolling.com/co-je-gis.htm --- # Layer Ordering -- + Layers on top are drawn on top -- + Just drag and drop within the Layers Panel to change order -- + Try it now --- ## Shapefiles -- + Basic file for storing map elements -- + Stores spatial data, like points, lines, and polygons -- + Multiple files comprise a "shapefile" --  --- ## Shapefiles  -- + .shp—The main file that stores the feature geometry -- + .dbf—The dBASE table that stores the attribute information of features --- ## Shapefiles  + .prj—The file that stores the coordinate system information -- + .shx—The index file that stores the index of the feature geometry --- ## You might also see -- + .cpg—Identifies the character set to be used -- + .sbn and .sbx—The files that store the spatial index of the features --- ## Shapefiles + Have a few limitations -- + One geometry type (Point, Line, Polygon) per shapefile -- + So sometimes you end up with this:  --- ## Overview of GeoPackage .pull-left[ * What is GeoPackage? * A data format for geographic information systems (GIS). * Platform-independent, open, and standards-based. * Uses an SQLite database to store both raster and vector data. * Key Features: * Single file for easy data sharing and use. * Efficient, especially for mobile and offline environments. * Supports extensions for flexibility (OGC-approved and custom extensions). * Why Use GeoPackage? * Lightweight and portable. * Facilitates easy data management and spatial queries. ] .pull-right[  ] --- ## GeoPackage vs. Shapefiles 1. **File Structure:** - **GeoPackage:** Single file (SQLite-based). - **Shapefile:** Requires multiple files (.shp, .shx, .dbf, etc.). 2. **Data Handling:** - **GeoPackage:** Stores both vector and raster data (multiple geometry type per file possible) - **Shapefile:** Vector data only. 3. **Efficiency:** - **GeoPackage:** Compact, better suited for mobile/offline use. - **Shapefile:** Larger, more fragmented. 4. **Attributes:** - **GeoPackage:** Supports larger field names and Unicode. - **Shapefile:** Limited field length and ASCII-only. --- ## Attribute Table (Right click on layer)  --- ## Attribute Table .pull-left[ ### Table View  ] .pull-right[ ### Form View  ] --- ## Shapefiles and Attribute Tables -- + Column names can only be letters, numbers, and underscores "_" -- + Column names can only be ten characters long --  --- class:center,middle # Let's add another layer --- ## Going out in Bern + [Download the data](https://github.com/BernCoDALab/gia/raw/main/lectures/02/data/going_out_in_bern.zip) to your desktop + Unzip the file + Open in QGIS  --- ## Going out in Bern  --- # Filter and Query + We can filter the points based on the values in the attribute table --- # Filter and Query + Right-click on the layer and select "Filter" to open the Query Builder  --- # Filter and Query  --- # Filter and Query  --  --- # Filter and Query  --- # Filter and Query  --- class:center,middle # We can also filter by multiple conditions --- # Filter and Query - Multiple Conditions  --  --- # Filter and Query - Multiple Conditions  --- # Zoom to Layer  --  --- # Zoom Selection -- + Select the zoom on the toolbar  -- + Draw a box around the area you want to zoom into -- + Click the icon to return to the previous map extent  --- # Pan Map + Select the hand tool to pan around the map  --- # Exporting Data  --  --- # Your Turn + Filter according to your own criteria + Try and find something interesting + Change the style of the point, either to a different shape, color, or icon + Export your selection as a new shapefile --- ## CSV-Files + General (textbased) spreadsheat format -- + simple and robust -- + human readable (kind of) --  --- ## CSV-Files + Perfect for data exchange between Spreadsheet (Excel) and GIS  --- ## CSV Import - Bicycle Rental + [Download the data](https://github.com/BernCoDALab/gia/raw/main/lectures/02/data/bicycle_rent.csv) to your desktop  --- ## CSV Import - Bicycle Rental Load Text Layer  --- ## CSV Import - Bicycle Rental Set coordinate columns  --- ## CSV Import - Bicycle Rental Set coordinate columns and Coordinate Reference System <- We will explain this in a bit! You can also access more detailed Coordinate Reference settings.  --- class:center,middle # So what is a Coordinate Reference System? --- # Projections -- + No one's favorite part of GIS -- + But a necessary part of it nonetheless -- + Convert points on the 3-dimensional Earth (**latitude** and **longitude**) to x and y coordinates on a 2-dimensional map --  [Digital Coast Geozone](https://geozoneblog.wordpress.com/2012/05/22/happy-birthday-mercator/) --- # Projections + Every projection distorts some part of your map  [FlowingData](http://flowingdata.com/2014/01/13/map-projections-illustrated-with-a-face/) --- # Mercator Projections -- + A common map projection -- + Makes geometries near poles look bigger than geometries near the equator --  --- # Projections Matter -- + These circles are all the same size on the globe:  [Progonos](http://www.progonos.com/furuti/MapProj/Normal/CartProp/Distort/distort.html) + Conformal map projection (Winkeltreu) --- # Projections Matter + As are these:  [Progonos](http://www.progonos.com/furuti/MapProj/Normal/CartProp/Distort/distort.html) + Equal-area projection (Flächentreu) --- # Projections Matter + And these:  [Progonos](http://www.progonos.com/furuti/MapProj/Normal/CartProp/Distort/distort.html) --- # Projections Matter  --- # Projections + For the most part we will work in **WGS 84** (latitude and longitude) -- + In Switzerland, we use a more accurate projection **CHTRS95: Swiss Terrestrial Reference System 1995** that is identical with the european system **ETRS89**. + You might also find 'Schweizer Landeskoordinaten' (CH1903) or Landesvermessung 1903 (LV03)  ###### Source: https://www.swisstopo.admin.ch/de/wissen-fakten/geodaesie-vermessung/bezugsrahmen/lokal/lv95.html --- # Projections + Identified by unique IDs (**EPSG**) that make it easier to talk about them + EPSG: European Petroleum Survey Group Geodesy (it was introduced, because Oil companies were annoyed by the incredible number of different systems) -- + WGS 84 is referred to as **EPSG:4326** -- + Google Maps and other online sources often uses WGS 84 / Pseudo-Mercator (**EPSG:3857**) -- + CHTRS95 is referred to as **EPSG:2056** -- ## Remember these three and you should be set --- class:center,middle # Back to Adding CSV Data --- # Adding CSV Data  --- ## CSV Import - Bicycle Rental Bicycles added.  --- # What We've Covered -- + Adding, styling, and labeling data in QGIS -- + Projections -- + Querying features --- # Homework + Add the files you can download from the homework page to QGIS (note: the projection epsg is in the filename) + background_4326.tif + cities_2056.csv + lakes_3857.gpkg + Style as you like + Send me a screenshot --- class: inverse, middle, center # Any questions?  .caption[Source: https://www.instagram.com/sadtopographies] .footnote[ .right[ .tiny[ You might find the course material (including the presentations) at https://github.com/BernCoDALab/gia You can see the rendered presentations at https://berncodalab.github.io/gia You can contact me at <a href="mailto:martin.hinz@unibe.ch">martin.hinz@unibe.ch</a> ] ] ]