Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
11e3227d
Commit
11e3227d
authored
Jun 19, 2012
by
Julien Michel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: Moving rasterization application to new rasterization algorithm
parent
faf41326
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
91 deletions
+42
-91
Applications/CMakeLists.txt
Applications/CMakeLists.txt
+0
-2
Applications/Rasterization/CMakeLists.txt
Applications/Rasterization/CMakeLists.txt
+1
-1
Applications/Rasterization/otbRasterization.cxx
Applications/Rasterization/otbRasterization.cxx
+41
-88
No files found.
Applications/CMakeLists.txt
View file @
11e3227d
...
...
@@ -15,9 +15,7 @@ add_subdirectory(Hyperspectral)
add_subdirectory
(
Projections
)
add_subdirectory
(
RadiometricIndices
)
add_subdirectory
(
Radiometry
)
IF
(
OTB_USE_MAPNIK
)
add_subdirectory
(
Rasterization
)
ENDIF
(
OTB_USE_MAPNIK
)
add_subdirectory
(
Segmentation
)
add_subdirectory
(
Test
)
add_subdirectory
(
Utils
)
Applications/Rasterization/CMakeLists.txt
View file @
11e3227d
OTB_CREATE_APPLICATION
(
NAME Rasterization
SOURCES otbRasterization.cxx
LINK_LIBRARIES OTBBasicFilters
)
LINK_LIBRARIES OTBBasicFilters
;OTBCommon;OTBOGRAdapters
)
Applications/Rasterization/otbRasterization.cxx
View file @
11e3227d
...
...
@@ -18,13 +18,11 @@
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"
#include "otbVectorDataExtractROI.h"
#include "otbVectorDataProjectionFilter.h"
#include "otbVectorDataProperties.h"
#include "otbVectorDataToMapFilter.h"
#include "otbGeoInformationConversion.h"
#include "otbRemoteSensingRegion.h"
#include "otbOGRDataSourceWrapper.h"
#include "otbOGRDataSourceToLabelImageFilter.h"
// #include "otbGenericRSTransform.h"
namespace
otb
{
...
...
@@ -47,23 +45,18 @@ public:
/** Filters typedef */
// the application produces a binary mask : no need to use a FloatVectorImageType
typedef
UInt8ImageType
::
PointType
PointType
;
typedef
UInt8ImageType
::
SizeType
SizeType
;
typedef
UInt8ImageType
::
SpacingType
SpacingType
;
typedef
UInt8ImageType
::
IndexType
IndexType
;
typedef
UInt8ImageType
::
PointType
PointType
;
typedef
UInt8ImageType
::
SizeType
SizeType
;
typedef
UInt8ImageType
::
SpacingType
SpacingType
;
typedef
UInt8ImageType
::
IndexType
IndexType
;
typedef
VectorDataProjectionFilter
<
VectorDataType
,
VectorDataType
>
VectorDataProjectionFilterType
;
typedef
VectorDataExtractROI
<
VectorDataType
>
VectorDataExtractROIType
;
typedef
VectorDataProperties
<
VectorDataType
>
VectorDataPropertiesType
;
// Rasterization
typedef
otb
::
VectorDataToMapFilter
<
VectorDataType
,
UInt8ImageType
>
VectorDataToMapFilterType
;
// Misc
typedef
otb
::
RemoteSensingRegion
<
double
>
RemoteSensingRegionType
;
typedef
RemoteSensingRegionType
::
SizeType
SizePhyType
;
// typedef otb::GenericRSTransform<> RSTransformType;
typedef
otb
::
PipelineMemoryPrintCalculator
MemoryCalculatorType
;
// Exact rasterization mode
typedef
otb
::
OGRDataSourceToLabelImageFilter
<
FloatImageType
>
OGRDataSourceToMapFilterType
;
private:
void
DoInit
()
{
...
...
@@ -78,7 +71,7 @@ private:
AddDocTag
(
Tags
::
Vector
);
AddParameter
(
ParameterType_Input
VectorData
,
"in"
,
"InputVectorData"
);
AddParameter
(
ParameterType_Input
Filename
,
"in"
,
"InputVectorData"
);
SetParameterDescription
(
"in"
,
"The input vector data to be rasterized"
);
AddParameter
(
ParameterType_OutputImage
,
"out"
,
"OutputImage"
);
...
...
@@ -90,11 +83,11 @@ private:
AddParameter
(
ParameterType_Float
,
"szx"
,
"SizeX"
);
SetParameterDescription
(
"szx"
,
"OutputSize[0] (useless if support image is given)"
);
MandatoryOff
(
"szx"
);
//
MandatoryOff("szx");
AddParameter
(
ParameterType_Float
,
"szy"
,
"SizeY"
);
SetParameterDescription
(
"szy"
,
"OutputSize[1] (useless if support image is given)"
);
MandatoryOff
(
"szy"
);
//
MandatoryOff("szy");
AddParameter
(
ParameterType_Int
,
"epsg"
,
"RSID"
);
SetParameterDescription
(
"epsg"
,
"Projection System RSID number (RSID 4326 for WGS84 32631 for UTM31N) (useless if support image is given)"
);
...
...
@@ -102,11 +95,11 @@ private:
AddParameter
(
ParameterType_Float
,
"orx"
,
"OriginX"
);
SetParameterDescription
(
"orx"
,
"OutputOrigin[0] (useless if support image is given)"
);
MandatoryOff
(
"orx"
);
//
MandatoryOff("orx");
AddParameter
(
ParameterType_Float
,
"ory"
,
"OriginY"
);
SetParameterDescription
(
"ory"
,
"OutputOrigin[1] (useless if support image is given)"
);
MandatoryOff
(
"ory"
);
//
MandatoryOff("ory");
AddParameter
(
ParameterType_Float
,
"spx"
,
"SpacingX"
);
SetParameterDescription
(
"spx"
,
"OutputSpacing[0] (useless if support image is given)"
);
...
...
@@ -116,6 +109,13 @@ private:
SetParameterDescription
(
"spy"
,
"OutputSpacing[1] (useless if support image is given)"
);
MandatoryOff
(
"spy"
);
AddParameter
(
ParameterType_Choice
,
"mode"
,
"Rasterization mode"
);
SetParameterDescription
(
"mode"
,
"This parameter allows to choose between rasterization modes"
);
AddParameter
(
ParameterType_String
,
"field"
,
"The attribute field to burn"
);
SetParameterDescription
(
"field"
,
"Name of the attribute field to burn"
);
SetParameterString
(
"field"
,
"DN"
);
AddRAMParameter
();
SetDocExampleParameterValue
(
"in"
,
"qb_RoadExtract_classification.shp"
);
...
...
@@ -132,17 +132,15 @@ private:
void
DoExecute
()
{
VectorDataType
::
Pointer
inputVData
=
GetParameterVectorData
(
"in"
);
inputVData
->
Update
();
{
UInt8ImageType
::
Pointer
referenceImage
;
m_OgrDS
=
otb
::
ogr
::
DataSource
::
New
(
GetParameterString
(
"inputVData"
),
otb
::
ogr
::
DataSource
::
Modes
::
read
);
// region information
SizeType
size
;
PointType
origin
;
SpacingType
spacing
;
SizePhyType
sizePhy
;
// reading projection information
// two choice :
...
...
@@ -166,9 +164,6 @@ private:
origin
=
referenceImage
->
GetOrigin
();
spacing
=
referenceImage
->
GetSpacing
();
sizePhy
[
0
]
=
size
[
0
]
*
spacing
[
0
];
sizePhy
[
1
]
=
size
[
1
]
*
spacing
[
1
];
}
else
if
(
HasValue
(
"szx"
)
&&
HasValue
(
"szy"
))
{
...
...
@@ -179,13 +174,9 @@ private:
}
else
{
outputProjectionRef
=
inputVData
->
GetProjectionRef
();
outputProjectionRef
=
m_OgrDS
->
GetProjectionRef
();
}
m_VdProperties
=
VectorDataPropertiesType
::
New
();
m_VdProperties
->
SetVectorDataObject
(
inputVData
);
m_VdProperties
->
ComputeBoundingRegion
();
size
[
0
]
=
GetParameterFloat
(
"szx"
);
size
[
1
]
=
GetParameterFloat
(
"szy"
);
...
...
@@ -196,7 +187,7 @@ private:
}
else
{
origin
=
m_VdProperties
->
GetBoundingRegion
().
GetIndex
();
// Not handled for now, parameter is mandatory
}
if
(
HasValue
(
"spx"
)
&&
HasValue
(
"spy"
))
...
...
@@ -206,66 +197,28 @@ private:
}
else
{
spacing
[
0
]
=
m_VdProperties
->
GetBoundingRegion
().
GetSize
()[
0
]
/
size
[
0
];
spacing
[
1
]
=
m_VdProperties
->
GetBoundingRegion
().
GetSize
()[
1
]
/
size
[
1
];
// Not handled for now, parameter is mandatory
}
sizePhy
[
0
]
=
size
[
0
]
*
spacing
[
0
];
sizePhy
[
1
]
=
size
[
1
]
*
spacing
[
1
];
}
else
{
otbAppLogFATAL
(
"Input entry problem, if no reference image given, region size is needed "
);
}
// Reprojecting the VectorData
m_Vproj
=
VectorDataProjectionFilterType
::
New
();
m_Vproj
->
SetInput
(
inputVData
);
m_Vproj
->
SetInputProjectionRef
(
inputVData
->
GetProjectionRef
());
m_Vproj
->
SetOutputProjectionRef
(
outputProjectionRef
);
if
(
HasValue
(
"im"
))
{
m_Vproj
->
SetOutputKeywordList
(
referenceImage
->
GetImageKeywordlist
());
}
RemoteSensingRegionType
region
;
region
.
SetSize
(
sizePhy
);
region
.
SetOrigin
(
origin
);
region
.
SetRegionProjection
(
outputProjectionRef
);
if
(
HasValue
(
"im"
))
{
region
.
SetKeywordList
(
referenceImage
->
GetImageKeywordlist
());
}
m_Vdextract
=
VectorDataExtractROIType
::
New
();
m_Vdextract
->
SetRegion
(
region
);
m_Vdextract
->
SetInput
(
m_Vproj
->
GetOutput
());
m_VectorDataRendering
=
VectorDataToMapFilterType
::
New
();
m_VectorDataRendering
->
SetInput
(
m_Vdextract
->
GetOutput
());
m_VectorDataRendering
->
SetSize
(
size
);
m_VectorDataRendering
->
SetOrigin
(
origin
);
m_VectorDataRendering
->
SetSpacing
(
spacing
);
m_VectorDataRendering
->
SetVectorDataProjectionWKT
(
outputProjectionRef
);
m_VectorDataRendering
->
SetRenderingStyleType
(
VectorDataToMapFilterType
::
Binary
);
UInt8ImageType
::
Pointer
outputImage
=
m_VectorDataRendering
->
GetOutput
();
if
(
HasValue
(
"im"
))
{
outputImage
->
SetMetaDataDictionary
(
referenceImage
->
GetMetaDataDictionary
());
}
AddProcess
(
m_VectorDataRendering
,
"Rasterization"
);
SetParameterOutputImage
<
UInt8ImageType
>
(
"out"
,
outputImage
);
m_OGRDataSourceRendering
=
OGRDataSourceToMapFilterType
::
New
();
m_OGRDataSourceRendering
->
AddOGRDataSource
(
m_OgrDS
);
m_OGRDataSourceRendering
->
SetBurnAttribute
(
GetParameterString
(
"field"
));
m_OGRDataSourceRendering
->
SetOutputSize
(
size
);
m_OGRDataSourceRendering
->
SetOutputOrigin
(
origin
);
m_OGRDataSourceRendering
->
SetOutputSpacing
(
spacing
);
m_OGRDataSourceRendering
->
SetOutputProjectionRef
(
outputProjectionRef
);
SetParameterOutputImage
<
FloatImageType
>
(
"out"
,
m_OGRDataSourceRendering
->
GetOutput
());
}
VectorDataPropertiesType
::
Pointer
m_VdProperties
;
VectorDataProjectionFilterType
::
Pointer
m_Vproj
;
VectorDataExtractROIType
::
Pointer
m_Vdextract
;
VectorDataToMapFilterType
::
Pointer
m_VectorDataRendering
;
otb
::
ogr
::
DataSource
::
Pointer
m_OgrDS
;
OGRDataSourceToMapFilterType
::
Pointer
m_OGRDataSourceRendering
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment