tychoStack<-stack(raster(x = '../../../ds9Tycho/ds9.jpeg',1), raster(x = '../../../ds9Tycho/ds9.jpeg',2), raster(x = '../../../ds9Tycho/ds9.jpeg',3))
levelplot(tychoStack)
Just messing around with some raster analysis of a tiff of Tycho. Since this is just messing around, Im initally only interested in Band 3.
levelplot(tychoStack[[3]])
hist(tychoStack[[3]])
## Warning in .hist1(x, maxpixels = maxpixels, main = main, plot = plot, ...):
## 79% of the raster cells were used. 100000 values used.
Explo plot for the distribution of values. Log scale because there are 60415 0’s.
valuesTycho<-as.data.frame(table(as.matrix(tychoStack[[3]])))
names(valuesTycho)<-c('val','count')
ggplot(valuesTycho)+aes(x=val, y=log(count), group=count)+geom_point(size=1) + preferedTheme + stripChartTitles
What if i just remove the 0’s and take the value?
tych<-valuesTycho[valuesTycho$val!=0,]
tych$val<-as.numeric(as.character(tych$val))
tych$count<-as.numeric(as.character(tych$count))
plt<-ggplot(tych)+aes(x=val, y=count, group=count)+geom_point(size=1)
plt<-plt + geom_hline(aes(median(as.numeric(as.character(tych$count)))))
plt + preferedTheme + stripChartTitles
ggplot(tych)+aes(x=val, y=count, group=count)+geom_bar(stat='identity') + preferedTheme
## Warning in loop_apply(n, do.ply): position_stack requires constant width:
## output may be incorrect
Lower the resolution by quite a bit.
tycho<-tychoStack[[3]]
tycho<-matrix(as.matrix(tycho), ncol=dim(tycho)[2])
levelplot(tycho)
tychoDF<-as.data.frame(tycho)
First i need to get this into a numeric matrix. Also added a df for convienicnet.
I also want to look at the rows value. Im expecting something normal-ish.
tychoSumDF<-cbind(1:357, as.data.frame(rowSums(tychoDF)))
names(tychoSumDF)<-c('x','y')
tychoSumQuantile<-data.frame('x'=quantile(rowSums(tychoDF)))
plt<-ggplot(tychoSumDF) + geom_line(aes(x=x, y=y))
plt
longTycho<-melt(tycho)
names(longTycho)<-c('x', 'y', 'val')
head(longTycho)
## x y val
## 1 1 1 0
## 2 2 1 0
## 3 3 1 0
## 4 4 1 0
## 5 5 1 0
## 6 6 1 0
longTycho$res1<-as.numeric(as.character(cut(x = longTycho$val, breaks=5, labels=FALSE)))
hist(longTycho$res1)
Full resolution Contour
ggplot(longTycho)+aes(x=x, y=y, z=val) + geom_contour()
1/5 resolution Contour
ggplot(longTycho)+aes(x=x, y=y, z=res1) + geom_contour()
All Together now.
ggplot(longTycho)+aes(x=x, y=y) + geom_contour(aes(z=val), alpha=.5) + geom_contour(aes(z=res1), colour='red', alpha=.5)+stripChartJunk
No real need for 3d, forgot to specify and just kind of liked the image. Now for what i actually meant in the first place.
ggplot(longTycho)+aes(x=x) + geom_tile(aes(y=res1, colour=factor(val)),alpha=.7) + stripChartJunk
ggplot(longTycho)+aes(x=x) + geom_tile(aes(y=val, colour=factor(res1)),alpha=.7) +stripChartJunk
Fill instead of Colour
ggplot(longTycho)+aes(x=x) + geom_tile(aes(y=res1, fill=factor(val)),alpha=.7) +stripChartJunk
ggplot(longTycho)+aes(x=x) + geom_tile(aes(y=val, fill=factor(res1)),alpha=.7) +stripChartJunk