[R-sig-Geo] Manipulate extract output
jm3389
jm3389 at columbia.edu
Sun Apr 24 16:55:41 CEST 2011
Dear All,
I have been struggling to extract individual pixel values from within a set
of polygons.
Mbola.shp <- readOGR(dsn="C:/Users/JOX201S/Desktop/Dropbox/LDSF/Mbola",
"MBSubplot1LULC")
SMA <- raster("C:/Users/JOX201S/Desktop/Dropbox/LDSF/Mbola/SMA-clipped.img")
X <- extract(SMA, Mbola.shp)
then when I display X I obtain a list:
>X
[[1]]
[1] 0.08505697 0.11521957 0.07027940 0.07027940 0.10559745 0.10363697
0.09353689
[8] 0.09353689 0.09673717 0.12536806 0.15696177 0.09306118 0.09353689
0.09673717
[15] 0.09306118 0.09306118 0.09669495
[[2]]
[1] 0.02609529 0.02609529 0.02996226 -0.00057072 0.02159369 0.02159369
[7] 0.04489277 0.02804214 0.02835380 0.06462935 0.06462935 0.02266412
[13] 0.03684234 0.02083779 0.07917891 0.05502048 0.03577228
[[3]]
[1] 0.08705948 0.08705948 0.08622552 0.05902963 0.05902963 0.03294581
0.08919024
[8] 0.10308155 0.10308155 0.04357137 0.06129387 0.18882106 0.15271443
0.15271443
[15] 0.07749587 0.23532785 0.23532785
[[4]]
[1] 0.09554891 0.09314694 0.13511878 0.12017184 0.12056647 0.10497463
0.19552167
[8] 0.19496135 0.10160323 0.09736327 0.12032449 0.18401594 0.13698930
0.09173016
[15] 0.11627619 0.13992140
[[5]]
[1] 0.08130399 0.12848020 0.15129283 0.06018241 0.06018241 0.12764616
0.15831620
[8] 0.16025396 0.07245398 0.07245398 0.08861573 0.15831620 0.16025396
0.07245398
[15] 0.08861573 0.10879661
[[6]]
[1] 0.01403566 0.05509807 0.06573696 0.07086041 0.05806389 0.08060271
0.04586258
[8] 0.04270630 0.07691538 0.06859619 0.08897498 0.06756449 0.04492125
0.04651234
[15] 0.04652581 0.08224432 0.04266668 0.05377325
[[7]]
[1] 0.19860968 0.13489768 0.11530623 0.11530623 0.12832202 0.18902805
0.09427368
[8] 0.08301217 0.08301217 0.11991798 0.18725793 0.19014162 0.14259814
0.14259814
[15] 0.08376002 0.18725793 0.14259814 0.14259814 0.08376002
[[8]]
[1] 0.06091007 0.06091007 0.05323072 0.03962127 0.04709431 0.04709431
[7] 0.05578892 0.06078413 0.03223819 0.02318165 0.02318165 0.04193906
[13] 0.04568461 -0.01365644 0.01866432 0.01866432 0.04833658 0.04675072
[19] 0.04113418 0.04113418 0.03635887
I would like to reshape the list like that:
Pixel value | Polygon
0.08505697 [[1]]
0.11521957 [[1]]
0.07027940 [[1]]
0.07027940 [[1]]
0.10559745 [[1]]
...
I have tried stack, and the reshape package but haven't been able to
manipulate the list.
I am sure it's a very simple function but I've been searching the web for
days now and nothing really works.
Any suggestion?
Thanks
Joseph
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Manipulate-extract-output-tp6301073p6301073.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list