Dear all, I am wondering what is the safest way to handle colors when SpatialGridDataFrame data are categories. spplot() or image() are extremely convenient when attributes are continuous variables or so (eg altitude, rainfall, etc...), but the colorRamp() system and the col.regions, col arguments, though extremely powerful in other cases, is not really adapted to category data such as Corine LandCover or Global Land Cover 2000 codes. Thus to link pixels to the right color may be quite tedious (however I may have missed something...). One option I though about was to change raster into shapefile (or SpatialGrid into SpatialPolygons objects), but again the straight way to get right colors is not evident. Any idea ? Patrick
color category SpatialGridDataFrame SpatialPolygonsDataFrame Corine Land Cover Global Land Cover 2000
6 messages · Patrick Giraudoux, Renaud Lancelot
Dear Patrick, I recently met this issue. I finally used image() on the SpatialGridDataFrame, defining the appropriate colors using the col argument (?tonnant, non ;-)). I have defined the legend using legend(), and I used split.screen() to arrange the plots. If you wish, I can send you the whole stuff (data and code) in a private message (huge datasets). Renaud Patrick Giraudoux a ?crit :
Dear all, I am wondering what is the safest way to handle colors when SpatialGridDataFrame data are categories. spplot() or image() are extremely convenient when attributes are continuous variables or so (eg altitude, rainfall, etc...), but the colorRamp() system and the col.regions, col arguments, though extremely powerful in other cases, is not really adapted to category data such as Corine LandCover or Global Land Cover 2000 codes. Thus to link pixels to the right color may be quite tedious (however I may have missed something...). One option I though about was to change raster into shapefile (or SpatialGrid into SpatialPolygons objects), but again the straight way to get right colors is not evident. Any idea ? Patrick
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Renaud Lancelot EDEN Project, coordinator http://www.eden-fp6project.net/ << EDEN International Conference, Montpellier, 10-12 May 2010 >> << http://international-conference2010.eden-fp6project.net/ >> UMR CIRAD-INRA "Contr?le des maladies animales exotiques et ?mergentes" Joint research unit "Control of emerging and exotic animal diseases" CIRAD, Campus International de Baillarguet TA A-DIR / B F34398 Montpellier http://www.cirad.fr http://bluetongue.cirad.fr/ Tel. +33 4 67 59 37 17 - Fax +33 4 67 59 37 95 Secr. +33 4 67 59 37 37 - Cell. +33 6 77 52 08 69
Renaud Lancelot a ?crit :
Dear Patrick, I recently met this issue. I finally used image() on the SpatialGridDataFrame, defining the appropriate colors using the col argument (?tonnant, non ;-)). I have defined the legend using legend(), and I used split.screen() to arrange the plots.
It was my point. In this case, you must have defined many breakpoints (to create appropriate intervals for each code) to get all the codes at the right color, which is quite tedious, isn't it ? I wonder if this can be simplified. Ideally importing a color table. Maybe a new function to write (thus to put on the many pending "to do").
If you wish, I can send you the whole stuff (data and code) in a private message (huge datasets).
I appreciate the proposal, but I was just interested in some general principles and advise... Have a nice evening... Cheers, Patrick
Renaud Patrick Giraudoux a ?crit :
Dear all, I am wondering what is the safest way to handle colors when SpatialGridDataFrame data are categories. spplot() or image() are extremely convenient when attributes are continuous variables or so (eg altitude, rainfall, etc...), but the colorRamp() system and the col.regions, col arguments, though extremely powerful in other cases, is not really adapted to category data such as Corine LandCover or Global Land Cover 2000 codes. Thus to link pixels to the right color may be quite tedious (however I may have missed something...). One option I though about was to change raster into shapefile (or SpatialGrid into SpatialPolygons objects), but again the straight way to get right colors is not evident. Any idea ? Patrick
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Patrick Giraudoux a ?crit :
Renaud Lancelot a ?crit :
Dear Patrick, I recently met this issue. I finally used image() on the SpatialGridDataFrame, defining the appropriate colors using the col argument (?tonnant, non ;-)). I have defined the legend using legend(), and I used split.screen() to arrange the plots.
It was my point. In this case, you must have defined many breakpoints (to create appropriate intervals for each code) to get all the codes at the right color, which is quite tedious, isn't it ? I wonder if this can be simplified. Ideally importing a color table.
Indeed, that's what I did (the color table was stored in a dbf file). Happy new year ! Renaud
Renaud Lancelot EDEN Project, coordinator http://www.eden-fp6project.net/ << EDEN International Conference, Montpellier, 10-12 May 2010 >> << http://international-conference2010.eden-fp6project.net/ >> UMR CIRAD-INRA "Contr?le des maladies animales exotiques et ?mergentes" Joint research unit "Control of emerging and exotic animal diseases" CIRAD, Campus International de Baillarguet TA A-DIR / B F34398 Montpellier http://www.cirad.fr http://bluetongue.cirad.fr/ Tel. +33 4 67 59 37 17 - Fax +33 4 67 59 37 95 Secr. +33 4 67 59 37 37 - Cell. +33 6 77 52 08 69
Patrick Giraudoux a ?crit :
Renaud Lancelot a ?crit :
Dear Patrick, I recently met this issue. I finally used image() on the SpatialGridDataFrame, defining the appropriate colors using the col argument (?tonnant, non ;-)). I have defined the legend using legend(), and I used split.screen() to arrange the plots.
It was my point. In this case, you must have defined many breakpoints (to create appropriate intervals for each code) to get all the codes at the right color, which is quite tedious, isn't it ? I wonder if this can be simplified. Ideally importing a color table. Maybe a new function to write (thus to put on the many pending "to do").
PS: by the way if you connect to http://pagesperso-orange.fr/giraudoux/, you can download an unofficial package 'pgirbric' (when I am sure things work well I move them to pgirmess). I have written some functions (based on splancs and sp) to extract info from rasters using buffer centred on points or polygons. A quite common business in my field of ecology but with no programmes (to my knowledge) doing it easy. The latest one are on the development version (I had quite busy Xmas vacation playing on Alevolar echinococcosis distribution in China). Cheers, Patrick
Patrick Giraudoux a ?crit :
Renaud Lancelot a ?crit :
Dear Patrick, I recently met this issue. I finally used image() on the SpatialGridDataFrame, defining the appropriate colors using the col argument (?tonnant, non ;-)). I have defined the legend using legend(), and I used split.screen() to arrange the plots.
It was my point. In this case, you must have defined many breakpoints (to create appropriate intervals for each code) to get all the codes at the right color, which is quite tedious, isn't it ? I wonder if this can be simplified. Ideally importing a color table. Maybe a new function to write (thus to put on the many pending "to do").
PS: by the way, Renaud, if you connect to http://pagesperso-orange.fr/giraudoux/, you can download an unofficial package 'pgirbric' (when I am sure things work well I move them to pgirmess). I have written some functions (based on splancs and sp) to extract info from rasters using buffer centred on points or polygons. A quite common business in my field of ecology but with no programmes (to my knowledge) doing it easy. The latest functions are on the development version pgirbric 1.1.4 (I had quite busy Xmas vacation playing on Alevolar echinococcosis distribution in China). Feed-back and suggestions appreciated if they are usable to your own work. sp, splancs, maptools, spdep, rgdal, etc... are really great things ! GRASS and QGIS also. Cheers, Patrick