[gdal-dev] Shapefiles and z dimensions
Even Rouault
even.rouault at spatialys.com
Sat Dec 9 06:58:01 PST 2017
Nyall,
As underlined by Alvaro and Ari, the format doesn't distinguish PointZ and PointZM in the
header.
GDAL has a logic to look by default at the first geometry
(ADJUST_GEOM_TYPE=FIRST_SHAPE open option) and see if it has a non nodata M value, if
so it exposes PointZM, otherwise PointZ
But for an empty file, there's no way to really know the intent.
We could potentially use a trick if we really wanted to distinguish in the case of an empty
layer. In the shape header, there's an array with min and max values of X, Y, Z and M.
Currently we always write Mmin = Mmax = 0, whereas the shapefile specification
"""Mmin and Mmax can contain "no data" values (see Numeric Types on page 2) for shapefiles
of measured shape types that contain no measures."""
An the nodata value is "Any floating point number smaller than –10e38"
So we could potentially use a nodata value for PointZ and another one for PointZM.
But the issue with layer geometry type is more general than that. It is really dependant on
the formats.
* For example in GeoPackage, the gpkg_geometry_columns which can be used to get the
layer geometry type has columns:
- z: 0: z values prohibited; 1: z values mandatory; 2: z values optional
- m: 0:m values prohibited; 1: m values mandatory; 2: m values optional
* In PostGIS, when a table has a Z, M or ZM constraint, it must be strictly
respected by each feature geometry (mandatory case of geopackage). This is in line with
OGC Simple Feature Access - Part 2: SQL
* In shapefile, you have that PointZ / PointZM equivalence
As a result of those variations, the OGR abstraction is rather loose on the exact semantics of
the geometry type. It is close to the the optional possibility of GeoPackage.
Even
> Hi all,
>
> I'm trying to track down some odd behaviour in QGIS, and determine
> whether this is a qgis bug, gdal bug, or shapefile limitation.
>
> If I create a new shapefile layer using GDALDatasetCreateLayer, with a
> geometry type of wkbPoint25D (actually any of the 25D) types, then the
> resultant layer ALWAYS has an M dimension present as well (i.e.
> ogrinfo reports PointZM type).
>
> Is this expected behaviour for shapefiles?
>
> Nyall
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20171209/5bea8809/attachment.html>
More information about the gdal-dev
mailing list