Ticket #2124 (closed defect: invalid)
Handling of Shapefile Z and M data in shapelib is incorrect
|Reported by:||odegaard||Owned by:||warmerdam|
Description (last modified by warmerdam) (diff)
I discovered a bug in shapelib and how it handles Z and M data. What I did was converting a Polygon shapefile to PolygonZ using:
OGR2OGR.exe -f "ESRI Shapefile" countriesZ.shp countries.shp -lco SHPT=PolygonZ
At the shapefile page, there is this warning: "Shapefiles with measure values are not supported". The thing is that you cannot create a shapefile with Z values without also having measure values. Its either XY, XYM or XYZM (see the spec). I confirmed this with files created using ArcCatalog?, and sure enough that's how it is (In ArcCatalog? you can choose to only have Z values in the file, but it really creates a Z+M file).
The problem is that the shapetype header is set to 15 (=PolygonZ*) so a shapefile reader will think there are both Z and M values in the file. Shapereaders that ignores Z and M doesn't have a problem, but if they are read, they are either incorrect or will risk getting a EOF exception.
*The same thing of course goes for points and polylines.
Technically what OGR really creates with the above command is PolygonM, but with an incorrect shapetype value. So the quickest fix would be to change the shapetype to 25 (generally add 10) and change the warning to "Shapefiles with Z values are not supported" (although adding support for both Z and M would of course be the best, and still fairly straighforward).