Can a shapefile store several geometry types? Yes or no? Why or why not?
-
5Welcome to gis.stackexchange. A good question is expected to show proof of basic research effort. Questions which look like basic course homework are generally not well received.– underdarkCommented Mar 6, 2014 at 17:41
-
2For part of the answer see: gis.stackexchange.com/questions/74627/…– underdarkCommented Mar 6, 2014 at 17:42
-
1Too vague for this topic– PROBERTCommented Mar 6, 2014 at 18:04
-
2Also addressed by gis.stackexchange.com/questions/71419/…– VinceCommented Mar 6, 2014 at 22:56
1 Answer
Wikipedia says yes and no (but mostly no):
Mixing shape types
Because the shape type precedes each record, a shape file is physically capable of storing a mixture of different shape types. However, the specification states, "All the non-Null shapes in a shapefile are required to be of the same shape type." Therefore this ability to mix shape types must be limited to interspersing null shapes with the single shape type declared in the file's header. A shape file must not contain both polyline and polygon data, for example, and the descriptions for a well (point), a river (polyline), and a lake (polygon) would be stored in three separate files.
The ESRI Shapefile Technical Description confirms this:
All the non-Null shapes in a shapefile are required to be of the same shape type. The values for shape type are as follows:
Value Shape Type 0 Null Shape 1 Point 3 PolyLine 5 Polygon 8 MultiPoint 11 PointZ 13 PolyLineZ 15 PolygonZ 18 MultiPointZ 21 PointM 23 PolyLineM 25 PolygonM 28 MultiPointM 31 MultiPatch
-
2A shapefile can store mixed geometry types like POLYGON and MULTIPOLYGON, or LINESTRING and MULTILINESTRING, but not the ones in your example like POLYGON vs LINESTRING vs POINT.– SaultDonCommented Mar 6, 2014 at 18:29
-
3@SaultDon those are WKT representations, in the shapefile format they are the same, only differentiated by the number of parts (single-part vs. multi-part). The exception is Point vs. Multipoint which are different geometry types and cannot be mixed: esri.com/library/whitepapers/pdfs/shapefile.pdf– blah238Commented Mar 6, 2014 at 18:36
-
1Multipoint shapefiles can have features with one vertex, but they still must be represented as a MultiPoint record, with an envelope (minx=maxx, miny=maxy) and a vertex count. They index differently (and less efficiently) than point shapefiles, though, so you shouldn't use Multipoint unless the table will need to store them.– VinceCommented Mar 6, 2014 at 22:50