Skip to content

6b Prepare your data

Oliver Heilig edited this page Mar 11, 2020 · 12 revisions

Now we are going to work with real-world data. For the tutorial i'm using some free world country boundaries together with population and area to create a thematic map.

A good commercial resource for spatial data is DDS Digital Data Services. They provide both geography and the corresponding socio-economic data. But you could also use the geometries and link it to your own data. You can download some test data here.

To visualize the spatial data, we have to import it into our database. The de-facto standard for exchanging geographic data are Shape Files (.shp). First we have to find a way to import them into our database. It is also possible to work on shape files directly, see https://github.com/ptv-logistics/SharpMap.Widgets, but there are many advantages having the geo data right in our database.

So i've written a little console application that reads the shape file and writes the data into SpatialLite. I'm using SharpMap as 3rd-party library here, because it can handle shape files. After the import i can directly work with the spatial database via ADO.NET, so i don't need SharpMap there. (ToDo: explain SpatialLite initialization).

The code creates a db.sqlite database. We can open it any SQLite tool and do qeries on the data.

For our program we just copy it to our web probject.