Creating Political Maps, Part 2

Over the past several months, I have been running a website, http://localpols.fordean.net which lists various progressive candidates. As the list has grown, I’ve been looking for ways to improve the navigation of the site. I set up a simple clickable map so you could click on a state to find specific candidates. I have expanded this to be able to click on the district level, for example, http://localpols.fordean.net/CTStateSenate
I wrote about my initial attempts at this here. As I mentioned then, people had suggested that I check out Mapserver. In theory, it is supposed to work with IIS. However, when I tried using it with IIS on my server, no matter what I did, I kept getting, “CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:”
This is an error message that has often been reported for various systems, but I have yet to find a way to get around this error.
I am not all that proficient at configuring my Apache servers, so I may not have set up MapServer as optimally as possible, but my test Mapserver is now up at http://ahynes1.homeip.net:7778/cgi-bin/mapserv.
My first pass was to try and take some of the shapefiles that I’ve gathered and put them up on the MapServer. The first problem I ran into in doing this was trying to find the appropriate ‘extent’. In the end, I used ArcGIS to check the properties of the themes and that has worked pretty well. Does anyone know how to find the proper extent of a shapefile using open tools?
I gathered redistricting shapefiles for several states and have put them all up on my Mapserver. A second problem that I’ve run into is that different shapefiles use different formats for the extents. Some of them are simple lat/long. Others seem to be lat/long times 10,000, still others on some other scale. Given this, I don’t think I can easily mix and match state shapefiles. Does anyone know how to change the scale that is being used, so, for example, they could all be simple lat/long?
My next step was to start playing with MapClient. The simple MapClient stuff seemed to work pretty well. I cut and pasted parts from their examples and set up my first little version, http://ahynes1.homeip.net:7778/mapclient/examples/test1.html This displays the different maps for the states that I’ve retrieved data.
When I set this up, I used server frames. I didn’t want a separate floating window created by Javascript. Unfortunately, when I tried porting that code into Drupal, I started getting errors. So, I’m on hold with the Drupal porting for a little while.
I then tried some other software. PHP MapScript looks really promising. I downloaded a binary version for Windows. Unfortunately, the MapScript windows binary comes with a lot of junk, which I didn’t want. It would be nice if they had a stripped down version. I’ve installed it, but when I try to run it, I get Unknown(): Unable to load dynamic library C:\PHP\extensions\php_mapscript_42.dll – Access is denied Anyone have any ideas about how to get around that one?
So, I’ve gone back to working with the MapServer MAP definitions. I’m sure that I could write much better map files. Mostly, I’ve cut and pasted from other map files, and slowly been learning how to get them to be a little nicer. My latest version gives me the ability to select different voting districts. For example, take a look at http://ahynes1.homeip.net:7778/cgi-bin/mapserv.exe?map=c:\mapserver\maps\wahoused.map&district=18,20,28,38,39,44. It highlights districts 18, 20, 28, 38, 39, and 44. I’ve also gotten my zooming working with http://ahynes1.homeip.net:7778/cgi-bin/mapserv.exe?map=c:\mapserver\maps\vasenated.map&district=12&mapext=-77.979604+37.376572+-77.224005+37.933055
I’ve used a few maps like this, particularly for Virginia and Washington, to enhance Local Pols
So, with this, I am getting closer. I still have a bunch of questions. They boil down to:
- How do I get MapServer to work with IIS?
- How do I get MapScript working with IIS?
- How do I incorporate this into Drupal (e.g. getting MapClient or MapScript to work)
- How do I find extents automatically without using ArcView?
- Is there a nice way to change the scaling?
- How do you make a section clickable? (I’m currently creating PNGs that I add to Drupal as a client side clickable map)
- How do you set up a floating tag? (So, when the mouse hovers over a location, it says what the location is. I can do this with clickable maps, and have at Local Pols)
- How do you make different sections different colors based on specific needs? (I’m doing it with a kludged up map file. I’m sure there must be a better way
- How do I add a symbol, or many symbols, programmatically?
Any comments are greatly appreciated..
change the scaling
Submitted by Anonymous on Tue, 10/05/2004 - 15:07. span>I think what you mean by "change the scaling" is that you need all your data to be in the same coordinate system, yes? the gis world would call this using a standard map projection. to do this you would have to find out the native projection of each of your source layers, and the re-project each of them to a common projection like lat/long. it's basically alot of math that you need a program to crunch through. if you do this in advance of serving your layers on the web (using an external GIS program like Arcview 3.x), them you can serve all the layers together quite easily in somthing like UMN Mapserver. In fact Mapserver can do reprojections on the fly (while serving) but it will cause all your maps to be slower to appear, so pre-processing is worth the effort. the hardest part might be finding out all your source projections as if you've been collecting data from all over, it might be hard to track back. different projections can look quite different (both in map shape and in text definition). just so you know what you are looking for here are a few example of projections that i have seen in oregon:
projection utm
datum nad27
units meters
zone 10
projection lambert
datum NAD83
units 3.28084
parameters
43 0 0.000
45 30 0.000
-120 30 0.00
41 45 0.000
400000
0.00000
projection albers
units meters
datum nad83
parameters
29.500000
45.500000
-96.000000
23.000000
0.0
0.0
easier/better map files
Submitted by Anonymous on Tue, 10/05/2004 - 15:15. span>to make writing customizing mapfiles easier try going to http://www.maptools.org and download "MapLab".
Actually, to make your whole Mapserver life easier, download the MS4W version of Mapserver at that same website, install it, and then install the "MapLab for MS4W" version. This installs a full apache/php/mapserver/maplab combo which is all in one root directory, and functions right out of the box (once you turn on the apache). The MapLab allows you to browse you data, color it the way you want etc, and it writes the mapfile for you. I can even build a browsable map website (complete with zoom /pan tools etc.) pretty cool. Also, if you decide you do not want any of it anymore, it is easy to unistall, since everything is in one root.