Friday, December 29, 2006

Shape2Earth: Normalizing GIS data for Google Earth

In order to make an effective map, it is often a good idea to normalize the data. One of the reasons for doing this can be seen in the Basic Polygon Height example. In that example, the value for California is so high that is skews the map. Instead of using raw values, we can create a normalized ration that makes the map much more aesthetically pleasing.

Start off by loading the states.shp file (usually found at C:\_GE Data\Sample Projects\United States\Shapefiles\states.shp). MapWindow will assign a default color.

In order to normalize the data, we are going to use some of the tools that are already available in MapWindow. The first thing to do is open the table for states. This is done be selecting states in the table of contents, and then clicking the Table button (see above). This will open up the attribute table for the shapefile (below).


We are going to add a field to hold the normalized values. To do this, click Edit on the menu, and then select Add Field.

This will open up the Create Field dialog box (below). For this demonstration, we will create a field named "NormalizedMALES" that is of type "Double" (this will hold a numerical value for us).



Once you hit OK, a new field will be added to the end of the table. Navigate to this field and right-click it. From the menu that appears, select Calculate Values (All Records).

This selection will open up the Calculate Column Values dialog box. This is where we will enter the algorithm that creates the values in our normalized field.
The algorithm entered below creates a ratio that is based off of the total population of males in from each state. The basic formula is (Males from State X) divided by (Total number of Males from all States). We then multiply the result by a factor that does nothing more than elevate the value so that the states will extrude far enough off of the surface to not intersect the Google Earth.
The formula used for this example is (MALES / (Sum(MALES))) * 1000000.
(NOTE: use of the multiplication factor is not really necessary if you do not plan to use this field as a height value. It also does not need to be nearly as big as the number we used here when using polygon features that are smaller than states, such as buildings.)


After you have entered the formula (above), click the Apply button. This will populate the new field you created with the normalized values.


After hitting Apply, click Close to close the dialog box. Also make sure to click the Apply button at the bottom of the table before closing. This will save your newly created data.
Now that we have a new field with normalized data, we will change the colors of each State based on this new value. Review the demonstration Changing Polygon Colors to see more information on changing colors. The two graphic below are a quick walk through of accessing the Properties and changing the colors.


One more step we will want to take is to spread out the color ramp. To do this, enter a number that is larger than the total number of records (in this case, 48 States).

Red and Yellow have been selected as the ending and starting color, and 100 has been entered for the number of breaks. The spread values can be seen below.


Now we can see the normalize values in MapWindow. Notice how the color values have been much more spread out compared to the map created when we used the raw data in MALES field.
Now that we have our normalized data ready in MapWindow, we can convert it to KML for viewing in Google Earth.
Click Shape2Earth in the menu and select Export to KML. After Shape2Earth opens, change the Altitude Mode to Relative To Ground, click the By Attribute option, and then select the NormalizeMALE field from the drop down box (keep the 3D source value at Meters).

It is also a good idea to always select a Feature Name Field to name each of your Placemarks in Google Earth (see below).


Finally, convert the data and load it into Google Earth. Compare this map to the one created with non-normalized data (viewable HERE).

This Google Earth map below is much easier to understand and easier to view.


Normalized data is also very useful when not creating height values. The map below was created using the normalized data with the height set to Clamped to Earth, and the centerpoint label option selected.

Shape2Earth: Basic Polygon Height

Shape2Earth offers several options for creating 3D features from GIS data for viewing in Google Earth. This example uses the States shapefile used in the Basic Importing example, and sets unique values for each State shown in the Changing Polygon Colors example.

There are 4 basic options for dealing with height values in Google Earth. KML vector data can be clamped to the ground (all data lays directly on the ground with no height values used), data can be extruded relative to the ground (a height value of 5 meters will be extruded 5 meters above the ground at any given location), or height can have an absolute value (height is the actual height regardless of the underlying terrain; a point with a height of 5010 meters at a location with a height of 5000 meters will be 10 meters above the ground).

The fourth option for height uses the above options by applies to Collada models that can be loaded in Google Earth after Version 4. Models are not available in Shape2Earth 1.0, but may be made available later.

For this very simple example, we will select Relative To Ground as our height mode. When this is selected, the other 3D options in Shape2Earth are made available.

The first choice we will need to make is the unit to be used for height. The options given are Feet or Meters. For this example, we will select Feet.

(Note: All height units in KML are measured in meters. The Feet option in Shape2Earth converts to a metric equivalent for Google Earth)

There are three different ways in Shape2Earth to get height values. You can use an attribute field in the GIS attribute data to use as a height, you can set a single arbitrary height that will be applied to all features, or you can use Z values in the GIS data itself (if they are present).

For this example, we are going to select an attribute field to use for height. The field selected was MALES (see below).

Once we have set all selections for height, we can convert the data to KML and view it in Google Earth (below).


To make a more powerful map, we can associate the color of each State with the height. To do this, we will open the properties of the shapefile (right-click in the MapWindow table of contents and select 'Properties'), and then open the Coloring Scheme Editor (refer to Changing Polygon Colors for more information on changing colors)
Once the Coloring Scheme Editor is open, select STATE_NAME as the Field to color by, and select Continuous Ramp (see below).

Next, you will be given a form to select the beginning and ending color that will be used to color ramp between the high and low value. For this example, I have chosen Red for the end color (high value) and yellow for the start color (low value).

The graphic below shows the color ramp applied to the data as seen in MapWindow.


And the graphic below shows this color scheme with the height values in Google Earth.


The graphic below is the same as above with the opacity level set to 100% (instead of 80% above).



While this map does convey information pretty well, there are a couple of problems with it. For one, California is so high that it becomes difficult to see the other States. In situations like this, it might be a good idea to normalize your GIS data. Fortunately, there are a number of methods for normalizing data that can be done rather easily in MapWindow. (Refer to Normalizing GIS Data For Google Earth to learn how).

Return to Users Manual





Shape2Earth: Changing Polygon Colors

This section will show basic methods for changing the colors of polygons in MapWindow. The colors set in MapWindow are used by Shape2Earth when it renders the Keyhole Markup Language (KML) file for viewing GIS data in Google Earth. Basic information on loading data into MapWindow can be reviewed here.

We will start out with a basic shapefile loaded into MapWindow. When loaded MapWindow sets a default color for the shapefile. In the case below, the default was blue. If you are following along with MapWindow, your color might be different.

(Note: the shapefile used in this exercise is from the MapWindow installation, usually found at C:\Program Files\MapWindow\Sample Projects\United States\Shapefiles\states.shp).




To change the color of the polygons, right-click on the shapefile name in the MapWindow table of contents and select Properties from the menu.



This will open up the MapWindow Legend Editor for the selected shapefile. The Legend Editor presents several options for changing the shapefile symbols. You can change both the Fill Color and the Line Color for the shapefile to get the color scheme you want. You can also set the colors of each individual feature based on a GIS attribute. This will allow you to create highly customizable GIS based maps for displaying in Google Earth.

To set the color of each feature based on a GIS attribute, click on the Coloring Scheme value in the Legend Editor (see above). This will open up the Coloring Scheme Editor (below). The first thing you will need to do is to select the GIS attribute field whose values you would like to use for color coding. In this example, we are going to use the STATE_NAME field to uniquely color code each State.


Once you have selected the field you want to use, you will need to determine how you want to break up the data in that field to be color coded. MapWindow offers 3 options for cartagraphically organizing and displaying data using color.

You can use Continuous Ramp to make a smooth transition from one color to another based on attribute values. Any example of this method is shown HERE.

Equal Breaks allows users to organize data into specific color categories based on their attribute relationships.

Unique Values sets a color for each unique value. This is what we will use for this example.


After you have selected Unique Value, the Coloring Scheme Editor will be populated by the unique values found in the selected attribute field, and will apply a random color to each unique value (see below).


Each individual color can me modified by the user simply by clicking on it. This will open the Color Editor which is used for selecting a cusomized color. In the example below, we are changing the color of the unique value 'Alabama' from Black to Green.

Click the color next to the field you wish to change.

Select a new color or define a custome one.
Select OK to set the new Color
This process will change the colors of the data as seen in MapWindow below. These color schemes are what will be used by Shape2Earth to color code the KML data for viewing in Google Earth.

Thursday, December 28, 2006

Shape2Earth: Creating KML Labels and Points

This section demonstrates some options when dealing with points, either as a point shapefile, or as centerpoints created for polygons. The centerpoint option with polygons creates a point that represents the geometric center of the polygon. These points are stored in a separate folder from the polygon features in the KML. This method was chosen over creating multi-geometries for the polygons and points so that users would have the option to turn of the centerpoint (and labels) if they wish

There are only really two differences that you will see when using points instead of centerpoints. When you load a polygon, you will need to check the Create Centroid box on the Properties tab in shape2earth in order to create the centerpoints (see below).



If you are using a point shapefile, all of the point options are already visible, and uses have the additonal option to use the colors set in MapWindow to color each point (this option is shown in more detail HERE).

To change the icon used for a point, click on the icon button next to the Style label (see above). This will open up a form with a selection of different point symbols to use (see below).


Select the point you would like to use and click OK. This will close the Point Selector, and will change the selected symbol in Shape2Earth.
To change the size of the icon, you can change the number next to the Icon text box to the right of the Style point selection (see below).


You can also change the characteristics of the label that will be seen next to the point. You can change both the size and the color (see below).
If you do not want to see the point, but just the text, then change the number next to the Icon label to zero.
(Note: the text that will be seen next to the point is selected from the Feature Name Field on the GIS Data tab. You can see how to do this at the Basic Importing section, or see a graphic here.

The Create Label Rollover checkbox will open up additional point options. The label rollover is a different icon and label that will be made visible when a user 'hovers' over the point in Google Earth. The options for the label rollover are the same as that for the Style Icon. Though there is one more option to change the color of the icon.

It is often a good idea to make the Label and Icon larger for the rollover. It also works well to change the Icon and Label Color, as we have done below.

The Google Earth KML below shows how the above settings would work when applied to a point shapefile representing cities. Notice the different icon and color when the user hovers over Thousand Oaks.


The Google Earth KML below shows how the above settings would work when applied to a polygon shapefile representing States with the centerpoint option selected. Notice the different icon and color when the user hovers over Iowa.


The options for labels and centerpoints can be adjusted and reapplied until a good color combination and Icon set are found for your particular dataset.

Shape2Earth:Basic Importing 2

This exercise is very similar to the Basic Importing example, but it explores some additional features of Shape2Earth. Refer to THIS POST for information on changing the colors of features based on an attribute field.

Is this example, we have already loaded the states.shp shapefile and have given each state a unique color. Once we have done this, we can launch Shape2Earth.

In the Shape2Earth KML tab, the Layer Name defaults to the name of the shapefile. We can change this name to anything we want (such as the change to "United States" below). We can also change the opacity of the features to any number between 0 and 100 (with 100 being fully opaque and zero being invisible). You can play with this number to see what looks best, but for this example, we will set it to 80%.



We will leave the 3D options as they are so that each State wil lay directly on the surface of Google Earth.

Next, click on the GIS Data tab. Select the STATE_NAME field from the drop-down box next to Feature Name Field. This will be the name of each of our features in Google Earth. Then, click on the Order by Feature Name check box. This will sort all of the features so that they will be seen in alphabetical order in Google Earths table of contents.



Next, we can decide which GIS attributes we would like to see in the KML document in Google Earth. The selected attributes (see checked boxes below) are written into the KML description tag as an HTML table, and are seen in the Google Earth balloons that pop-up when a feature is selected.



Once we have set all of our options, we can either save as KML, or save as KML and immediately load the saved KML file into Google Earth (see graphic below).


When creating polyons, the GIS attribute data that we emedded in the KML can be made visible in a couple of ways. You can click on the feature in the table of contents, you can hold down the Ctrl key and click on the polygon, or you can make a centerpoint label for each polygon that can be clicked on to open the balloon.
The method for creating centerpoints is described HERE, and was used to create the graphic seen below.
Also note that the names of each state have been writtein in alphabetical order, and are listed in that order in the table of contents (see below). This option is very helpful when trying to find a specific feature by name.


This KML file was created using the centerpoint option. This option created a point that acts as a label and a selection point to view the information balloon. This option also let us set our own rollover option. This option lets the user change the icon and label when a viewer hovers over a point (see below).


Finally, we can see the GIS data that we selected in Shape2Earth visible in the information balloon in Google Earth when we click on a point (see below).