This project has moved and is read-only. For the latest updates, please go here.

GradientTheme using data from two different tables

Topics: General Topics
Aug 14, 2006 at 12:49 AM

I am trying to produce a demographic map displaying data such as population,race,income,etc using SharpMap.

I am using a United States Census Tract .shp files as my datasource. The .dbf files associated with the .shp files contain a tract number associated with various census areas.

The data containing the actual numerical demographic information is stored in a seperate sql server database file. The database file's also contain the tract numbers, so a relationship can be established between the two differnent data table ( .dbf and sql server table )

I understand how to create a relationship between the two tables using datarelation in .Net.

I am unsure how to implent the combined dataset into the Gradient Theme or Custom Theme Class. I have explored the examples for gradient and bin theme and understand the code. Yet i am unsure of how to associate a datarelation with the shp file in the code.

Do i have to modify the Sharpmap.Data.Providers.Shapfile.cs ( Public class shapefile)

Example of Table Structures ( Using Tract as matching fields )

.dbf Table sql server table

Tract Tract Population
----- ----- ----------
9800 <----------> 9800 34000
9801 9801 34500
9802 9802 45000

Any ideas how to proceed with my problem would be greatly appreciated!!

Thank you, and great work with the project.

Jim M

Aug 14, 2006 at 4:59 PM
Why not move the geometry to the SQL table instead?
The MsSql Provider class has a method for uploading a datasource to a table in the SQL database. From there you can just create a view that links the tables, and use that as your datasource (and from my experience it's even faster than ShapeFiles!)
Aug 15, 2006 at 3:44 AM
Moving that data would work, but i have 1000's of .shp files. It would be very time consuming.

Data consists of the following:

.shp file ( county demographic tracts )
.dbf ( Table containing Tracts Numbers)

.mdf file ( contains all demographic information for county .shp files also contains Tract Numbers)

Both the .dbf and .mdf tables contain identical tract numbers to create a relationship.

Can i somehow create a Feature table collection ( Creating a datarelation between the two tables )

I have examined your Bin.cs example. Would it be possible to use the featuredatarow class or feature table collection class to create a relationship between the two tables .dbf and .mdf using the tract numbers as common relationship.

Any of suggestions would be greatly apprieciated!

Thank You


Aug 15, 2006 at 8:50 AM
You could probably do a look-up per row, but I don't think it would be very fast.

Regarding your 1000s of shapefiles, it wouldn't take many minutes to create a script that loops all the shapes in a directory and loads them into the database.

Another approach would be to export your data to 1000s of DBF files instead, but that would probably be harder to do.

To be honest it sounds more to me that your problem is a bad data structure.