Does RSGISLib support .tif Images ? or Need to convert them into .kea Images ?

44 views
Skip to first unread message

Alpesh

unread,
May 14, 2019, 7:17:37 AM5/14/19
to RSGISLib Support

Hello Sir,

I am using RSGISLib Object based classification Training Manual.

I have abc.tif images with 3 different bands.

I have convert them to abc.kea images.

Than I have stacked this abc.kea  images using "imageutils.stackImageBands"  => abc3.kea

Than I have subset this stacked abc3.kea image  using "imageutils.subsetbbox"  => abc3_subset.kea

Than I have segment this abc3_subset.kea image using "segutils.runShepherdSegmentation"   => abc3_subset_clumps.kea  ,  abc3_subset_clumps_Means.kea

All above steps are worked on my converted images ( abc.tif to abc.kea )

Shapefiles have been generated from abc3_subset_clumps_Means.kea uing QGIS.

But 16_PerformObjClass.py script is giving bellow error with Input files:  abc3_subset.kea, abc3_subset_clumps.kea  and shapefiles


"ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required"

This error will not come if I use the images and shapefiles given in the RSGISLib training manual Jan 2018.

I have also check all 4 combination options with same 16_PerformObjClass.py as bellow:


case1: Training manual Images        &      Training manual  shapefiles                  =>  No  Error
case2: Training manual Images          &      My   shapefiles                                      =>  Above Error
case3: My Images                              &       Training manual  shapefiles                   =>  Above Error
case4: My Images                               &      My   shapefiles                                       =>  Above Error

In conclusion, if I use Training manual Images & Training manual  shapefiles than my script file will work, but if I replace just my images than it shows error.    

Sir, is there any problem with my .tif to .kea conversion process ?    If. its like so, than please suggest some standard conversion script.

Sir, if I am doing some mistake / misunderstanding than please let me know.




Bellow is the terminal running error messages for case2, case3 and case4:


Started .0..10..20..30..40..50..60..70..80..90. Complete.
Started .0..10..20..30..40..50..60..
70..80..90. Complete.
Writing Stats (Mean, ) to Output RAT
Building
Building.shp
./tmp/Building_22dd1e3f2b.kea
Creating output image using input image
Started Complete.
Running Rasterise now...
Building.shp
<osgeo.ogr.DataSource; proxy of <Swig Object of type 'OGRDataSourceShadow *' at 0x7f2e42cc1b40> >
Adding Colour Table
Get Image Min and Max.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Calculating Image Pyramids.
Started .0..20..50..70..100. Complete.
Completed
Land
Land.shp
./tmp/Land_22dd1e3f2b.kea
       ....
       ....
       ....
        ....
Water.shp
<osgeo.ogr.DataSource; proxy of <Swig Object of type 'OGRDataSourceShadow *' at 0x7f2e42cc1b40> >
Adding Colour Table
Get Image Min and Max.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Calculating Image Pyramids.
Started .0..20..50..70..100. Complete.
Completed
New image width = 1160 height = 980 bands = 1
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Opening Clumps Image: 23997_BAND432_subset_Clumps_Mean_1.kea
Opening Input Image: ./tmp/CombinedClasses_22dd1e3f2b.kea
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Min 0
Max 0
Range 1
[0]
Started .0..10..20..30..40..50..60..70..80..90. Complete.
Writing Stats to RAT
Deleting file: ./tmp/Building_22dd1e3f2b.kea
Deleting file: ./tmp/Land_22dd1e3f2b.kea
Deleting file: ./tmp/Road_22dd1e3f2b.kea
Deleting file: ./tmp/Water_22dd1e3f2b.kea
Deleting file: ./tmp/CombinedClasses_22dd1e3f2b.kea
Number of input samples:
Number of output samples:
Reading NIRMean
Reading RedMean
Reading GreenMean
Input data size: 37625 x 3

classesInt are [0 0 0 ... 0 0 0]
Training data size: 0 x 3
Training data IDs size: 0

[]
/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_split.py:2053: FutureWarning: You should specify a value for 'cv' instead of relying on the default value. The default value will change from 3 to 5 in version 0.22.
  warnings.warn(CV_WARNING, FutureWarning)
Traceback (most recent call last):
  File "PerformObjClass.py", line 85, in <module>
    classifier = classratutils.findClassifierParameters(clumpsImg, classesIntCol, variables, preProcessor=None, gridSearch=gSearch)  #Find the optimal parameters for a classifier using a grid search and return a classifier instance with those optimal parameters
  File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/rsgislib/classification/classratutils.py", line 688, in findClassifierParameters
    gridSearch.fit(trainingData, classesInt)
  File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 722, in fit
    self._run_search(evaluate_candidates)
  File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 1191, in _run_search
    evaluate_candidates(ParameterGrid(self.param_grid))
  File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_search.py", line 711, in evaluate_candidates
    cv.split(X, y, groups)))
  File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/model_selection/_split.py", line 719, in split
    y = check_array(y, ensure_2d=False, dtype=None)
  File "/home/alpesh/anaconda3/envs/osgeo-env-v1/lib/python3.6/site-packages/sklearn/utils/validation.py", line 582, in check_array
    context))
ValueError: Found array with 0 sample(s) (shape=(0,)) while a minimum of 1 is required.
Reply all
Reply to author
Forward
0 new messages