class: title-slide, center, middle # GIS in Archaeology ## 05 - Handling Spatial Data ### Martin Hinz #### Institut für Archäologische Wissenschaften, Universität Bern 23/10/24 .footnote[ .right[ .tiny[ You can download a [pdf of this presentation](gis_in_archaeology05.pdf). ] ] ] --- ## Things to cover + Manipulation of vector data + Spatial selection of vector data + Working with buffers + Creation of a Thematic Map (Choropleth) by combining vector data --- class:center,middle,inverse # Basic Map Elements --- class:center,middle ## Points  .caption[http://docs.qgis.org/2.8/en/docs/gentle_gis_introduction/vector_data.html#overview] --- class:center,middle ## Lines  .caption[http://docs.qgis.org/2.8/en/docs/gentle_gis_introduction/vector_data.html#overview] --- class:center,middle ## Polygons  .caption[http://docs.qgis.org/2.8/en/docs/gentle_gis_introduction/vector_data.html#overview] --- ## Shapefiles -- + Basic file for storing map elements -- + Stores spatial data, like points, lines, and polygons -- + Multiple files comprise a "shapefile" --  --- # Reworking of Shapefiles + Spatial (vector) data often can be downloaded, or created using digitalisation of scanned maps (last session) + Sometimes it is necessary to combine informations (geometries) for the desired result + for theses tasks there are geometry processing tools  --- <!-- opening shapefile --> ## Let's Get Started 1. [Click this link](https://github.com/BernCoDALab/gia/raw/main/lectures/05/data/kantonsgrenzen.zip) and download the cantonal borders of Switzerland (shapefile) to your desktop 2. [Click this link](https://github.com/BernCoDALab/gia/raw/main/lectures/05/data/seen.zip) and download the lakes of Switzerland (shapefile) to your desktop 3. [Click this link](https://github.com/BernCoDALab/gia/raw/main/lectures/05/data/14c_daten.csv) and download some 14C data (csv) also to your desktop 4. Open QGIS 5. Start a new project and Add all layers --- ## Adding a CSV Layer...Reminder + csv data are 'delimited text' data, so use the approriate import tool + the coordinates are store as lat/lng in columns named accordingly + lat -> *Latitude:* a geographic coordinate that specifies the **north–south** position of a point on the Earth's surface -> y-coordinate + lng -> *Longitude:* a geographic coordinate that specifies the **east–west** position of a point on the Earth's surface -> x-coordinate + latitude/longitude -> World Geodetic System: WGS 84 -> **EPSG 4326** .center[] --- ## Tasks for today + Extract the 14C data for Switzerland + Count how many data are in lakes and within 1 km around lakes + visualise the mean age of 14C dates per canton .center[] + first, we need a polygon of Switzerland (or create one ourself) --- ## Vector overlay .pull-left[ Combine different layers for to produce a combined result ### Multiple Options + Clip (Intersection) + Difference (Substraction) + Symmetric Difference (Disjunction) + Union  .caption[https://moderndilettante.wordpress.com/category/boole/] ] .pull-right[] --- ## Combining lakes with cantons .pull-left[ The cantonal borders exclude the lakes! Check yourself... We need to combine the lakes with the borders shapefile! .tiny[*Not strictly necessary for our task at hand, but serves didactic purpose...*] **Which algorithm to use?**  .caption[https://moderndilettante.wordpress.com/category/boole/] ] .pull-right[   ] --- ## Union + Select Union from Vector > Geometry-Processing + Select the cantonal borders as one layer + Select the lakes as second layer + Temporary Layer is fine, so no need to specify storage location + Check 'Open after success' checkbox + Click 'Run' .center[  ] --- ## Union Result + A layer containing all polygons from both layers + You can check in the attribute table: .center[  ] --- ## Dissolve .pull-left[ + We need only one polygon -> Combining all polygons to one + use disolve tool (Vector > Geometry-Processing) + Select Union Layer as Input Layer + Temporary Layer as output is fine + Click 'Run' ] .pull-right[   ] --- ## Wrong or unnecessary Vertices If we zoom in, some Structure within our polygon resulted from non-matching spatial data: .right[  ] --- ## Edit/Remove wrong or unnecessary Vertices .pull-left[ + Click on 'Toggle Edit Mode'  + Click on Vertices Tool  + Select unnecessary vertices and remove + Save by and 'Toggle Edit Mode'  *in the same tool, you also can move points of your polygons to different locations...* ] .pull-right[  ] --- ## Toolbox .pull-left[ For our next task, we need a tool that is not available from the menu For this, we activate the toolbox sidebar/window  This toolbox contains all menu tools + a lot more It also features a search bar for fast and easy access ] .pull-right[  ] --- ## Extract points based on Polygon (1) To extract the 14C data contained within the 'Switzerland'-polygon, we access the 'Extract by Position' tool. Start typing in the search field to find it!  --- ## Extract points based on Polygon (2) .pull-left[ + Select the 14c-layer as layer to extract from + Select 'are contained' as Option + Select the 'Dissolved' Layer as source + Temporary Layer might be fine + Click on 'Run' + The resulting Layer should only contain the 14C Data within Switzerland + Finally save your layer as shapefile! ] .pull-right[   ] --- ## Check the number of 14C Dates within lakes (1) *(Spatial Query)* Lets start with our first analytical procedure: How many 14C dates are comming from lakes? To check this, we need the lakes and the 14C Data:  --- ## Check the number of 14C Dates within lakes (2) This time, the tool is accessible via the menue 'Vector > Analytical tools':   + select the lakes layer as polygon layer + select the 14C layer as points layer + (you can specify a weighting and a classification field, too) + the name of the resulting count column is 'NUMPOINTS', that might be ok for now + temporary layer might be ok for now + click on 'Run' --- ## Check the number of 14C Dates within lakes (2) A new layer is created that contains the original information from the lakes layer + the number of 14C data as 'NUMPOINTS'. You can check in the attribute table.  --- ## Check the number of 14C Dates within 1km around lakes (1) .pull-left[ To check, how many 14C Data are within a buffer of 1 km around the lakes, we have to create a buffer first. + Select Buffer from 'Vector > Geometry processing tools' + Select the lakes layer as input layer + Select 1km as distance + most of the other options refer to the shape of the buffer... we can leave them to default now + the checkbox 'dissolve' merges all connected buffers, we do not want that here + Click on 'Run' ] .pull-right[   ] --- ## Check the number of 14C Dates within 1km around lakes (2) + The resulting Vector layer contains all informations of the lakes layer, only that the lakes are 1km enlarged + You can now count points in polygons like before, but you should select the 'buffered' layer as your input + The number of 14C dates are now much larger per lake --- ## Calculate mean 14C age per canton (1) Using GIS, you can excecute statistical procedures and visualise the result in a Choropleth. (the German term for this is also Choropleth...)  #####Source: http://www.estv2.admin.ch/ --- ## Calculate mean 14C age per canton (2) *(Spatial Join)* To start, we need the cantonal borders and the 14C data and the Toolbox . The command is 'Join attributes by location (summary)'  --- ## Calculate mean 14C age per canton (3) + Select the cantonal borders as input layer + Select the 14C data as joined layer + Select intersection as condition  --- ## Calculate mean 14C age per canton (4) + in Summary fields, select bp (uncalibrated 14C date) as field + in Calculated Summaries, select 'mean' as statistic + temporary layer might be ok + press 'Run'   --- ## Calculate mean 14C age per canton (5) In the Attribute Table, now you can see the mean bp age per canton  --- ## Visualise mean 14C age per canton Now we can color the cantons according to the mean BP age + Open the **Properties** of the layer (right click on the layer) and Select there the **Symbology** tab + Select 'Graduated' as symbol and Classify the values + click on 'OK' + Now you should be able to see the age by color   --- ## What We've Covered -- + Editing and joining Geometries -- + Extract features based on location in relation to other vector data -- + Extract and summarise information based on location in relation to other vector data --- ## Homework + Get the [north](https://github.com/BernCoDALab/gia/raw/main/lectures/05/data/kreise_bern_nord.zip) and the [south part](https://github.com/BernCoDALab/gia/raw/main/lectures/05/data/kreise_bern_sued.zip) of the Kanton of Bern + Unite them to get a map of the whole Kanton + Get the [Location of archaeological sites of the Kanton of Bern](https://github.com/BernCoDALab/gia/raw/main/lectures/05/data/fundstellen_bern.zip) + Count the number of sites in each 'Amtsbezirk' + Make a Map showing the number of sites color coded + Send me the map --- 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> ] ] ]