2

Hello:
I have the following:
1. Shapefile of the world with the boundaries of each country
-- Successfully imported shapefile into PostGIS database
-- Can display map of the world in a browser via Openlayers.

2 A data (CSV) file where each record has
a. birth country,
b. gender,
c. lat and long of the country of birth (which matches the lat & long in the shapefile)

I am trying to figure out the best approach to display a map where each country (based on the CSV data) that has a 100 or more people with a color say red or green....

So my question is:
If I create a separate table with the CSV data, is there a way link this table with the shapefile table to do the above?

OR

Do I need to merge the CSV data into the shapefile table in order to accomplish the above

I am using PostGIS, mapserver and Openlayers

Thanks
Chris

winwaed
  • 7,355
  • 6
  • 30
  • 78
ChrisJ
  • 397
  • 1
  • 11
  • 27

3 Answers3

1

I would import data from CSV file to the same PostGIS database and then create a view on two tables that would have country name and number of people(calculated from data in CSV file).

Then I would create a WMS in Mapserver from this view with SLD where I specify which color every country gets depending on number of people.

igorti
  • 3,718
  • 3
  • 19
  • 29
  • Igorti: I see what you're saying.... It's a static set of data so I can use a table instead of a view.... I have a question about the shape file... I looked at the associated dbf file I don't see a geometry column. So how do I find the geometry for each country? Chris – ChrisJ Nov 21 '10 at 23:22
  • one addition; Don't forget to add an entry to the VIEW in your geometry_columns table: http://postgis.refractions.net/documentation/manual-1.4/ch04.html#id2759271 – milovanderlinden Dec 16 '10 at 07:19
0

You can import a Sharefile into geoserver and geoserver will provide a WMS resource that OpenLayers can read.

I am not too sure about how to integrate CSV data b/c it has been a while. Perhaps you can just make each country have its own DOM id and just alter CSS with different background-color after map is rendered using javascript.

Teddy
  • 17,609
  • 2
  • 27
  • 42
  • Thanks for the suggestion... But I'm using mapserver on this project... Based on another suggestion, I'll import the CSV file as table and get at what I want via a SELECT statement that get data from both tables... Chris – ChrisJ Nov 19 '10 at 13:40
0

@chris the .dbf file should have non-geographic data such as the data about birth country and gender.

Another good example is a Shapefile from US Census Bureau. Typically the dbf file will have Census data / demographic data; but not geographic data.

Teddy
  • 17,609
  • 2
  • 27
  • 42