Full teaching narration is free with Private Starter.Create free account
Back to curriculum
Computer ScienceGrade 4· U.S. National — Common Core & NGSS
Aligned to:U.S. educational frameworks

Program a Map Feature Classifier

Students create and test a simple sequence of if-then rules that classifies mapped locations as mountains, plains, or bodies of water based on visible geographic features.

Program a Map Feature Classifier

Illustrations are auto-generated and may be placeholders. They can be refreshed to match the narration.

Full teaching narration is included free with a Private Starter account.Create free account

Explore Features on a Map

Maps use colors, shapes, symbols, and elevation information to show Earth’s features. Begin by studying a physical map and its key. Bodies of water are often shown in blue. Mountains may appear as raised, shaded land or as areas with high elevations and closely spaced contour lines. Plains are broad areas of mostly flat or gently rolling land, often with little change in elevation. Compare several locations and describe only the evidence visible on the map. For example, a large blue area labeled with a shoreline is probably a lake, while a brown region with several high peaks is probably mountainous. Work with a partner to explain which clues support each choice. Remember that map colors can vary, so always check the map key before classifying a location.

A physical map shows a blue lake with a shoreline, steep mountains with close contour lines, flat plains, and a map key.
A physical map shows a blue lake with a shoreline, steep mountains with close contour lines, flat plains, and a map key.Source: Illustrated for this lesson

Introduce If-Then Rules

An if-then rule tells a computer what action to take when a condition is true. The if part asks a question about the map evidence, and the then part gives a classification. One rule might say, “If most of the location is blue and the map key identifies blue as water, then classify it as a body of water.” Another rule could use elevation: “If the land has high peaks or closely spaced contour lines, then classify it as mountains.” A computer checks exactly what the rule says, so each condition must be clear and observable. Rules are often arranged in a sequence. The computer checks the first rule, then the next rule if needed. Discuss each rule with classmates and ask whether everyone can use the same evidence to reach the same result.

A simple rule diagram connects a map clue to a true-or-false decision and then to a body of water classification.
A simple rule diagram connects a map clue to a true-or-false decision and then to a body of water classification.Source: Illustrated for this lesson

Design the Classifier

Create a sequence of rules that places each mapped location into one of three classes. Put the most specific rule first. Rule 1 can be: “If the location is mostly inside a shoreline and shown as water in the map key, then classify it as a body of water.” Rule 2 can be: “Otherwise, if the land has high elevations, peaks, or many closely spaced contour lines, then classify it as mountains.” Rule 3 can be: “Otherwise, if the land is broad and mostly flat, with little elevation change, then classify it as plains.” The word otherwise means that an earlier rule was not true. Record the rules in order using a flowchart, numbered list, or simple program. Make sure every location can reach an answer, and explain why the evidence in each condition matches the geographic class.

A three-step flowchart sends map locations through water, mountain, and plains decisions in order.
A three-step flowchart sends map locations through water, mountain, and plains decisions in order.Source: Illustrated for this lesson

Test with Sample Locations

Testing means running several sample locations through the rules and recording the results. Use samples that show different features. Location A is mostly blue, lies inside a shoreline, and matches the water symbol in the key. Rule 1 classifies it as a body of water. Location B is land with several peaks and contour lines packed closely together. Rule 1 is false, but Rule 2 is true, so it is classified as mountains. Location C is a wide land area with few elevation changes. The first two rules are false, so Rule 3 classifies it as plains. Create a table with the location, visible evidence, predicted class, and actual class provided by the teacher. Compare the results. A correct result is a match; an incorrect result shows that the rules may need improvement.

A test table compares evidence and classifications for three sample locations: water, mountains, and plains.
A test table compares evidence and classifications for three sample locations: water, mountains, and plains.Source: Illustrated for this lesson

Debug and Improve the Rules

Debugging means finding and fixing problems in a program or rule sequence. Suppose the classifier labels a blue-colored river valley as a body of water even though most of the test area is land. The water rule may be too broad. Improve it by requiring both clues: “If more than half of the location is shown as water and the map key confirms the water symbol, then classify it as a body of water.” A mountain rule may also fail if it looks only for brown coloring, because some maps use brown for other purposes. Add stronger evidence, such as peaks, high elevation numbers, or closely spaced contour lines. After changing one rule, test all sample locations again. Keep a record of each change and its results. Collaborate by listening to classmates’ explanations and choosing revisions supported by map evidence.

A before-and-after rule diagram fixes the classification of a mostly land test area containing a narrow blue river.
A before-and-after rule diagram fixes the classification of a mostly land test area containing a narrow blue river.Source: Illustrated for this lesson