[Mapserver-users] Coloring shapefile layer according to DB query

Lowell Filak lfilak at medinaco.org
Fri Oct 10 15:58:18 EDT 2003


There are probably 100 more ways to do what your asking, but here is one
thought...
You can use MapScript to join data from the database to the selected
shapes on the fly or once on the entire data set.
Adding fields to the shapefile really means adding fields to the dbf
file and populating that field.
Because your not adding records you never touch the shp file and really
only need XBase to populate the dbf field unless your operating on the
fly against a set of shapes currently displayed on the map - then you
need MapScript.
The fatstest method would be to "preprocess everything possible" - EM,
but that may not be practical if your data changes real-time.
If your data is loaded on a daily, weekly, etc. basis preprocessing will
save time rendering the map.

Lowell

The following message was sent by "Matthew Haines"
<mhaines94108 at hotmail.com> on Fri, 10 Oct 2003 15:20:18 -0400.

> 
> I have a shapefile for the tax lots in Manhattan (New York City) and I
have 
> a lot of information about the individual tax lots in a MySQL
database.  I 
> would like to generate maps where I color the tax lots according to
the data 
> in the MySQL database.
> 
> Just as an example, I have a table that tells me how many residential
units 
> have been built on a particular tax lot.  I might like to color the
map by 
> population density so that single family dwellings are light red, 2-4
family 
> buildings are medium red, and 5+ family apartment buildings are dark red.
> 
> Is there any way to do this without loading the shapefile polygons
into the 
> database?  I've had several thoughts, but they seem impractical ...
> 
> => I could use Perl MapScript to write a program that would scan the
entire 
> database table and assign tax lots to different layers ... but there are 
> 100,000 tax lots in Manhattan and that might take a long time.
> 
> => I could try to get put the data into the shapefile ... but how?  I
don't 
> have any commercial mapping software for working with shapefiles.  Is
there 
> a utility to do this?  Also that makes my data hard to update.
> 
> => Is there a MAP file command to load data from a database and
somehow join 
> it to the shapefile on the fly so I can define layers based on it?
> 
> I'm hesitant to mess with MySQL, if only for fear of breaking my existing 
> applications.  The documentation indicates that the MySQL connector is 
> buggy.
> 
> What's the best way to go about this?  Do I have to install PostgreSQL?
> 
> Pointers much appreciated,
> 
> Matthew
> 
> Matthew
> 
> _________________________________________________________________
> Share your photos without swamping your Inbox.  Get Hotmail Extra Storage 
> today! http://join.msn.com/?PAGE=features/es
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list