Contouring in C ATS 315. How Contours Really Work Contours may LOOK like curves, but they are really just straight line segments.

Slides:



Advertisements
Similar presentations
2009 Road Scholars Complete the Student-Generated Map Activity using the resources provided at your table.
Advertisements

A. How do we tell the location by letters and numbers?
1 Lab 09-4 ONLINE LESSON. 2 If viewing this lesson in Powerpoint Use down or up arrows to navigate.
Turns Right Angles Angles Angles ©mdhazrin. One Complete Turn 90   1 round clockwise Angles: Angles: Turns & Right angles 90   360  ©mdhazrin.
Direction at your fingertips. A compass rose is a design on a map that shows directions. It shows north, south, east, west, northeast, northwest, southeast,
Help me find the cardinal directions
The Compass Rose.
Unit 2 Map Skills Visual Vocabulary.
Section, Township, Range By: Cytetn Industries, Inc.By: Cytetn Industries, Inc.
World Geography Pretest
Basic Geography Review (or World Geography)
Locating Places on a Map. 2 Cardinal Points The four main directions of a compass are known as cardinal points. They are north (N), east (E), south (S)
Vectors 9/13/13. Bellwork ► Bellwork: Do you use the “Word Doc” and “PowerPoints” from the labs? ► Bellwork class poll.
Unit 2 Map Skills. Cornell Notes White = Left Yellow = Right.
Map Skills. Geography The study of the earth’s surface and the way people use it The study of the earth’s surface and the way people use it.
Direction at your fingertips. A compass rose is a design on a map that shows directions. It shows north, south, east, west, northeast, northwest, southeast,
Week 2 GLEs 1, 2, 3, 5.  A map is a flat image of a place on earth.
Geography: The Study of Earth
MAPS.
Basic Components of a World Map. Compass Rose Compass rose tells direction on a map. 1. Cardinal Directions NnorthS south E eastW west 2. Intermediate.
Tells what the map is about Shows the location of cities, states, and countries.
Orientation Location Scale By: Eleanor Joyce City of Salem Schools.
MAP SKILLS How do we find places on maps? VOCABULARY TERM Compass Is a tool that helps the user know what direction they are going.
Parts of a Map SOL USII.1.G. Why are maps useful? Show people where things are Can include information on population, elevation, resources, etc. They.
Theme 4 - Location Where is It?Where is It? Why is It There?Why is It There? Two Types of Location Absolute Relative.
Elements on a Map Compass Rose Legend Bar Scale Title Inset Map
Map Skills Directions – Where do I go???. How can you tell what direction you are facing? Watch the movement of the sun or stars. Watch the movement of.
CARDINAL DIRECTIONS BY: KANIESHIA WILSON. Content Area: Social Studies Grade Level: 3rd Summary: The purpose of this instructional PowerPoint is for students.
Map Skills.
Mapdraw ats315. Today’s goal: Drawing a map in the graphics window! Drawing a map in the graphics window!
Sectionalism Map Assignment
MAPS 3.G.1.1 Students ARE ABLE TO IDENTIFY AND USE MAP COMPONENTS. Examples: Title, map key, compass rose, lines and borders, roads and routes, objects.
Orientation Location Scale. Orientation Location or position relative to the points on the compass. Cardinal Directions– North, South, East, West Intermediate.
Map Skills How do we find places on maps? Imaginary Lines Latitude and LongitudeThe earth is divided into lots of lines called latitude and longitude.
AIM: What are the important features included in a map? Do Now: Complete the Compass Rose Worksheet.
GRID REFERENCES NORTHINGS AND EASTINGS.  NOT THE SAME AS LATITUDE AND LONGITUDE  Used to help you locate a specific spot on a flat map  Uses a grid.
Unit 3 Locating Places On A Map When giving directions you need to know: Where you are & Where you want to go. A Compass rose show directions in terms.
Maps, Keys, and Legends.
Map Skills How do we find places on maps? Vocabulary Term Compass Is a tool that helps the user know what direction they are going.
Latitude and Longitude
Map Skills Training Course
TOPOGRAPHIC MAPS Key Vocabulary:
Map Skills/ Latitude and Longitude
Chapter 5.4 – Angles of elevation and depression
BEARINGS.
NORTHINGS AND EASTINGS
Latitude and Longitude
Latitude and Longitude
Mapping Skills.
Field Maps.
Locating Places on a Map
Mapskills How do we use maps?.
Map Essentials: Parts of a Map
How do we find places on maps?
Basic Components of a World Map
Unit 1 Map Skills Visual Vocabulary.
Unit 1 Map Skills.
Theme 4 - Location Two Types of Location Where is It? Absolute
Map Skills Study Guide Answers
Latitude and Longitude:
北 N north 西 W west 東 E east south南 S.
Welcome to Jeopardy! Cardinal Directions Maps & Globes Longitude
Map Skills Study Guide Answers
NORTHINGS AND EASTINGS
Warm Up After picking up your spiral and filling out your planner…
Maps & Map Keys.
Title Every map should have a title.
Before the Bell Rings… Please sit down.
INTRODUCTION TO MAP SKILLS
Social studies vocabulary
Presentation transcript:

Contouring in C ATS 315

How Contours Really Work Contours may LOOK like curves, but they are really just straight line segments.

How Contouring Works:

So What We Are Really Worried About…

The northwest corner is grid[i][j]. grid[i][j]

The northwest corner is grid[i][j]. grid[i][j]grid[i][j+1] grid[i+1][j]grid[i+1][j+1]

The northwest corner is grid[i][j]. grid[i][j]grid[i][j+1] grid[i+1][j]grid[i+1][j+1]

How the contour is drawn depends on the value of the contour and the values at the four corners! grid[i][j]grid[i][j+1] grid[i+1][j]grid[i+1][j+1]

For simplicity, rename the values at the corners: nwne swse

Count the number of corners with values greater than the contour line. nwne swse

CornersGreaterThanContour can be 0, 1, 2, 3, or 4. nwne swse

if (CornersGreaterThanContour==0) do nothing nwne swse

if (CornersGreaterThanContour==4) do nothing nwne swse

if (CornersGreaterThanContour==1)… there are four possibilities: nwne swse

if (CornersGreaterThanContour==1)… there are four possibilities: nwne swse Possibility 1: Only the northwest corner is greater than the value of the contour.

if (CornersGreaterThanContour==1)… there are four possibilities: nwne swse Possibility 2: Only the northeast corner is greater than the value of the contour.

if (CornersGreaterThanContour==1)… there are four possibilities: nwne swse Possibility 3: Only the southeast corner is greater than the value of the contour.

if (CornersGreaterThanContour==1)… there are four possibilities: nwne swse Possibility 4: Only the southwest corner is greater than the value of the contour.

if (CornersGreaterThanContour==2)… there are three possibilities: nwne swse

if (CornersGreaterThanContour==2)… there are three possibilities: nwne swse Possibility 1: The line should be drawn from the west edge to the east edge. Either: Both ne and nw are bigger than contour… or Both ne and nw are smaller than contour.

if (CornersGreaterThanContour==2)… there are three possibilities: nwne swse Possibility 2: The line should be drawn from the north edge to the south edge. Either: Both ne and se are bigger than contour… or Both ne and se are smaller than contour.

if (CornersGreaterThanContour==2)… there are three possibilities: nwne swse Possibility 3: Two contour lines pass through this box. Either: Both nw and se are bigger than contour… or Both nw and se are smaller than contour.

if (CornersGreaterThanContour==3)… there are four possibilities: nwne swse

if (CornersGreaterThanContour==3)… there are four possibilities: nwne swse Possibility 1: Only the northwest corner is less than the value of the contour.

if (CornersGreaterThanContour==3)… there are four possibilities: nwne swse Possibility 2: Only the northeast corner is less than the value of the contour.

if (CornersGreaterThanContour==3)… there are four possibilities: nwne swse Possibility 3: Only the southeast corner is less than the value of the contour.

if (CornersGreaterThanContour==3)… there are four possibilities: nwne swse Possibility 4: Only the southwest corner is less than the value of the contour.

What will this program look like?

/* Compute CornersGreaterThanContour */ if (CornersGreaterThanContour == 0) { } if (CornersGreaterThanContour == 1) { } if (CornersGreaterThanContour == 2) { } if (CornersGreaterThanContour == 3) { } if (CornersGreaterThanContour == 4) { }

What will this program look like? /* Compute CornersGreaterThanContour */ if (CornersGreaterThanContour == 0) { /* Do nothing */ } if (CornersGreaterThanContour == 1) { } if (CornersGreaterThanContour == 2) { } if (CornersGreaterThanContour == 3) { } if (CornersGreaterThanContour == 4) { /* Do nothing */ }

What will this program look like? if (CornersGreaterThanContour == 1) { } if (CornersGreaterThanContour == 2) { } if (CornersGreaterThanContour == 3) { }

What will this program look like? if (CornersGreaterThanContour == 1) { if( nw > contour) { } if( ne > contour) { } if( se > contour) { } if( sw > contour) { } } if (CornersGreaterThanContour == 2) { } if (CornersGreaterThanContour == 3) { }

What will this program look like? if (CornersGreaterThanContour == 2) { } if (CornersGreaterThanContour == 3) { }

What will this program look like? if (CornersGreaterThanContour == 2) { if((ne > contour && nw > contour) || (ne < contour && nw < contour)) { } if((ne > contour && se > contour) || (ne < contour && se < contour)) { } if((nw > contour && se > contour) || (nw < contour && se < contour)) { } } if (CornersGreaterThanContour == 3) { }

What will this program look like? if (CornersGreaterThanContour == 3) { }

What will this program look like? if (CornersGreaterThanContour == 3) { if( nw < contour) { } if( ne < contour) { } if( se < contour) { } if( sw < contour) { } }

Deciding how to draw the contour nwne swse Let’s say that you have determined that this is the kind of line you need to draw. This line segment has a starting point and an ending point.

Deciding how to draw the contour nwne swse What determines the location of the starting point?

Deciding how to draw the contour nwne swse What determines the location of the starting point? INTERPOLATION!

Deciding how to draw the contour nwne swse Suppose we are drawing the 1000 mb contour. nw = ne =

Deciding how to draw the contour nwne swse Suppose we are drawing the 1000 mb contour. nw = ne =

Deciding how to draw the contour nwne swse startlat = ??? startlon = ???

Deciding how to draw the contour nwne swse startlat = depends on: latitude of nw latitude of ne value at nw value at ne value of contour startlon = depends on: longitude of nw longitude of ne value at nw value at ne value of contour

Deciding how to draw the contour nwne swse interp(gridlatitude[i][j], &startlat, gridlatitude[i][j+1], nw, contour, ne); interp(gridlongitude[i][j], &startlon, gridlongitude[i][j+1], nw, contour, ne);

Deciding how to draw the contour nwne swse How about the endlat and endlon?

Deciding how to draw the contour nwne swse interp(gridlatitude[i][j+1], &endlat, gridlatitude[i+1][j+1], ne, contour, se); interp(gridlongitude[i][j+1], &endlon, gridlongitude[i+1][j+1], ne, contour, se);

Deciding how to draw the contour nwne swse Once you have (startlat, startlon) and (endlat, endlon): 1.tranform 2.clip 3.gline

How this produces contours

i=0 i=1 i=2 i=3 j=0j=1j=2j=3

How this produces contours i=0 i=1 i=2 i=3 j=0j=1j=2j=3

How this produces contours i=0 i=1 i=2 i=3 j=0j=1j=2j=3

How this produces contours i=0 i=1 i=2 i=3 j=0j=1j=2j=3

How this produces contours i=0 i=1 i=2 i=3 j=0j=1j=2j=3

How this produces contours i=0 i=1 i=2 i=3 j=0j=1j=2j=3

How this produces contours i=0 i=1 i=2 i=3 j=0j=1j=2j=3

How this produces contours i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

for(contour=mincontour;contour<=maxcontour;contour=contour+conint) i=0 i=1 i=2 i=3 j=0j=1j=2j=3

Great, I can picture what this looks like, but how do I do it?

The Steps Open the window Draw the base map Read the sao.cty file Read the current_sao.wxp file Produce grids of objectively analyzed data. Contour (like this….)

for(i=0;i<NUMROWS-1;i++) { for(j=0;j<NUMCOLS-1;j++) { for(contour=mincon;contour<=maxcon; contour=contour+conint) { CornersGreaterThanContour = ?????; if (CornersGreaterThanContour==0) { } if (CornersGreaterThanContour==1) { } if (CornersGreaterThanContour==2) { } if (CornersGreaterThanContour==3) { } if (CornersGreaterThanContour==4) { } }

for(i=0;i<NUMROWS-1;i++) { for(j=0;j<NUMCOLS-1;j++) { for(contour=mincon;contour<=maxcon; contour=contour+conint) { CornersGreaterThanContour = ?????; if (CornersGreaterThanContour==0) { } if (CornersGreaterThanContour==1) { } if (CornersGreaterThanContour==2) { } if (CornersGreaterThanContour==3) { } if (CornersGreaterThanContour==4) { } } For every “square” on the map… (Notice that there are (NUMROWS-1)x(NUMCOLS-1) squares…)

for(i=0;i<NUMROWS-1;i++) { for(j=0;j<NUMCOLS-1;j++) { for(contour=mincon;contour<=maxcon; contour=contour+conint) { CornersGreaterThanContour = ?????; if (CornersGreaterThanContour==0) { } if (CornersGreaterThanContour==1) { } if (CornersGreaterThanContour==2) { } if (CornersGreaterThanContour==3) { } if (CornersGreaterThanContour==4) { } } For every possible contour level… (We’ll discuss how to figure this out shortly.)

for(i=0;i<NUMROWS-1;i++) { for(j=0;j<NUMCOLS-1;j++) { for(contour=mincon;contour<=maxcon; contour=contour+conint) { CornersGreaterThanContour = ?????; if (CornersGreaterThanContour==0) { } if (CornersGreaterThanContour==1) { } if (CornersGreaterThanContour==2) { } if (CornersGreaterThanContour==3) { } if (CornersGreaterThanContour==4) { } } Determine the number of corners on this square that are greater than the current contour level. (This will take about 5 lines of code.)

for(i=0;i<NUMROWS-1;i++) { for(j=0;j<NUMCOLS-1;j++) { for(contour=mincon;contour<=maxcon; contour=contour+conint) { CornersGreaterThanContour = ?????; if (CornersGreaterThanContour==0) { } if (CornersGreaterThanContour==1) { } if (CornersGreaterThanContour==2) { } if (CornersGreaterThanContour==3) { } if (CornersGreaterThanContour==4) { } } For each of the 5 possible values of CornersGreaterThanContour, you’ll need the elaborate “if” statements discussed earlier.

for(i=0;i<NUMROWS-1;i++) { for(j=0;j<NUMCOLS-1;j++) { for(contour=mincon;contour<=maxcon; contour=contour+conint) { CornersGreaterThanContour = ?????; if (CornersGreaterThanContour==0) { } if (CornersGreaterThanContour==1) { } if (CornersGreaterThanContour==2) { } if (CornersGreaterThanContour==3) { } if (CornersGreaterThanContour==4) { } } Where do you get these values? mincon, maxcon, conint

You could just prompt the user for these three values. Better: prompt the user for conint, and compute mincon and maxcon! But, to do this, you first need to be able to compute max and min of the grid!

max and min Suppose you have a 2D grid of floating point numbers. min needs to be the lowest value in the grid, and max needs to be the highest

max and min min = ; max = ; for(i=0;i<NUMROWS;i++) { for(j=0;j<NUMCOLS;j++) { if (grid[i][j] < min) min = grid[i][j]; if (grid[i][j] > max) max = grid[i][j]; }

max and min min = ; max = ; for(i=0;i<NUMROWS;i++) { for(j=0;j<NUMCOLS;j++) { if (grid[i][j] < min) min = grid[i][j]; if (grid[i][j] > max) max = grid[i][j]; } Set min to a very high number and max to a very low number

max and min min = ; max = ; for(i=0;i<NUMROWS;i++) { for(j=0;j<NUMCOLS;j++) { if (grid[i][j] < min) min = grid[i][j]; if (grid[i][j] > max) max = grid[i][j; } For every element of the 2D array…

max and min min = ; max = ; for(i=0;i<NUMROWS;i++) { for(j=0;j<NUMCOLS;j++) { if (grid[i][j] < min) min = grid[i][j]; if (grid[i][j] > max) max = grid[i][j]; } If grid[i][j] < min, min=grid[i][j] !

max and min min = ; max = ; for(i=0;i<NUMROWS;i++) { for(j=0;j<NUMCOLS;j++) { if (grid[i][j] < min) min = grid[i][j]; if (grid[i][j] > max) max = grid[i][j]; } If grid[i][j] > max, max=grid[i][j] !

But Sadly… min  mincon max  maxcon

But Happily… mincon = (float) (( (int)(min/conint) + 1) * conint) maxcon = (float) (( (int)(max/conint) ) * conint) You can work out the math and see that this works! (maxcon is easier than mincon)

Grading Assignment 15 Properly determine mincon and maxcon from a grid of data, prompting the user for the contour interval.

Grading Assignment 15 Correctly determining most of the things you need to draw contours, but not getting good output:

Grading Assignment 15 Successfully contouring temperature fields:

Grading Assignment 15 Successfully contouring any grid of data chosen by the user:

Suggested “Impressive” Things Variable domains Variable colors for the contours Nice labels for the plot (NOT contour labels!)