making efficient map layers

Ed McNierney ed at TOPOZONE.COM
Wed Mar 23 21:43:23 EST 2005


Mark -

I'll elbow my way in here between Frank and Steve to comment on feature
selection in shapefiles.  Shapefiles do not support attribute indexes,
so class selection with EXPRESSION statements produces simple
brute-force scans through all records in the file.  You can think of
shapefiles quite literally as database tables without indexes (for
attributes, not spatially).

If you have a shapefile with 1,000 objects, and your expression selects
20 of them, you will read, scan, and discard 9,980 objects from that
file.  If you extract those 20 into a separate file, you will read,
scan, and use 20 objects.  This is somewhere around 50 times less work
<g>.

The second "rule" I suggested earlier is important to keep in mind - if
you're going to open a shapefile, use all (or most) of the objects in
it.  There are two reasons you would not want to use an object: (a) it's
out of the spatial extent of the requested map, and (b) it's not
something you're choosing to render on this map.  (a) is addressed by
spatial organization and TILEINDEX creation, and (b) is addressed by
attribute selection and the division of data into separate shapefiles.

        - Ed

Ed McNierney
President and Chief Mapmaker
TopoZone.com / Maps a la carte, Inc.
73 Princeton Street, Suite 305
North Chelmsford, MA  01863
Phone: +1 (978) 251-4242
Fax: +1 (978) 251-1396
ed at topozone.com 

-----Original Message-----
From: UMN MapServer Users List [mailto:MAPSERVER-USERS at LISTS.UMN.EDU] On
Behalf Of Mark Dieterich
Sent: Wednesday, March 23, 2005 8:54 PM
To: MAPSERVER-USERS at LISTS.UMN.EDU
Subject: Re: [UMN_MAPSERVER-USERS] making efficient map layers

Steve,

I'm really impressed with the maps on the imaptools site, hope you don't
mind a few prodding questions from a mapserver newbie...

- Does your site actually use some form of generalized layer when zoomed
out?  If so, can you tell me at what point you switch from generalized
maps to shapefiles, it seems really seemless.

- How do you go about changing the width of the different types of
roads?  I assume each class of road is in a different layer and you
somehow manipulate the line width?

- Is there any speed reason to split types of roads, based on the CFCC
type, into different shapefiles or is it just as good to use shp2tile
and then a tileindex?  On a side not, is it possible to throw a wildcard
at ogr2ogr, where by you can specify something likek ogr2ogr dst.shp
src.shp -where CFCC=A1*?  I couldn't figure out if it could take
wildcards or not.  I suppose you could go through and run it for each
A1* type and append it to the shapefile, but this could be a long
process.

I'm working on familiarizing myself with the National Map offerings and
will probably have some more questions for you.

Thanks!

Mark



More information about the mapserver-users mailing list