[mapserver-users] shp/dbf file's name

Johan Forsman Johan.Forsman at LA.GOV
Fri Aug 20 12:21:34 EDT 2010


If I understand your question correctly you are attempting to do something similar to what I have where I am coloring polygons in a shapefile based on a numeric value stored in a frequently-updated CSV-file. As long as you have a field in both files that you can join on it ought to work.

I used the OGR connection type as briefly discussed in a previous post,
http://www.mail-archive.com/mapserver-users@lists.umn.edu/msg13477.html

This is the type of syntax you appear to need:

CONNECTIONTYPE OGR
CONNECTION "/var/www/demodata/a.shp" //path to the shapefile
DATA "SELECT a.ID, b.NAME FROM a LEFT JOIN '/var/www/demodata/b.dbf'.b ON a.ID=b.ID"

In my case the LAYER section in the mapfile looks like this, where "FIPS" is the field I join the files on.

LAYER
  NAME 'parishes_on_boiladv'
  CONNECTIONTYPE OGR
  CONNECTION "myshapefile.shp"
  DATA "SELECT * FROM myshapefile LEFT JOIN 'full_path_to_file_named_bwa.csv'.bwa ON myshapefile.FIPS = bwa.FIPS"
  STATUS on
  TYPE polygon
  CLASSITEM "PercentageOut"
  CLASS
    EXPRESSION ([PercentageOut] > 0 AND [PercentageOut] <= 10)
    NAME "0 - 10%"
    STYLE
      COLOR 56 168 0
    END
  END #class
(continues with several more classes).

Hope that helps,
Johan.

> -----Original Message-----
> From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-
> bounces at lists.osgeo.org] On Behalf Of Clément MONIER
> Sent: Friday, August 20, 2010 9:06 AM
> To: P Kishor
> Cc: mapserver-users at lists.osgeo.org
> Subject: RE: [mapserver-users] shp/dbf file's name
> 
> > How would MapServer know which row in your external dbf file matches
> which row (aka feature) in your ShapeFile?
> > What if the external dbf file doesn't have the same number of rows as
> the number of features in your ShapeFile?
> 
> not really a problem as I'm able to generate dbf files with records in
> exactly same number and order as inside shp.
> 
> 
> > The dbf format is pretty primitive. Your best bet is to actually add to
> your ShapeFile the data that is now in your external file. > It will also
> likely be faster.
> 
> That's precisely what I can't do any more,
> since I'd like to join various kinds of time-related attributes on very
> static geometries.
> 
> -----Message d'origine-----
> De : P Kishor [mailto:punk.kish at gmail.com]
> Envoyé : vendredi 20 août 2010 15:42
> À : Clément MONIER
> Cc : mapserver-users at lists.osgeo.org
> Objet : Re: [mapserver-users] shp/dbf file's name
> 
> On Fri, Aug 20, 2010 at 8:22 AM, Clément MONIER
> <Clement.MONIER at v-trafic.com> wrote:
> > Hi,
> >
> >
> >
> > I would like to know if it's possible to draw geometries from a shp file
> >
> > according to attributes from a dbf
> >
> > but with 2 files named differently.
> >
> >
> >
> > For instance :
> >
> >
> >
> > LAYER
> >
> >   NAME layer1
> >
> >   DATA shapefile1.shp
> >
> >   CLASS
> >
> >     EXPRESSION ([col1]=1)
> >
> >     STYLE
> >
> >     END
> >
> >   END
> >
> > END
> >
> >
> >
> > Where col1 is a field inside a file storing attributes (dbf/csv/txt/.)
> but
> > not named shapefile1.dbf
> >
> 
> 
> How would MapServer know which row in your external dbf file matches
> which row (aka feature) in your ShapeFile? What if the external dbf
> file doesn't have the same number of rows as the number of features in
> your ShapeFile?
> 
> The dbf format is pretty primitive. Your best bet is to actually add
> to your ShapeFile the data that is now in your external file. It will
> also likely be faster.
> 
> 
> >
> >
> > I already tried to use the JOIN option but I think it's inappropriate
> for my
> > purpose
> >
> > since "You cannot use joins to affect the look of a map"
> > (http://mapserver.org/mapfile/join.html)
> >
> >
> >
> > Thanks for your help !
> >
> >
> >
> > Clément
> >
> >
> >
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >
> >
> 
> 
> 
> --
> Puneet Kishor http://www.punkish.org
> Carbon Model http://carbonmodel.org
> Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
> Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
> Nelson Institute, UW-Madison http://www.nelson.wisc.edu
> -----------------------------------------------------------------------
> Assertions are politics; backing up assertions with evidence is science
> =======================================================================
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the mapserver-users mailing list