Skip to content

Commit

Permalink
support selection of dimension for writers.gdal #1325
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Oct 19, 2016
1 parent cd95f6f commit e6baa96
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
13 changes: 6 additions & 7 deletions doc/stages/writers.gdal.rst
Expand Up @@ -20,13 +20,10 @@ potentially contributes to the raster's value.
it is possible that some points will not be considered at all, including
those that may be within the bounds of the raster cell.

The GDAL writer creates rasters using the data in the 'Z' dimension of the
points. In a :ref:`pipeline_command` one can precede the GDAL writer with
the ferry filter (:ref:`filters.ferry`) in order to copy data from some
other dimension to the 'Z' dimension if desired.

The writer will creates up to six rasters based on different statistics in
the output dataset. The order of the layers in the dataset is as follows:
The GDAL writer creates rasters using the data specified in the ``dimension``
option (defaults to `Z`).The writer will creates up to six rasters based on
different statistics in the output dataset. The order of the layers in the
dataset is as follows:

min
Give the cell the minimum value of all points within the given radius.
Expand Down Expand Up @@ -125,3 +122,5 @@ window_size
the fallback interpolation method. See the stage description for more
information. [Default: 0]

dimension
A dimension name to use for the interpolation. [Default: ``Z``]
7 changes: 6 additions & 1 deletion io/gdal/GDALWriter.cpp
Expand Up @@ -71,6 +71,7 @@ void GDALWriter::addArgs(ProgramArgs& args)
args.add("window_size", "Cell distance for fallback interpolation",
m_windowSize);
args.add("nodata", "No data value", m_noData, -9999.0);
args.add("dimension", "Dimension to use", m_interpDimString, "Z");
}


Expand Down Expand Up @@ -105,6 +106,10 @@ void GDALWriter::initialize()
}

gdal::registerDrivers();

m_interpDim = Dimension::id(m_interpDimString);
if (m_interpDim == Dimension::Id::Unknown)
throw pdal_error("Dimension name is not known!");
}

void GDALWriter::ready(PointTableRef table)
Expand Down Expand Up @@ -134,7 +139,7 @@ void GDALWriter::write(const PointViewPtr view)
m_bounds.minx;
double y = view->getFieldAs<double>(Dimension::Id::Y, idx) -
m_bounds.miny;
double z = view->getFieldAs<double>(Dimension::Id::Z, idx);
double z = view->getFieldAs<double>(m_interpDim, idx);

m_grid->addPoint(x, y, z);
}
Expand Down
3 changes: 3 additions & 0 deletions io/gdal/GDALWriter.hpp
Expand Up @@ -73,6 +73,9 @@ class PDAL_DLL GDALWriter : public Writer
int m_outputTypes;
GDALGridPtr m_grid;
double m_noData;
Dimension::Id m_interpDim;
std::string m_interpDimString;

};

}

0 comments on commit e6baa96

Please sign in to comment.