MCPcopy Create free account
hub / github.com/PDAL/PDAL / open

Method open

pdal/private/gdal/Raster.cpp:232–329  ·  view source on GitHub ↗

Open a raster destined for output. \param width Raster width. \param height Raster height. \param numBands Number of bands in the raster. \param type Datatype of the raster. \param noData Nodata value for "empty" cells. \param options A list of option strings that are passed to the GDAL driver. */

Source from the content-addressed store, hash-verified

230 \param options A list of option strings that are passed to the GDAL driver.
231*/
232GDALError Raster::open(int width, int height, int numBands,
233 Dimension::Type type, double noData, StringList options)
234{
235 if (m_drivername.empty())
236 m_drivername = "GTiff";
237
238 m_width = width;
239 m_height = height;
240 m_numBands = numBands;
241 m_bandType = type;
242 m_dstNoData = noData;
243
244 if (!GDALInvGeoTransform(m_forwardTransform.data(),
245 m_inverseTransform.data()))
246 {
247 m_errorMsg = "Geotransform for raster '" + m_filename + "' not "
248 "invertible";
249 return GDALError::NotInvertible;
250 }
251
252 registerDrivers();
253 GDALDriver *driver = GetGDALDriverManager()->GetDriverByName(
254 m_drivername.data());
255 if (!driver)
256 {
257 m_errorMsg = "Driver '" + m_drivername + "' not found.";
258 return GDALError::DriverNotFound;
259 }
260
261 std::string item;
262 const char *itemp = driver->GetMetadataItem(GDAL_DCAP_CREATE);
263 if (itemp)
264 item = itemp;
265 if (item != "YES")
266 {
267 m_errorMsg = "Requested driver '" + m_drivername + "' does not "
268 "support file creation.";
269 return GDALError::InvalidDriver;
270 }
271
272 GDALError error = validateType(type, driver);
273 if (error != GDALError::None)
274 return error;
275
276 std::vector<const char *> opts;
277 for (size_t i = 0; i < options.size(); ++i)
278 {
279 if (options[i].find("INTERLEAVE") == 0)
280 {
281 m_errorMsg = "INTERLEAVE GDAL driver option not supported.";
282 return GDALError::InvalidOption;
283 }
284 opts.push_back(options[i].data());
285 }
286 opts.push_back("INTERLEAVE=BAND");
287 opts.push_back(NULL);
288
289 m_ds = driver->Create(m_filename.data(), m_width, m_height, m_numBands,

Callers 15

dumpMethod · 0.45
processArgsMethod · 0.45
unwrapMethod · 0.45
doneMethod · 0.45
doneFileMethod · 0.45
readyFileMethod · 0.45
initializeMethod · 0.45
readyMethod · 0.45
readDimMajorMethod · 0.45
OutputMethod · 0.45
runGdalWriterFunction · 0.45
runGdalWriter2Function · 0.45

Calls 8

registerDriversFunction · 0.85
toGdalTypeFunction · 0.85
getWKTMethod · 0.80
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
validMethod · 0.45

Tested by 4

runGdalWriterFunction · 0.36
runGdalWriter2Function · 0.36
TESTFunction · 0.36
TESTFunction · 0.36