[Mapserver-users] Coloring shapefile layer according to DBquery

Steve Lime steve.lime at dnr.state.mn.us
Fri Oct 10 14:14:54 PDT 2003


A DBF file is part of a shapefile- the part that holds the attribute
information. I'm not sure
whether PostGIS or local shapefiles are faster, my guess is the latter
but not overwhelmingly
so.

Switching entirely to Postgres is not a downgrade, rather an upgrade
(you wouldn't
need the "build the shapefile" step. However, you'd have to move away
from MySQL or
at least run both in parallel and try and keep them in sync. Worse than
the shapefile 
option in my opinion.

Building custom data isn't sexy but it's often a reality that nets you
great performance.

Steve

>>> "Matthew Haines" <mhaines94108 at hotmail.com> 10/10/2003 3:50:06 PM
>>>

So which is faster, reading the shapefiles from the DBF file or
(assuming I 
move to PostgreSQL) reading them from a PostgreSQL database?

Reading between the lines I'm guessing that (1) the .DBF files are an 
indexed database file, (2) mapserver has an XBASE database engine built
in, 
and (3) XBASE is the fastest database for this kind of application, and

therefore (4) switching to MySQL or PostgreSQL would be a form of 
downgrading.

Precompiling everything isn't quite as sexy as doing doing it on the
fly, 
but speed is very important, and not having to add PostegreSQL to my
server 
and migrate everything from MySQL is also good.

Matthew

----Original Message Follows----
From: "Steve Lime" <steve.lime at dnr.state.mn.us>
To: <mhaines94108 at hotmail.com>,<mapserver-users at lists.gis.umn.edu>
Subject: Re: [Mapserver-users] Coloring shapefile layer according to
DBquery
Date: Fri, 10 Oct 2003 15:11:54 -0500

An increasingly popular topic these days.

There is no way with CGI MapServer to link the two for map creation.
Your best bet
would be to create a custom shapefile that combines the base shapefile
and the MySQL
database. You can use MapScript and the DBD drivers for MySQL and
XBase
to do this
pretty easily. The psuedo code is something like:

- copy the base shapefile to a new file
- open the new shapefile DBF file
- add the new columns
- open the connection to MySQL
- for each shape select the corresponding MySQL row
   - copy the content from MySQL to the DBF file
- close everything

Really shouldn't be more that 20 lines.

If done properly you could run this script every so often to sync the
2
datasets using cron. The advantage of this approach is that it gives
you a dataset
optimized for map making. The real time joins are certainly doable but
would absolutely
kill performance- that's why they're not supported.

If your MySQL data is not changing every few seconds then this
approach
should work
quite well. Postgres/PostGIS is of no help unless you want to move
everything into it and
not use MySQL.

Steve

Stephen Lime
Data & Applications Manager

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

 >>> "Matthew Haines" <mhaines94108 at hotmail.com> 10/10/2003 2:20:18 PM
 >>>

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 

_________________________________________________________________
Add MSN 8 Internet Software to your existing Internet access and enjoy

patented spam protection and more.  Sign up now!   
http://join.msn.com/?page=dept/byoa 




More information about the MapServer-users mailing list