Dear list, I want to do some unsupervised image classification of some landsat imagery, I think I can read in the multi-band rasters using rgdal, but has anyone tried doing this in R? I am thinking (after looking at documentation for how GRASS and ArcGIS do it) that I need to do an initial hierarchical clustering to define clusters, but does anyone have an idea on how to do a maximum likelihood classification of the imagery? Would a discriminant function approach work? Any advice anyone may have would be greatly appreciated, and i'm very sorry but I don't have a working example yet. Best Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks 'at' utsa.edu
image classification in R
8 messages · Corey Sparks, Edzer Pebesma, Tomislav Hengl +2 more
Corey, you can use functions lda or qda (in library MASS) for linear or quadratic discriminant analysis, respectively, on your training/ground truth data, and then use the predict method on the resulting objects, passing the bands (you need to convert the SpatialGridDataFrame to a data.frame) as newdata to obtain the classified pixels. Make sure that the band names have identical name in both cases. Then assign the predicted class to the SpatialGridDataFrame and export. It has never been clear to me whether "maximum likelihood classification" in RS refers to lda or qda. Anyway, it's called discriminant analysis in the statistical literature. -- Edzer
Corey Sparks wrote:
Dear list, I want to do some unsupervised image classification of some landsat imagery, I think I can read in the multi-band rasters using rgdal, but has anyone tried doing this in R? I am thinking (after looking at documentation for how GRASS and ArcGIS do it) that I need to do an initial hierarchical clustering to define clusters, but does anyone have an idea on how to do a maximum likelihood classification of the imagery? Would a discriminant function approach work? Any advice anyone may have would be greatly appreciated, and i'm very sorry but I don't have a working example yet. Best Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks 'at' utsa.edu
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics (ifgi), University of M?nster Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/ http://www.springer.com/978-0-387-78170-9 e.pebesma at wwu.de
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090417/d4a9bba8/attachment.pl>
There's a Task View on clustering, linked from CRAN: http://cran.r-project.org/web/views/Cluster.html that will lead you to all types of clustering available, including hierarchical. I don't know how well it will work for large data sets such as images, as it calls for constructing n x n distance matrices, with n the number of pixels. -- Edzer
Hengl, T. wrote:
Don't forget that you can also use different types of unsupervised classification methods, such as the fuzzy k-means as implemented in the "kmeans" method. Here is an example (with landform classes): http://spatial-analyst.net/wiki/index.php?title=Analysis_of_DEMs_in_R%2BILWIS/SAGA If you work with large grids, consider also using R+SAGA: https://stat.ethz.ch/pipermail/r-sig-geo/2009-February/005155.html T. Hengl -----Original Message----- From: r-sig-geo-bounces at stat.math.ethz.ch on behalf of Edzer Pebesma Sent: Fri 4/17/2009 5:32 PM To: Corey Sparks Cc: r-sig-geo at stat.math.ethz.ch Subject: Re: [R-sig-Geo] image classification in R Corey, you can use functions lda or qda (in library MASS) for linear or quadratic discriminant analysis, respectively, on your training/ground truth data, and then use the predict method on the resulting objects, passing the bands (you need to convert the SpatialGridDataFrame to a data.frame) as newdata to obtain the classified pixels. Make sure that the band names have identical name in both cases. Then assign the predicted class to the SpatialGridDataFrame and export. It has never been clear to me whether "maximum likelihood classification" in RS refers to lda or qda. Anyway, it's called discriminant analysis in the statistical literature. -- Edzer Corey Sparks wrote:
Dear list, I want to do some unsupervised image classification of some landsat imagery, I think I can read in the multi-band rasters using rgdal, but has anyone tried doing this in R? I am thinking (after looking at documentation for how GRASS and ArcGIS do it) that I need to do an initial hierarchical clustering to define clusters, but does anyone have an idea on how to do a maximum likelihood classification of the imagery? Would a discriminant function approach work? Any advice anyone may have would be greatly appreciated, and i'm very sorry but I don't have a working example yet. Best Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks 'at' utsa.edu
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
------------------------------------------------------------------------
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Edzer Pebesma Institute for Geoinformatics (ifgi), University of M?nster Weseler Stra?e 253, 48151 M?nster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de/ http://www.springer.com/978-0-387-78170-9 e.pebesma at wwu.de
In my opinion, and considering that imagery uses to be very large datasets, unless you want to include spatial characteristics, the best is to subsample your imagery with your gis, then import the dataset to R, perform classification with the many tools available, save the centroids (means, sds, covar matrices depending on your method) and then allocate pixels to those centroids in your gis. Images are too large for R Agus
Edzer Pebesma wrote:
There's a Task View on clustering, linked from CRAN: http://cran.r-project.org/web/views/Cluster.html that will lead you to all types of clustering available, including hierarchical. I don't know how well it will work for large data sets such as images, as it calls for constructing n x n distance matrices, with n the number of pixels. -- Edzer Hengl, T. wrote:
Don't forget that you can also use different types of unsupervised classification methods, such as the fuzzy k-means as implemented in the "kmeans" method. Here is an example (with landform classes): http://spatial-analyst.net/wiki/index.php?title=Analysis_of_DEMs_in_R%2BILWIS/SAGA If you work with large grids, consider also using R+SAGA: https://stat.ethz.ch/pipermail/r-sig-geo/2009-February/005155.html T. Hengl -----Original Message----- From: r-sig-geo-bounces at stat.math.ethz.ch on behalf of Edzer Pebesma Sent: Fri 4/17/2009 5:32 PM To: Corey Sparks Cc: r-sig-geo at stat.math.ethz.ch Subject: Re: [R-sig-Geo] image classification in R Corey, you can use functions lda or qda (in library MASS) for linear or quadratic discriminant analysis, respectively, on your training/ground truth data, and then use the predict method on the resulting objects, passing the bands (you need to convert the SpatialGridDataFrame to a data.frame) as newdata to obtain the classified pixels. Make sure that the band names have identical name in both cases. Then assign the predicted class to the SpatialGridDataFrame and export. It has never been clear to me whether "maximum likelihood classification" in RS refers to lda or qda. Anyway, it's called discriminant analysis in the statistical literature. -- Edzer Corey Sparks wrote:
Dear list, I want to do some unsupervised image classification of some landsat imagery, I think I can read in the multi-band rasters using rgdal, but has anyone tried doing this in R? I am thinking (after looking at documentation for how GRASS and ArcGIS do it) that I need to do an initial hierarchical clustering to define clusters, but does anyone have an idea on how to do a maximum likelihood classification of the imagery? Would a discriminant function approach work? Any advice anyone may have would be greatly appreciated, and i'm very sorry but I don't have a working example yet. Best Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks 'at' utsa.edu
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
------------------------------------------------------------------------
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-------------- next part -------------- A non-text attachment was scrubbed... Name: alobolistas.vcf Type: text/x-vcard Size: 251 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090418/0dcd7d60/attachment.vcf>
Yes, I've already run into this problem trying to run hclust on a landsat image. I'm on an imac with leopard and 4gb of ram and the distance matrix needed wouldn't fit into memory. I will try the sub- sampling technique. Thank you all for you assistance. Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies College of Public Policy One UTSA Circle San Antonio, TX 78239 corey.sparks 'at' utsa.edu
On Apr 18, 2009, at 6:54 AM, Agustin Lobo wrote:
In my opinion, and considering that imagery uses to be very large datasets, unless you want to include spatial characteristics, the best is to subsample your imagery with your gis, then import the dataset to R, perform classification with the many tools available, save the centroids (means, sds, covar matrices depending on your method) and then allocate pixels to those centroids in your gis. Images are too large for R Agus Edzer Pebesma wrote:
There's a Task View on clustering, linked from CRAN: http://cran.r-project.org/web/views/Cluster.html that will lead you to all types of clustering available, including hierarchical. I don't know how well it will work for large data sets such as images, as it calls for constructing n x n distance matrices, with n the number of pixels. -- Edzer Hengl, T. wrote:
Don't forget that you can also use different types of unsupervised classification methods, such as the fuzzy k-means as implemented in the "kmeans" method. Here is an example (with landform classes): http://spatial-analyst.net/wiki/index.php? title=Analysis_of_DEMs_in_R%2BILWIS/SAGA If you work with large grids, consider also using R+SAGA: https://stat.ethz.ch/pipermail/r-sig-geo/2009-February/005155.html T. Hengl -----Original Message----- From: r-sig-geo-bounces at stat.math.ethz.ch on behalf of Edzer Pebesma Sent: Fri 4/17/2009 5:32 PM To: Corey Sparks Cc: r-sig-geo at stat.math.ethz.ch Subject: Re: [R-sig-Geo] image classification in R Corey, you can use functions lda or qda (in library MASS) for linear or quadratic discriminant analysis, respectively, on your training/ ground truth data, and then use the predict method on the resulting objects, passing the bands (you need to convert the SpatialGridDataFrame to a data.frame) as newdata to obtain the classified pixels. Make sure that the band names have identical name in both cases. Then assign the predicted class to the SpatialGridDataFrame and export. It has never been clear to me whether "maximum likelihood classification" in RS refers to lda or qda. Anyway, it's called discriminant analysis in the statistical literature. -- Edzer Corey Sparks wrote:
Dear list, I want to do some unsupervised image classification of some landsat imagery, I think I can read in the multi-band rasters using rgdal, but has anyone tried doing this in R? I am thinking (after looking at documentation for how GRASS and ArcGIS do it) that I need to do an initial hierarchical clustering to define clusters, but does anyone have an idea on how to do a maximum likelihood classification of the imagery? Would a discriminant function approach work? Any advice anyone may have would be greatly appreciated, and i'm very sorry but I don't have a working example yet. Best Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks 'at' utsa.edu
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-------------------------------------------------------------------- ----
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
<alobolistas.vcf>
2 days later
Beware that results yield by hierarchical clustering are very dependent upon the actual initial subsample, Agus
Corey Sparks wrote:
Yes, I've already run into this problem trying to run hclust on a landsat image. I'm on an imac with leopard and 4gb of ram and the distance matrix needed wouldn't fit into memory. I will try the sub-sampling technique. Thank you all for you assistance. Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies College of Public Policy One UTSA Circle San Antonio, TX 78239 corey.sparks 'at' utsa.edu On Apr 18, 2009, at 6:54 AM, Agustin Lobo wrote:
In my opinion, and considering that imagery uses to be very large datasets, unless you want to include spatial characteristics, the best is to subsample your imagery with your gis, then import the dataset to R, perform classification with the many tools available, save the centroids (means, sds, covar matrices depending on your method) and then allocate pixels to those centroids in your gis. Images are too large for R Agus Edzer Pebesma wrote:
There's a Task View on clustering, linked from CRAN: http://cran.r-project.org/web/views/Cluster.html that will lead you to all types of clustering available, including hierarchical. I don't know how well it will work for large data sets such as images, as it calls for constructing n x n distance matrices, with n the number of pixels. -- Edzer Hengl, T. wrote:
Don't forget that you can also use different types of unsupervised classification methods, such as the fuzzy k-means as implemented in the "kmeans" method. Here is an example (with landform classes): http://spatial-analyst.net/wiki/index.php?title=Analysis_of_DEMs_in_R%2BILWIS/SAGA If you work with large grids, consider also using R+SAGA: https://stat.ethz.ch/pipermail/r-sig-geo/2009-February/005155.html T. Hengl -----Original Message----- From: r-sig-geo-bounces at stat.math.ethz.ch on behalf of Edzer Pebesma Sent: Fri 4/17/2009 5:32 PM To: Corey Sparks Cc: r-sig-geo at stat.math.ethz.ch Subject: Re: [R-sig-Geo] image classification in R Corey, you can use functions lda or qda (in library MASS) for linear or quadratic discriminant analysis, respectively, on your training/ground truth data, and then use the predict method on the resulting objects, passing the bands (you need to convert the SpatialGridDataFrame to a data.frame) as newdata to obtain the classified pixels. Make sure that the band names have identical name in both cases. Then assign the predicted class to the SpatialGridDataFrame and export. It has never been clear to me whether "maximum likelihood classification" in RS refers to lda or qda. Anyway, it's called discriminant analysis in the statistical literature. -- Edzer Corey Sparks wrote:
Dear list, I want to do some unsupervised image classification of some landsat imagery, I think I can read in the multi-band rasters using rgdal, but has anyone tried doing this in R? I am thinking (after looking at documentation for how GRASS and ArcGIS do it) that I need to do an initial hierarchical clustering to define clusters, but does anyone have an idea on how to do a maximum likelihood classification of the imagery? Would a discriminant function approach work? Any advice anyone may have would be greatly appreciated, and i'm very sorry but I don't have a working example yet. Best Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks 'at' utsa.edu
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
------------------------------------------------------------------------
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
<alobolistas.vcf>
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
This may be a stupid question but has anyone tried the unsupervised option in Random Forest for unsupervised image classification? I'm not sure how that would work. Ned
Corey Sparks wrote:
Dear list, I want to do some unsupervised image classification of some landsat imagery, I think I can read in the multi-band rasters using rgdal, but has anyone tried doing this in R? I am thinking (after looking at documentation for how GRASS and ArcGIS do it) that I need to do an initial hierarchical clustering to define clusters, but does anyone have an idea on how to do a maximum likelihood classification of the imagery? Would a discriminant function approach work? Any advice anyone may have would be greatly appreciated, and i'm very sorry but I don't have a working example yet. Best Corey Corey Sparks Assistant Professor Department of Demography and Organization Studies University of Texas at San Antonio One UTSA Circle San Antonio, TX 78249 210 458 6858 corey.sparks 'at' utsa.edu
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo