+ All Categories
Transcript
Page 1: Graphs, grouping, pie charts and other  ‘ stuff ’ .

1

Peter Fox

GIS for Science

ERTH 4750 (98271)

Week 10, Tuesday, April 3, 2012

Graphs, grouping, pie charts and other ‘stuff’.

Page 2: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Contents (eek!)• Pie charts on

thematic map

• Graphs

• Editing attributes in tables

• Manipulating objects within MapInfo

• Graduated symbol maps

• Bivariate thematic maps

2

• Dispersing points

• Creating points for intersections of lines

• Extracting latitude and longitude from a geocoded table

• Selecting data that are not geocoded

• Web links

• Adding tools

Page 3: Graphs, grouping, pie charts and other  ‘ stuff ’ .

3

Page 4: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Pie charts (sorry, but they survive)!

• Pie chart of the ethnicity of the population for the New England States (table usa).

• Open USA.TAB, select New England States with marquis select, save as new table (ne_states.tab).

• Display NE states only, Create Thematic map, select Pie Charts > Next > Table = NE_states, select and Add from fields, pop_cauc, pop_black, pop_native, etc. > Next.

• Click Styles > turn on Half Pies > OK > OK.4

Page 5: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Looks like this …

5

Page 6: Graphs, grouping, pie charts and other  ‘ stuff ’ .

More thematic maps• Bar charts to show the quarterly rainfall for

the New England States.

• Open ne_states and US_rain.

• Select rain data points from NE states and write to separate table NE_rain.

• NE_rain has monthly data so we need to put it into quarterly sums.

• To do this add 4 columns to the table (Table > Maintenance > Table structure) and Update columns to hold quarterly sums. 6

Page 7: Graphs, grouping, pie charts and other  ‘ stuff ’ .

More thematic maps• Create Thematic map, select Bar Chart >

Next > select columns to plot > Next > OK.

• But … because some states have multiple measurement sites we have to group them.

• Query > SQL select > Columns = State,sum(q1),sum(q2),sum(q3),sum(q4) > Tables = NE_rain > Group by = state > into Table = ne_q.

• Create Thematic map, select Bar Chart > Next > select columns to plot > Next > OK.

7

Page 8: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Looks like this

8

Page 9: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Adding/ comparing• Using a table of friends zipcodes (earlier exercise),

add their ages and add 5 new friends (or class members) to the table.

• Plot them on a map that distinguishes new friends from old and their ages.

• Open friends table (NB save copy as new_friends). • Open new_friends, Table > Maintenance > Structure

> Add field old_new as character (3) and age as Integer.

• Open the table in Browser window and add new information. You can also edit the data via the Info tool. 9

Page 10: Graphs, grouping, pie charts and other  ‘ stuff ’ .

and• To add or delete rows, go to Edit > New Row

or Edit > Clear.

• You’ll have to Geocode the data again.

• To remove rows from the table Table > Maintenance > Pack Table > Save changes > read table in again.

10

Page 11: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Creating attributes• Make CL editable > put objects on map with

tools > Map > Save CL objects and name the new table

• Open new Browser window

• Table > Maintenance > Table structure > add fields (add "area" column)

• Table > Update column > Column = "area" > Value > Assist > Function > Area

• Save table11

Page 12: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Modify graphic objects• Make layer with objects editable (if you can’t

do this, try saving table with a different name).

• Select the object to be changed. Select Reshape icon or Edit > Reshape.

• Click on the node to be moved.

• Select multiple nodes in sequence with Shift-click (short-route) or Ctrl-click (long-route) and move them together.

• Ctrl-click on same node twice will select all nodes.

12

Page 13: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Modify graphic objects• If the object borders another and shares

nodes, first go to Options > Preferences > Map window > click on Move duplicate nodes in the same layer.

• If you don’t do this, you can open up gaps between objects or make them overlap.

• Use add nodes icon to add nodes.

13

Page 14: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Combining objects• Make table editable, Select objects to be

combined, Objects > Combine, select how to combine object attributes.

14

Page 15: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Splitting objects• Objects must be split with another object

which can either exist or be made on the cosmetic layer.

• First, make splitting object if necessary.

• Make CL editable, create polygon to be the "splitter", save to cut.tab (Map > Save Cosmetic objects).

• Make target file editable, select the object to be split then Object > Set target, select the "splitter" object, then Objects > Split > OK.

• Remove cut.tab from display.15

Page 16: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Graduated symbol maps.• Graduated symbol maps use symbol sizes to

represent different values.

• To make a graduated map of Japanese earthquakes where the earthquake magnitude is represented by symbol size: read tables ‘world’ and ‘japan_quakes’ > Map > Create TM > Graduated > Next > choose table = japan_quakes and field = mb > Next > Modify settings > OK.

16

Page 17: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Bivariate thematic maps• Bivariate maps are those that represent two

attributes with a single symbol on the map. For example, we can represent earthquake depth with color and earthquake magnitude with symbol size.

• To do this first create a TM of the earthquake depth using point ranges. Use 6 ranges and select equal count.

• Then create a second TM using point ranges for the mb field.

17

Page 18: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Bivariate thematic maps• Under step 3 of 3 click Styles > Options and

under Autospread select Size.

• Then under Apply choose size again.

• The symbols should become hollow but of graduated size.

• Click OK and the graduated size symbols draw over the color ranged symbols.

• Deep Japan earthquakes.18

Page 19: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Voila, and uh-oh…

19

Page 20: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Mapbasic - prelude• MapBasic is a programming language for MapInfo

that encompasses many direct calls to mapping and database functions.

• It is used in one of two ways: either through Options > Show MapBasic window in MapInfo or through the MapBasic interface and compiler.

• MapBasic Window

20

Page 21: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Mapbasic compiler• MapBasic is a standalone program to develop

programs that interface with MapInfo. • One can manipulate data and maps from within

MapBasic programs.• E.g. a MapBasic program that performs the same

function as that given above for the MapBasic Window looks like this:declare sub main

sub main

open table "c:\mapinfo\data\world.tab" Interactive [replace with correct path]

map from world

select * from world where pop_1994> 10000000 into selection

browse * from selection

map from selection

end sub

21

Page 22: Graphs, grouping, pie charts and other  ‘ stuff ’ .

• The body of the program is identical to the MapBasic Window commands.

• To run this program, start MapBasic, select File > New, paste the program into the editor window, select Project > Compile current file (or Ctrl-K), then select Project > Run (or Ctrl-U).

• If MapInfo is not already running it will start and perform the tasks.

• The result should be a map window showing only countries with > 10 million inhabitants.

22

Page 23: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Mapbasic - prelude• One can perform many of the MapInfo functions via

the MapBasic window by entering command lines. • For example to open the world table and make a

map of countries with greater than 10 million people, type in the MapBasic window:

open table "c:\mapinfo\data\world.tab" Interactive map from world

select * from world where pop_1994> 10000000 into selection

browse * from selection

map from selection

• There are several functions available for MapBasic. • To view MapBasic functions, open the MapBasic

window as you perform tasks with MapInfo's interactive screen.

23

Page 24: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Dispersing points• Sometimes when we geocode we get many

points falling at the same coordinates.

• This happens because the data are geocoded to the centroid of the entity, for example when we geocoded with zip codes.

• For the purposes of the map, we can disperse the points to give the proper representation of the number of points.

• To do this we can use the MapBasic window. Choose Options> Show MapBasic window to open the MapBasic window.

24

Page 25: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Dispersing points (ctd)• Within the window type:

randomize

update selection set obj = createpoint(centroidx(obj) +.02*rnd(1), centroidy(obj)+.02*rnd(1))

• This will randomly redistribute the points to the northeast within 0.02 degrees (or whatever the distance units are).

• To randomly redistribute them about the current point, use:update selection set obj = createpoint(centroidx(obj) +.02*(rnd(1)-.5), centroidy(obj)+.02*(rnd(1)-.5))

• The table will be automatically updated and the new points will appear on the map. Make sure you save a copy of your original data.

25

Page 26: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Creating points for intersections of lines

• In some cases we might be interested only in the intersections of lines, for example street intersections. We can create a new table of points containing only the intersections.

• Open the street file nyrensd. Make 2 copies of the nyrensd file and give each a unique name (File > Save copy as) such as str1 and str2. Open the 2 new files you have created.

• Choose Query > SQL select. In the dialog box enter:– Select columns = str1.streetname + "&&" +

str2.streetname

26

Page 27: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Then From Tables = str1, str2

Where Condition = str1.obj Intersects str2.obj and str1.streetname <> str2.streetname

Into Table Named = Intersection

• Save the Intersection table (File > save copy as).

27

Page 28: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Lon/lat from geocoded table• You may want to see the latitude and

longitude in your geocoded table.

• There are 2 ways to do this depending on whether you want a new table or want to put the lat/lon in your original table.

• To create a new table use Query > SQL select.

• Under select columns, enter columns you want in the new table and then also put:– CentroidX(obj) "Longitude", CentroidY(obj)

"Latitude"28

Page 29: Graphs, grouping, pie charts and other  ‘ stuff ’ .

And • To add the lat/lon to an existing table, select

Table > Maintenance > Table structure and add 2 new columns to your table.

• Call the Lat and Lon and make them ‘float’ types.

• Then choose Table > Update column. Enter your table name under Table to update and Get value from Table.

• Column to update should be your lat or lon and Value shoud be CentroidY(obj) for latitude and CentroidX(obj) for longitude.

29

Page 30: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Selecting data that are not geocoded

• You may want to get a Browser list of points that did not geocode from a particular table.

• Open the table and choose Query > Select. Under that Satisfy enter not obj.

• This selects all the data records that are not objects, i.e., not geocoded.

• Example: Geocode friends.xls with zip_codes and find those that do not geocode. 30

Page 31: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Un-geocoding tables or data• Un-geocoding means removing the objects

from a Table.

• You may want to do this if you are going to re-geocode using a better method or have better data to geocode with.

• To un-geocode an entire table: select Table > Maintenance > Table structure.

• Clear the Table is Mappable check box > OK > OK.

• This is irreversible. 31

Page 32: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Un-geocoding tables or data• To un-geocode selected objects: Plot the data

in a map window.

• Select the points you want to un-geocode.

• Choose Layer control and set the layer to be editable.

• Choose Edit > Clear Map objects only.

• This un-geocodes the data but does not remove them from the table.

• To undo choose Edit > Undo Deletion.32

Page 33: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Creating web links for maps• WWW links can be incorporated into the

maps using the HotLink button (the lightning bolt).

• To create the links, add a column to your table through the Table > Maintenance > Structure option.

• Make it a character string long enough to accommodate your longest URL.

• Open the table in the Browser window and type in the URLs.

• In Layer Control, click on the HotLink button. 33

Page 34: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Creating web links for maps• Select the column containing the links in the

FilenameExpression dropdown box and check the Save options to table metadata box to save URLs with table.

• Don't forget File > Save table.

• To activate the link on the map, click on the HotLink button (the lightning bolt) and then on the map object.

• Example: Add http://www.states.AL.us to the states table for Alabama.

34

Page 35: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Adding tools to MapInfo• Tools are external routines that can be called from the

MapInfo interface. – They are accessed via the Tools menu.

• A tool can be developed as a MapBasic program and its compiled form (.mbx file) is run from MapInfo.

• To add a tool, select Tools > Tool Manager > Add Tool and fill out the location of the tool (the .mbx file) and a description. – The tool will run.

• To run it later, select Tools, then find the tool and check Loaded.

• Checking Autoload will cause it to run on Startup of MapInfo.• Example: Add the Xcel_2_tab tool.

35

Page 36: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Summary• Topics for GIS (for Science)

– Extras!

• For learning purposes remember:– Demonstrate proficiency in using geospatial applications and tools

(commercial and open-source).

– Present verbally relational analysis and interpretation of a variety of spatial data on maps.

– Demonstrate skill in applying database concepts to build and manipulate a spatial database, SQL, spatial queries, and integration of graphic and tabular data.

– Demonstrate intermediate knowledge of geospatial analysis methods and their applications.

36

Page 37: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Reading for this week• MapInfo (10.8) User Guide

– Chapter 5 Graphing your data– Chapter 7 Graphing and editing objects– Chapter 9 Pie charts, graduated symbols, etc.

• Review the mini-exercises in these slides and work through them in MapInfo – if you have questions, ask on Friday

37

Page 38: Graphs, grouping, pie charts and other  ‘ stuff ’ .

Next classes

• Friday, April 6, Lab: …

• Tuesday, April 10, Editing attributes, manipulating objects in MapInfo

• Friday, April 13, Lab: geostatistics and some more maps

• No class April 17 (Grand Marshall week)38


Top Related