mapnikOTBClasses.cxx 1.47 KB
Newer Older
1
#include "otbVectorDataFileReader.h"
Emmanuel Christophe's avatar
Emmanuel Christophe committed
2
#include "otbImageFileWriter.h"
3 4 5 6
#include "otbVectorData.h"
#include "otbVectorDataProjectionFilter.h"
#include <fstream>
#include <iostream>
7

8 9 10
#include "itkRGBAPixel.h"
#include "otbImage.h"
#include "otbVectorDataToImageFilter.h"
11 12 13 14

int main(int argc, char * argv[])
{

15
  //Read the vector data
Emmanuel Christophe's avatar
Emmanuel Christophe committed
16
  typedef otb::VectorData<> VectorDataType;
17 18 19 20 21 22 23 24 25 26 27 28 29
  typedef otb::VectorDataFileReader<VectorDataType> VectorDataFileReaderType;
  VectorDataFileReaderType::Pointer reader = VectorDataFileReaderType::New();

  reader->SetFileName(argv[1]);

  //Reproject the vector data in the proper projection
  typedef otb::VectorDataProjectionFilter<VectorDataType, VectorDataType> ProjectionFilterType;
  ProjectionFilterType::Pointer projection = ProjectionFilterType::New();
  projection->SetInput(reader->GetOutput());
//   projection->Update();

  //Convert the vector data into an image
  typedef itk::RGBAPixel< unsigned char > PixelType;
Emmanuel Christophe's avatar
Emmanuel Christophe committed
30
  typedef otb::Image<PixelType,2> ImageType;
31 32 33 34 35 36 37 38 39 40 41 42
  typedef otb::VectorDataToImageFilter<VectorDataType, ImageType> VectorDataToImageFilterType;
  VectorDataToImageFilterType::Pointer vectorDataRendering = VectorDataToImageFilterType::New();
  vectorDataRendering->SetInput(projection->GetOutput());

  //Save the image in a file
  typedef otb::ImageFileWriter<ImageType> WriterType;
  WriterType::Pointer writer = WriterType::New();
  writer->SetInput(vectorDataRendering);
  writer->SetFileName(argv[2]);
  writer->Update();


43 44 45

  return EXIT_SUCCESS;
}