histogram matching of cloud masked Landsat 8 messages

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

histogram matching of cloud masked Landsat 8 messages

sarah crabbe
Dear all,

We are trying to apply a histogram matching on cloudmasked landsat 8 images, with the intention to fill the clouds.
Therefore we want to use the package "Landsat"

We tried to import two bands with the package "raster":

image1<-raster("LC82280562013211LGN00_B1.tif")
image2<-raster("LC82280562013227LGN00_B1.tif")

whereafter we try to apply a histogram matching with the landsat package:

histmatch(image1, image2, minval=0, maxval= 65535, by=1)

And we get following error:

Error in as.vector(data) :
no method for coercing this S4 class to a vector

This might be easy to solve, but we just started to learn how to work with R for image processing, So could we please get some advice on this..
Many thanks
Sarah
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: histogram matching of cloud masked Landsat 8 messages

Barry Rowlingson
Instructions say (help(histmatch))


Arguments:

  master: The target image, in SpatialGridDataFrame, data frame, matrix
          or vector format.

   tofix: The image to be normalized, in any format.

but what you have is a *raster* object, not a SpatialGridDataFrame, or
any other of those.

 You can convert a raster, r, to a SpatialGridDataFrame, rg:

 > rg = as(r,"SpatialGridDataFrame")

and then feed those to histmatch. You probably have to convert both arguments.

Barry



On Tue, Aug 12, 2014 at 4:45 PM, sarah crabbe <[hidden email]> wrote:

> Dear all,
>
> We are trying to apply a histogram matching on cloudmasked landsat 8 images, with the intention to fill the clouds.
> Therefore we want to use the package "Landsat"
>
> We tried to import two bands with the package "raster":
>
> image1<-raster("LC82280562013211LGN00_B1.tif")
> image2<-raster("LC82280562013227LGN00_B1.tif")
>
> whereafter we try to apply a histogram matching with the landsat package:
>
> histmatch(image1, image2, minval=0, maxval= 65535, by=1)
>
> And we get following error:
>
> Error in as.vector(data) :
> no method for coercing this S4 class to a vector
>
> This might be easy to solve, but we just started to learn how to work with R for image processing, So could we please get some advice on this..
> Many thanks
> Sarah
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: histogram matching of cloud masked Landsat 8 messages

Sarah Goslee
What Barry says is completely correct: the landsat package (not
Landsat), is not currently compatible with the format used by the
raster package, only with sp classes or base R object types. You can
convert the raster objects, or use the rgdal package to import your
tifs as SGDFs.

And as I told you in private email, the landsat package was developed
pre-Landsat 8, and has not been updated for the new data source.

Both raster compatibility and Landsat 8 support are in the works, but
will not be available in the very near future.

Sarah

On Tue, Aug 12, 2014 at 12:25 PM, Barry Rowlingson
<[hidden email]> wrote:

> Instructions say (help(histmatch))
>
>
> Arguments:
>
>   master: The target image, in SpatialGridDataFrame, data frame, matrix
>           or vector format.
>
>    tofix: The image to be normalized, in any format.
>
> but what you have is a *raster* object, not a SpatialGridDataFrame, or
> any other of those.
>
>  You can convert a raster, r, to a SpatialGridDataFrame, rg:
>
>  > rg = as(r,"SpatialGridDataFrame")
>
> and then feed those to histmatch. You probably have to convert both arguments.
>
> Barry
>
>
>
> On Tue, Aug 12, 2014 at 4:45 PM, sarah crabbe <[hidden email]> wrote:
>> Dear all,
>>
>> We are trying to apply a histogram matching on cloudmasked landsat 8 images, with the intention to fill the clouds.
>> Therefore we want to use the package "Landsat"
>>
>> We tried to import two bands with the package "raster":
>>
>> image1<-raster("LC82280562013211LGN00_B1.tif")
>> image2<-raster("LC82280562013227LGN00_B1.tif")
>>
>> whereafter we try to apply a histogram matching with the landsat package:
>>
>> histmatch(image1, image2, minval=0, maxval= 65535, by=1)
>>
>> And we get following error:
>>
>> Error in as.vector(data) :
>> no method for coercing this S4 class to a vector
>>
>> This might be easy to solve, but we just started to learn how to work with R for image processing, So could we please get some advice on this..
>> Many thanks
>> Sarah

--
Sarah Goslee
http://www.functionaldiversity.org

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo