[R] Bubble plot on shapefile - projection issues?
t c
mudiver1200 at yahoo.com
Sat Jan 10 02:58:13 CET 2009
Dear R help list,
I am working on some data from a study on the habitat use and movement patterns of fish using a marine protected area in Hawaii. We have a number of acoustic receivers in a MPA, and any time a tagged fish passes within range it records the date and time of detection. I am trying to make bubble plots showing the number of detections for each fish at each receiver. I have been able to get it to work using a map generated from GSHHS data (Global Self-consistent, Hierarchical, Highresolution Shoreline) but the map data is not of high enough resolution. Instead I am trying to plot the data on a shapefile, but I can't find out how to project the shapefile correctly to match up with the data. I know my shapefile is in NAD 1983 UTM Zone 4N and my data is in WSG84. How do I change the projections to make them line up? I tried mapproj but couldn't get it to work. Any suggestions would be greatly appreciated.
My code is below. I have also attached the shapefile and my data.
Thanks in advance for your help.
Aloha,
Tim
#Read ESRI shapefiles
library(maptools)
library (PBSmapping)
setwd("E:/Telemetry_research/Kealakekua Bay MPA study/R bubble plot")
hawaii.coast<- read.shape("coast_n83.shp")
#Read data and convert to event data
mydat<-read.table("my.event", header=TRUE)
my.event<-as.EventData(mydat,projection="LL")
#Calculate bubble size
detects<-mydat$Detections
max.symbol.size=10
min.symbol.size=1
bubble.size <- (detects-min(detects))/((max(detects)+.0001)-min(detects))*(max.symbol.size-min.symbol.size)+min.symbol.size #Calculates bubble size as a range between min and max. 0.0001 added to avoid division by zero if only one sample.
#Plot of all Hawaiii showing point data somewhere to the south. Needs projcting?
plot(hawaii.coast,xlab="Longitude",ylab="Latitude",main="Kealakekua Bay")
addPoints(my.event, pch=19 ,col="red",cex=500)
#Plot of location where point data should be
plot(hawaii.coast,xlim=c(820000, 824000), ylim=c(2154000, 2158000),xlab="Longitude",ylab="Latitude",main="Kealakekua Bay")
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: my.event
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090109/0c6b5af6/attachment-0003.pl>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: coast_n83.prj
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090109/0c6b5af6/attachment-0004.pl>
More information about the R-help
mailing list