Home | Product information | Help documentation | Downloads | Contact us   


  gSpatial.net Help documentation: Linking external data 
Although it might be amusing for a while to import other people's shapefile layers to Google Earth, you probably want to link some of your own data to a shapefile. For example, you may be in real estate sales, and you would like to position the properties you have on a map, and attach your own data such as the listing number and sales price of the property to each address on the map. You may have the sales data captured in for example a Microsoft Excel spreadsheet. The data you'd like to link could also reside in some kind of corporate database, such as in Microsoft Access, Oracle or SQL/Server.

In order for the gSpatial Toolbar to link your data, some rules have to be observed. As discussed in the section on shapefiles, each shapefile has a DBase III table associated with it which contains attribute data. Each row or record in the DBase table corresponds to one geographical feature. As an example, if your shapefile contains the 50 US states, there will be 50 rows in the DBase table, each containing for example one state's name. 

Each row or record, in turn, is divided into fields or columns. In our example above, the columns for US States could be STATE_NAME and CAPITAL_CITY. These correspond closely to the columns in an Excel spreadsheet. gSpatial Toolbar automatically reads the DBase file and will display these column names to you. You can also, however, open the dBase file directly using a third party program like Microsoft Excel. 

For you to link your data to the DBase table, you have to use one of the columns in the DBase file as well as one of your own columns as the link column. For example: you may have sales figures per US state in an Excel spreadsheet called "sales.xls". The worksheet containing sales figures could be called "statesales", and the column in the worksheet that contains the state name could be called "state". You would then use "state_name" from the DBase file as one link column, and "state" in your spreadsheet as the other link column.

The problem in this approach is of course that gSpatial may not always find a matching record. If one of the two state names is for example misspelt, the particular state won't be drawn correctly. 

A shapefile's DBase table is special in another way: the order of the records in the DBase table is the same as the order of the geographical features in the .shp file that contains the binary coordinates. If New York State is the first geographical feature in the .SHP file, the first record in the DBase table will be New York. You can use the same convention, and depend on the order of the records in your own data, but this is often difficult to to unless you have a commercial GIS software package. If you look at the screen below, you are allowed to use this method of linking tables.

When you attach a shapefile, you can choose the attribute table type in the layer dialog box. When you click on OK in the layer dialog box, the screen below appears. If you are using an Excel spreadsheet, you have to pick an Excel spreadsheet by clicking on the button, and then also enter the worksheet name in the field provided. 

Before you can select the link field, you have to click on the Test connection button at least once, so that gSpatial Toolbar can check that the ODBC datasource or Excel file and worksheet are valid. If it is not valid, you won't be able to set up a linkage. If it is valid, you will be able to choose the link columns in both the shapefile's DBase table (left-hand side), as well as the column in your linked table (right-hand side).

 

If you are using an ODBC data source, the data source has to exist on your system first. Each ODBC data source has a name and typically connects to an external database such as a SQL/Server database. ODBC data sources are set up using the Control Panel. Please refer to your Windows system documentation for more information on ODBC data sources. The database table or view name has to be entered in the Table / Worksheet name field below in this case.

 


Home Contact us (c)2007 gSpatial.net Page last updated: 20 December 2007