🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Data Science & Analytics › GIS and Spatial Data Analysis › Lesson 3
TEC-DATA85-09 · Lesson 3 · 12 clock hours · lab

Vector Data: Loading, Querying, and Editing

Objective. Students will perform attribute queries, spatial queries, and basic feature editing on vector data (points, lines, polygons) in QGIS, exporting results as a new shapefile or GeoJSON.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Vector Data in GIS: Points, Lines, and Polygons

Vector data represents geographic features as discrete geometric shapes. A point marks a single location (latitude/longitude pair), such as a school or fire hydrant. A line (or polyline) connects two or more points to represent features like roads or rivers. A polygon is a closed shape used to represent areas such as census tracts, city limits, or parcels. Every vector feature carries an attribute table — a spreadsheet-like structure where each row is one feature and each column is a field (name, population, category, and so on). Understanding this geometry-plus-attribute structure is the foundation of all GIS analysis.

QGIS 3.x is a free, open-source desktop GIS application that reads dozens of vector formats including shapefiles (.shp and companion files) and GeoJSON (.geojson). Shapefiles are the legacy standard from Esri and remain extremely common in government open-data portals. GeoJSON is a text-based, web-friendly format that stores geometry and attributes in a single file, making it easy to share and use in web maps or Python scripts.

The Attribute Table and Select by Expression

Open the attribute table in QGIS by right-clicking a layer and choosing Open Attribute Table, or pressing F6. The table shows every field for every feature. You can sort, scroll, and manually click rows to select individual features on the map canvas at the same time.

For systematic filtering, use Select by Expression (the epsilon icon, or Ctrl+F3). This tool accepts SQL-like syntax. For example, to select all census tracts with a population over 5,000:

```

"POP_2020" > 5000

```

Or to find features whose name contains a specific string:

```

"NAME" ILIKE '%downtown%'

```

The Query Builder (Layer Properties → Source → Query Builder) works similarly but hides non-matching features from the layer entirely, acting as a persistent display filter rather than a temporary selection. Both tools use field names enclosed in double quotes and string values in single quotes — standard SQL convention.

Spatial Queries: Select by Location

Attribute queries filter on what a feature is; spatial queries filter on where it is relative to other features. The Select by Location tool (Vector menu → Research Tools → Select by Location) lets you ask questions such as: "Which schools fall inside census tract 042.01?" You specify a source layer (schools, points) and a reference layer (a selected census tract, polygon), then choose a spatial relationship: intersects, within, touches, overlaps, and others. QGIS highlights the matching features and you can then export or analyze them further.

For this lesson, you will select a single census tract using Select by Expression, then run Select by Location to find all school points whose geometry falls within that polygon boundary.

Exporting Results as GeoJSON

After selecting features, right-click the layer → Export → Save Selected Features As. Choose GeoJSON as the format, set the coordinate reference system (CRS) — WGS 84 (EPSG:4326) is the most portable choice for GeoJSON — and name your output file. QGIS writes only the selected records to the new file, giving you a clean, filtered dataset. Open the new layer to confirm the record count matches your expectation.

Editing Vector Features

Before editing, toggle editing mode by clicking the pencil icon in the toolbar or pressing Ctrl+E. A red pencil icon on the layer confirms it is editable. Use the Add Point Feature tool to click on the map canvas where you want to place a new point. QGIS will immediately prompt you to fill in attribute values — do not skip any required fields. After entering attributes, click OK. Repeat for each new feature.

When finished, click Save Layer Edits (the floppy disk icon next to the pencil), then toggle editing off. Saving and toggling editing off are two separate steps — forgetting to save is a common mistake that causes data loss.

Have a partner open the attribute table and check that every new feature has a populated name and category field. Empty (NULL) attributes are a data quality problem that will cause errors in later analysis steps.

Data Sources and File Handling

US Census TIGER/Line shapefiles provide authoritative boundaries for census tracts, counties, ZIP codes, roads, and water features. They are free from the Census Bureau website. City and county open-data portals (common platforms include ArcGIS Hub and Socrata) publish point layers such as school locations, business permits, and crime incidents. Download these before the lab session because network speeds inside a classroom can be slow.

Shapefiles consist of at least four files (.shp, .shx, .dbf, .prj). Always keep them together in the same folder. Renaming only the .shp file without renaming the others breaks the link between geometry and attributes.

Safety and Data Integrity Notes

There are no physical hazards in a GIS lab. However, data integrity is the professional equivalent of safety in data science: always work on a copy of original data files, never the originals. Keep originals in a read-only folder. Before sharing or submitting any dataset containing individual-level information, verify that it contains no personally identifiable information (PII) — even publicly downloaded data sometimes includes fields that, combined, could identify individuals. When in doubt, consult your instructor before sharing files outside the classroom network.

Key terms9

Vector dataA GIS data model that represents geographic features as points, lines, or polygons, each paired with a row of attribute information in a table.
Attribute tableA tabular structure attached to a vector layer where each row represents one feature and each column stores a descriptive field such as name, population, or category.
Select by ExpressionA QGIS tool that uses SQL-like syntax to select features whose attribute values satisfy a specified condition, highlighting them on the map canvas.
Select by LocationA QGIS spatial query tool that selects features from one layer based on their geometric relationship (e.g., within, intersects) to features in another layer.
GeoJSONA text-based, open-standard file format that encodes geographic features and their attributes in a single JSON file; widely used for web mapping and data exchange.
ShapefileA widely used vector data format consisting of multiple companion files (.shp, .shx, .dbf, .prj) that together store geometry, spatial index, attributes, and coordinate reference system information.
TIGER/LineA set of free, authoritative geospatial files published by the US Census Bureau covering census tracts, roads, counties, and other features used in demographic and geographic analysis.
Query BuilderA QGIS layer property that applies a persistent SQL-like filter to hide non-matching features from display and analysis without deleting them from the source data.
Coordinate Reference System (CRS)A framework that defines how geographic coordinates relate to locations on the Earth's surface; WGS 84 (EPSG:4326) is the standard used for GeoJSON and most web mapping.
In class: Instructor demo of the QGIS attribute table, Select by Expression tool, and the Query Builder using a public crime or permit dataset; students follow along on their own machines and record the SQL-like expressions used. · Individual lab: students load a city open-data polygon layer (e.g., census tracts) and a point layer (e.g., public schools), run attribute queries to filter features meeting specified criteria, and use 'Select by Location' to identify all schools within a specified census tract; they export results as GeoJSON. · Editing exercise: students add three new point features to an existing layer (e.g., locations of community centers identified from a reference map), populate attributes including name and category, and save edits; a partner reviews the attribute table for completeness.
Materials: QGIS 3.x, US Census TIGER/Line shapefiles, city or county open-data portal shapefiles (pre-downloaded), QGIS Training Manual (open-source, qgis.org), lab worksheet with step-by-step instructions and expected outputs
Check: Students submit: exported GeoJSON file with correct filtered features, a screenshot of the Select by Location result, and the edited layer. Instructor checks that the GeoJSON contains only records matching the query criteria and that new features have fully populated attributes; pass mark: all three deliverables correct and complete.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Data querying and filtering
1. In QGIS, which tool would you use to select only the census tracts where the field 'MED_INCOME' is greater than 45000?
Spatial analysis
2. A student wants to find all public schools located inside census tract 042.01. After selecting tract 042.01 with Select by Expression, what is the correct next step?
Data export and file formats
3. After running a spatial query in QGIS and selecting the desired features, how do you export only those selected records as a GeoJSON file?
GIS tools and software
4. Which of the following correctly describes the difference between the QGIS Query Builder and Select by Expression?
Data management and file formats
5. A shapefile downloaded from a city open-data portal contains the files school_locations.shp, school_locations.dbf, school_locations.shx, and school_locations.prj. A student renames only the .shp file to 'schools.shp' and moves it to a new folder without the other files. What is the most likely result?
GIS editing and data integrity
6. When adding new point features during an editing session in QGIS, what is the correct order of final steps to ensure edits are not lost?
Data formats and standards
7. A data analyst is preparing a GeoJSON file for use in a web mapping application. Which coordinate reference system is the most portable and widely expected choice for GeoJSON according to its specification?
Data quality and validation
8. During peer review of an edited point layer, a partner notices that two of the three newly added community center features have NULL values in the 'category' field. Why is this a data quality problem?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.