[pktools] 189/375: retain nodata in pksieve when mask is set

Bas Couwenberg sebastic at xs4all.nl
Wed Dec 3 21:54:12 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch upstream-master
in repository pktools.

commit 3682d1ffc98c093e5e93657790606d14f7231203
Author: Default Seadas User <seadas-user at localhost>
Date:   Mon Feb 24 18:00:37 2014 +0100

    retain nodata in pksieve when mask is set
---
 ChangeLog             |  4 +++-
 src/apps/pkcrop.cc    |  2 +-
 src/apps/pkopt_svm.cc |  6 ++++--
 src/apps/pksieve.cc   | 21 ++++++++++++---------
 4 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 50ad0a3..179fc60 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -261,8 +261,10 @@ version 2.5.1
 	no automatic normalization user provided filter taps
  - pkcrop
 	correct bounding box when dx_opt and dy_opt are set
+ - pksieve
+	retain nodata in pksieve when mask is set
 version 2.5.2 (todo)
- - pkcrop -> pkcropnmerge
+ - pkcrop -> pkcropnmerge or pkcropnstack
 	name was confusing as pkcrop supports spatial and spectral subsetting and merging
  - pkmosaic -> pkcomposit
 	name was confusing as also compositing is supported (unlike gdal_merge.py and gdalwarp)
diff --git a/src/apps/pkcrop.cc b/src/apps/pkcrop.cc
index d27483b..4248e61 100644
--- a/src/apps/pkcrop.cc
+++ b/src/apps/pkcrop.cc
@@ -271,7 +271,7 @@ int main(int argc, char *argv[])
     double uli,ulj,lri,lrj;//image coordinates
     bool forceEUgrid=false;
     if(projection_opt.size())
-      forceEUgrid=(!(projection_opt[0].compare("EPSG:3035"))||!(projection_opt[0].compare("EPSG:3035"))||projection_opt[0].find("ETRS-LAEA")!=string::npos);
+      forceEUgrid=(!(projection_opt[0].compare("EPSG:3035"))||!(projection_opt[0].compare("epsg:3035"))||projection_opt[0].find("ETRS-LAEA")!=string::npos);
     if(ulx_opt[0]>=lrx_opt[0]){//default bounding box: no cropping
       uli=0;
       lri=imgReader.nrOfCol()-1;
diff --git a/src/apps/pkopt_svm.cc b/src/apps/pkopt_svm.cc
index 0a8ff6b..6e48923 100644
--- a/src/apps/pkopt_svm.cc
+++ b/src/apps/pkopt_svm.cc
@@ -601,8 +601,10 @@ int main(int argc, char *argv[])
     double progress=0;
     if(!verbose_opt[0])
       pfnProgress(progress,pszMessage,pProgressArg);
-    double ncost=log(ccost_opt[1])/log(10)-log(ccost_opt[0])/log(10);
-    double ngamma=log(gamma_opt[1])/log(10)-log(gamma_opt[0])/log(10);
+    // double ncost=log(ccost_opt[1])/log(step_opt[0])-log(ccost_opt[0])/log(step_opt[0]);
+    double ncost=log(ccost_opt[1]/ccost_opt[0])/log(step_opt[0]);
+    // double ngamma=log(gamma_opt[1])/log(step_opt[1])-log(gamma_opt[0])/log(step_opt[1]);
+    double ngamma=log(gamma_opt[1]/gamma_opt[0])/log(step_opt[1]);
     for(double ccost=ccost_opt[0];ccost<=ccost_opt[1];ccost*=step_opt[0]){
       for(double gamma=gamma_opt[0];gamma<=gamma_opt[1];gamma*=step_opt[1]){
 	x[0]=ccost;
diff --git a/src/apps/pksieve.cc b/src/apps/pksieve.cc
index 7d373a5..39b01ca 100644
--- a/src/apps/pksieve.cc
+++ b/src/apps/pksieve.cc
@@ -74,15 +74,6 @@ int main(int argc,char **argv) {
   GDALProgressFunc pfnProgress=GDALTermProgress;
   pfnProgress(dfComplete,pszMessage,pProgressArg);
   
-  ImgReaderGdal maskReader;
-  GDALRasterBand *maskBand=NULL;
-  if(mask_opt.size()){
-    if(verbose_opt[0])
-      cout << "opening mask file " << mask_opt[0] << endl;
-    maskReader.open(mask_opt[0]);
-    maskBand = maskReader.getRasterBand(0);
-  }
-
   assert(input_opt.size());
   assert(output_opt.size());
   ImgReaderGdal inputReader(input_opt[0]);
@@ -94,6 +85,17 @@ int main(int argc,char **argv) {
   if(verbose_opt[0])
     cout << "opening output file " << output_opt[0] << endl;
   outputWriter.open(output_opt[0],inputReader);
+
+  ImgReaderGdal maskReader;
+  GDALRasterBand *maskBand=NULL;
+  if(mask_opt.size()){
+    if(verbose_opt[0])
+      cout << "opening mask file " << mask_opt[0] << endl;
+    maskReader.open(mask_opt[0]);
+    maskBand = maskReader.getRasterBand(0);
+    outputWriter.GDALSetNoDataValue(0);
+  }
+
   if(colorTable_opt.size()){
     if(colorTable_opt[0]!="none")
       outputWriter.setColorTable(colorTable_opt[0]);
@@ -101,6 +103,7 @@ int main(int argc,char **argv) {
   else if (inputReader.getColorTable()!=NULL)//copy colorTable from input image
     outputWriter.setColorTable(inputReader.getColorTable());
   outputBand = outputWriter.getRasterBand(0);
+
   //sieve filter to remove small raster elements (overwrite input band)
   if(size_opt[0]){
     if(GDALSieveFilter((GDALRasterBandH)inputBand, (GDALRasterBandH)maskBand, (GDALRasterBandH)outputBand, size_opt[0], connect_opt[0],NULL,pfnProgress,pProgressArg)!=CE_None)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git



More information about the Pkg-grass-devel mailing list