Working with vector data: queries, joins and spatial relationships
Spatial data is any type of data that directly or indirectly references a specific geographical area or location. A location can be represented not only by a combination of coordinates (X + Y, latitude + longitude, etc.), but also by, for example, an address (of arbitrary detail). The two most common data formats used to store (geo)spatial data are vector and raster.
Spatial data types
-
Vector data
-
represent elements of the real world using basic geometric elements: points, lines and surfaces (called polygons)
-
the detail of the data is determined by the detail of the coordinates of the vertices of the geometric feature
-
suitable for modelling and analysis of discrete objects (e.g. location of points, land cover categories)
-
suitable for map creation, length measurements, geometric calculations
-
possible problems with topology (gaps and overlaps)
-
basic vector data formats are Esri Shapefile, GeoJSON, GeoPackage or KML/GML
-
-
Raster data
-
represent real world elements in the form of a regular grid made up of pixels (from picture element)
-
the detail of the data is determined by the spatial resolution of the grid, i.e. the size of the pixel edge (in meters)
-
suitable for modeling and analysis of continuous phenomena (elevation, temperature, precipitation)
-
used for image data (e.g. satellite imagery)
-
raster datasets can become potentially very large
-
basic raster data formats are GeoTIFF, JPEG, PNG or GIF
-
Attribute queries
Attribute Query is a method of selecting/filtering elements based on attribute values. It complements the interactive feature selection method from practical 1. The basis is a selection rule - called Expression. ArcGIS Pro allows you to build expressions interactively using a dialog, but to use the full potential of expressions, it is recommended to use SQL code.
Attribute query (over map data): Map → Select By Attributes → fill in the dialog... Select features using attributes
The Input Rows field is automatically prepopulated with the layer selected in the map content
Using the
you can change the notation between the interactive dialog entry and the SQL expression.
Spatial queries
Spatial Query is a method of selecting/filtering elements of one layer based on their relative position with elements of another layer. The function uses as input the layer of selected elements, the layer for overlay analysis a the relationship for overlay analysis.
| Intersect | A |
| Intersect (DBMS) | A |
| Contains | A |
| Contains Clementini | A |
| Within | A |
| Within Clementini | A |
| Are identical to | A |
| Have their center in | A |
| Intersect | A, C |
| Intersect (DBMS) | A, C |
| Within | A, C |
| Completely within | A |
| Within Clementini | A |
| Have their center in | A, C |
| Boundary touches | C |
| Intersect | A, C, D |
| Intersect (DBMS) | A, C, D |
| Contains | A, C, D |
| Completely contains | A, D |
| Contains Clementini | A, D |
| Have their center in | D |
| Boundary touches | C |
| Intersect | A, C, D, E, F, G, H, I, J |
| Intersect (DBMS) | A, C, D, E, F, G, H, I, J |
| Contains | G, H |
| Completely contains | G |
| Contains Clementini | G, H |
| Within | F, H |
| Completely within | F |
| Within Clementini | F, H |
| Are identical to | H |
| Boundary touches | C, E |
| Share a line segment with | F, G, H, I, J |
| Intersect | A, C, D, E, F, G, H, I, J, K, L, M, N, O |
| Intersect (DBMS) | A, C, D, E, F, G, H, I, J, K, L, M, N, O |
| Within | A, D, G, H, I, O |
| Completely within | A |
| Within Clementini | A, D, G, H, I |
| Boundary touches | F, G, H, I, K, L, M, N, O |
| Share a line segment with | G, I, J, K, M, O |
| Crossed by the outline of | C, E, H, L, N |
| Have their center in | A, C, D, E, G, H, I, J, O |
| Intersect | A, B |
| Intersect (DBMS) | A, B |
| Contains | A, B |
| Completely contains | A |
| Contains Clementini | A |
| Have their center in | A, D |
| Boundary touches | B |
| Intersect | A, C, D, E, F, G, H, I, J, K, L, M, N, O |
| Intersect (DBMS) | A, C, D, E, F, G, H, I, J, K, L, M, N, O |
| Contains | A, D, G, H, I, O |
| Completely contains | A |
| Contains Clementini | A, D, G, H, I |
| Boundary touches | F, G, H, I, K, L, M, N, O |
| Share a line segment with | G, I, J, K, M, O |
| Crossed by the outline of | C, E, H, L, N |
| Have their center in | E, I, L |
| Intersect | A, C, D, E, F, G, H, I, J, K, M |
| Intersect (DBMS) | A, C, D, E, F, G, H, I, J, K, M |
| Contains | C, E, H, M |
| Completely contains | C |
| Contains Clementini | C, E, H, M |
| Within | F, G, H, M |
| Completely within | F |
| Within Clementini | F, G, H, M |
| Are identical to | H, M |
| Boundary touches | D, E, G, H, I, J, M |
| Share a line segment with | D, H, I, M |
| Crossed by the outline of | A, E, G, J, K |
| Have their center in | C, E, F, G, H, K, L |
Resources: {: align=center } Select features by location Select Layer By Location (Data Management) Select By Location graphic examples
Attribute and spatial join
Through a common field, known as a key, you can associate records in one table with records in another table. For example, you can associate a table of parcel ownership information with the parcels layer, because they share a parcel identification field. You can make these associations in several ways. Joins can also be based on spatial location.
Joins information are stored in the layer's properties, so they can be applied only to tables that are opened from a map or scene. To access join information, right-click the layer and click Properties to open the Layer Properties dialog box, and click the Joins tab.
Join the attributes from a table
Typically, you'll join a table of data to a layer based on the value of a field that can be found in both tables. The name of the field does not have to be the same, but the data type must be the same; you join numbers to numbers, strings to strings, and so on. You can perform a join using the Add Join geoprocessing tool. When performing an attribute join, the joined fields are dynamically added to the existing table. Field properties (such as aliases, visibility, and number formatting) are maintained when a join is added or removed.

Note
When joining tables, the default option is to keep all records. If a record in the target table doesn't have a match in the join table, that record is given null values for all the fields being appended into the target table from the join table.

With the keep only matching records option, if a record in the target table doesn't have a match in the join table, that record is removed from the resultant target table. If the target table is the attribute table of a layer, features that don't have data joined to them are not shown on the map.

Join data by location spatially
When the layers on your map don't share a common attribute field, you can join them using the Spatial Join geoprocessing tool, which joins the attributes of two layers based on the location of the features in the layers.
With a spatial join, you can complete any of the following common workflows:
- Find the nearest feature
- Find what is inside a polygon
- Find what intersects a feature
Join by location, or spatial join, uses spatial associations between the layers involved to append fields from one layer to another. Depending on the type of association, you can append the attributes or an aggregate (minimum, maximum, mean, and so on) of numeric attributes from a matched feature to the target features. Spatial joins by default are different from attribute-driven joins in that they are not dynamic and require you to save the results to a new output layer.
Resources:
Assignment 02
Exploring European regions
TASK:
Explore statistical data of the NUTS 2 regions in your country using attribute and spatial queries.
-
Create a thematic geodatabase named
YourSurname_CountryName_as03.gdbcontaining the following layers / tables:- a polygon layer of NUTS 2 regions located within your selected country (Required attributes: NUTS 2 ID, NUTS 2 name, country code, population, population category, unemployment rate, unemployment rate category, GDP, GDP category, number of airports, airport density (airports per km²), area, area category)
- a polygon layer of NUTS 2 regions neighbouring your selected country (Required attributes: NUTS 2 ID, NUTS 2 name, country code, population, population category, unemployment rate, unemployment rate category, GDP, GDP category, number of airports, airport density (airports per km²), area, area category)
- a point layer of airports located within your selected country (Required attributes: ID, type, name, lat_deg, long_deg, elevation_ft, country ID, NUTS 2 ID, NUTS 2 name)
- a point layer of airports located within 100 km of the borders of your selected country (Required attributes: ID, type, name, lat_deg, long_deg, elevation_ft, country ID, NUTS 2 ID, NUTS 2 name)
- a table summarising the following numerical information about NUTS 2 regions for individual EU countries (region names do not need to be included!): count, min_area, max_area, avg_area, min_pop, max_pop, avg_pop, min_ur, max_ur, avg_ur, min_gdp, max_gdp, avg_gdp)
-
Create a map poster in A3 format named
YourSurname_CountryName_as03.pdfcontaining:- A map showing airports located within your selected country. Airports must be distinguished by colour according to their type (small / medium / large). Use shaded relief and NUTS 2 region boundaries as the map background.
- **A map showing one selected statistical indicator (unemployment rate / GDP per capita) **using an areal mapping method. Use two colours to distinguish NUTS 2 regions according to whether the value of the selected indicator is above or below the EU average.
-
A text section containing written answers / comments on the following questions related to the maps:
-
map of airports:
- How many airports are located within your selected country? - How many airports are located within 100 km of the country border? - List the names of the NUTS 2 regions within your country with the highest and lowest airport density. -
map of selected statistical indicator (unemployment rate / GDP per capita)_
- How many NUTS 2 regions border your selected country? Which countries do these regions belong to? - List the names of the NUTS 2 regions within your country with the highest and lowest values of the selected indicator.
-
DATA SOURCES:
SUBMISSION FORM:
- gdb + map poster in PDF (submit by 01/11, send to petra.justova@fsv.cvut.cz)
INSTRUCTIONS:
-
Add the
NUTS_RG_03M_2024_4326_LEVL_2.shplayer to the map and explore the contents of its attribute table. -
Join the data from
NUTS2_statistics.csvto the NUTS 2 regions layer (Add Join). Export the layer with the joined data as a new feature layer with an appropriate name, for exampleNUTS02_statistics(Data → Export Features). -
In the new
NUTS02_statisticslayer, create four new text fields:pop_cat– population categoryur_cat– unemployment rate categoryGDP_cat– GDP categoryarea_cat– area category
For each NUTS 2 region, assign either
"above avg"or"below avg"depending on whether the value of the corresponding indicator is above or below the mean value for all NUTS 2 regions in the EU. (Add Field, Select By Attributes, and Calculate Field) -
Create a summary table for individual EU countries containing the minimum, maximum, and average values of the following statistical indicators (Attribute Table → Summarize):
- population
- unemployment rate
- GDP per capita
- area
-
From the
NUTS02_statisticslayer, select only the NUTS 2 regions belonging to your selected country using (Select By Attributes). Export the selected features to a new layer (Data → Export Features). -
Add the airport data from
eu-airports_filtered.csvto the map (XY Table To Point). -
From the airport layer, use Select By Location to select:
- all airports located within your selected country;
- all airports located within 100 km of the border of your selected country (excluding airports located inside your country!)
Export both spatial selections as separate point layers (Data → Export Features).
Then use Spatial Join to add the NUTS 2 region name and NUTS 2 ID to both airport layers according to the region in which each airport is located.
-
From the
NUTS02_statisticslayer containing the NUTS 2 regions of all EU countries, use Select By Location to select the NUTS 2 regions that border your selected country.Export the spatial selection as a separate polygon layer using (Data → Export Features).
-
For both the NUTS 2 regions within your selected country and the neighbouring NUTS 2 regions, use Spatial Join to calculate the number of airports located in each region (Spatial Join → New Field → Count). Then add and calculate a new attribute representing airport density (number of airports per km²).
-
Create an A3 map poster according to the assignment requirements. Choose portrait or landscape orientation depending on the shape and extent of your selected country.
Supplemental exercise:












