Skip to content

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

Difference in graphical representation of vector and raster data

Difference in graphical representation of vector and raster data (Geletič et al. 2019)

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.

Introduction to query expressions Construct and modify queries


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.

IntersectA
Intersect (DBMS)A
ContainsA
Contains ClementiniA
WithinA
Within ClementiniA
Are identical toA
Have their center inA

IntersectA, C
Intersect (DBMS)A, C
WithinA, C
Completely withinA
Within ClementiniA
Have their center inA, C
Boundary touchesC

IntersectA, C
Intersect (DBMS)A, C
WithinA, C
Completely withinA
Within ClementiniA
Have their center inA, C
Boundary touchesC

IntersectA, C, D
Intersect (DBMS)A, C, D
ContainsA, C, D
Completely containsA, D
Contains ClementiniA, D
Have their center inD
Boundary touchesC

IntersectA, C, D, E, F, G, H, I, J
Intersect (DBMS)A, C, D, E, F, G, H, I, J
ContainsG, H
Completely containsG
Contains ClementiniG, H
WithinF, H
Completely withinF
Within ClementiniF, H
Are identical toH
Boundary touchesC, E
Share a line segment withF, G, H, I, J

IntersectA, 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
WithinA, D, G, H, I, O
Completely withinA
Within ClementiniA, D, G, H, I
Boundary touchesF, G, H, I, K, L, M, N, O
Share a line segment withG, I, J, K, M, O
Crossed by the outline ofC, E, H, L, N
Have their center inA, C, D, E, G, H, I, J, O

IntersectA, B
Intersect (DBMS)A, B
ContainsA, B
Completely containsA
Contains ClementiniA
Have their center inA, D
Boundary touchesB

IntersectA, 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
ContainsA, D, G, H, I, O
Completely containsA
Contains ClementiniA, D, G, H, I
Boundary touchesF, G, H, I, K, L, M, N, O
Share a line segment withG, I, J, K, M, O
Crossed by the outline ofC, E, H, L, N
Have their center inE, I, L

IntersectA, C, D, E, F, G, H, I, J, K, M
Intersect (DBMS)A, C, D, E, F, G, H, I, J, K, M
ContainsC, E, H, M
Completely containsC
Contains ClementiniC, E, H, M
WithinF, G, H, M
Completely withinF
Within ClementiniF, G, H, M
Are identical toH, M
Boundary touchesD, E, G, H, I, J, M
Share a line segment withD, H, I, M
Crossed by the outline ofA, E, G, J, K
Have their center inC, 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:

pro.arcgis.com
Join the attributes from a table
pro.arcgis.com
Join data by location (spatially)
learn.arcgis.com
Remove join


Assignment 02

Exploring European regions

TASK:

Explore statistical data of the NUTS 2 regions in your country using attribute and spatial queries.

  1. Create a thematic geodatabase named YourSurname_CountryName_as03.gdb containing 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)
  2. Create a map poster in A3 format named YourSurname_CountryName_as03.pdf containing:

    • 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:

DATA

SUBMISSION FORM:

INSTRUCTIONS:

  1. Add the NUTS_RG_03M_2024_4326_LEVL_2.shp layer to the map and explore the contents of its attribute table.

  2. Join the data from NUTS2_statistics.csv to the NUTS 2 regions layer (Add Join). Export the layer with the joined data as a new feature layer with an appropriate name, for example NUTS02_statistics (Data → Export Features).

  3. In the new NUTS02_statistics layer, create four new text fields:

    • pop_cat – population category
    • ur_cat – unemployment rate category
    • GDP_cat – GDP category
    • area_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)

  4. 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
  5. From the NUTS02_statistics layer, 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).

  6. Add the airport data from eu-airports_filtered.csv to the map (XY Table To Point).

  7. 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.

  8. From the NUTS02_statistics layer 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).

  9. 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²).

  10. 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:

learn.arcgis.com
Join tabular data to a spatial layer