Square polygons appear as triangles

Ken Lord kenlord at GMAIL.COM
Fri Feb 25 17:04:51 EST 2005


A true ESRI compliant polygon shapefile must have properly closed
polygons ... the final point must be the same as the starting point.

I looked this info up recently directly in the ESRI shapefile whitepaper.

Since the shapefile format was created by ESRI, If you have software
that reads/writes shapefiles with polygons that are not closed, than
your software is not following the standards.

Cheers,
Ken Lord


On Fri, 25 Feb 2005 16:42:44 -0500, Stephen Woodbridge
<woodbri at swoodbridge.com> wrote:
> OK, I have a question. Does the ESRI spec require polygons to be closed
> or is this just mapserver that requires it? It seems to me that if the
> user says it is a polygon layer, then we should be smart enough to check
> if it is closed and close it if it is not. This would make much more
> sense and make mapserver much more user friendly.
>
> -Steve
>
> Frank Warmerdam wrote:
> > On Fri, 25 Feb 2005 21:54:59 +0100, Roberto Bianconi
> > <roberto.bianconi at gmail.com> wrote:
> >
> >>Hi,
> >>I have a shp file that describes a grid plot. It is made of adjacent
> >>square polygons and when viewed out of Mapserver it is displayed
> >>correctly.
> >>If I try to plot it with Mapserver, with something like:
> >>
> >>    LAYER
> >>       NAME grd
> >>       STATUS DEFAULT
> >>       TYPE POLYGON
> >>       DATA /path_to_data/grd"
> >>       CLASS
> >>          EXPRESSION ([VALUE] > 1.e-5 and [VALUE] <= 1.e-4)
> >>          COLOR   0 151 255
> >>          OUTLINECOLOR 0 0 0
> >>       END
> >>       CLASS
> >>          EXPRESSION ([VALUE] > 1.e-4 and [VALUE] <= 1.e-3)
> >>          COLOR   0 223 255
> >>          OUTLINECOLOR 0 0 0
> >>       END
> >>  END
> >>
> >>I get the square polygons represented as triangles, with a line
> >>connecting the lower right corner to the upper left corner (i.e. the
> >>lower left vertex is not connected). If I plot this layer - as a test
> >>-  as TYPE POINT and add a CLASS vector symbol and size, I can see the
> >>4 corners of each polygon grid, each with the selected symbol.
> >>
> >>Where am I wrong ? Any hint on how to get the correct behaviour?
> >>Thank you.
> >
> >
> > Roberto,
> >
> > My first suspicion is that the polygons in the shapefile are not
> > properly closed.  There should be five vertices for each rectangle
> > as a close rectangle must have matching first and last vertices.
> >
> > However, your description of how it is drawn doesn't quite
> > sound like I would expect.  You could inspect the file with
> > shpdump or ogrinfo to see how many vertices the squares
> > really have.  Lots of sloppy shapefile generating apps fail to
> > close polygons.  Many apps will do it implicitly, but MapServer
> > does not.
> >
> > Running the file through ogr2ogr may fix it up.
> >
> > Best regards,
> > --
> > ---------------------------------------+--------------------------------------
> > I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
> > light and sound - activate the windows | http://pobox.com/~warmerdam
> > and watch the world go round - Rush    | Geospatial Programmer for Rent
> >
>



More information about the mapserver-users mailing list