Hi, What are the columns in sat.mat?
I can see that, sat.mat[,1:2] are longitude and latitude in some form but we don't even know what dim(sat.mat)[2] is from what you've shown. You can avoid the loops (untested): asub <- sat.mat[,1] >= long.min & sat.mat[,1] <= long.max & sat.mat[,2] >= lat.min & sat.mat[,2] <= lat.max tempo <- sat.mat[asub, ] Note that you don't need to equate to TRUE, and & is vectorized. Your process would have needed to zap out rows with values of zero in tempo[,1:2] but since your longitude range straddles longitude 0 you might have a problem there. ## basic plot plot(tempo[,1:2], pch = ".") Using other columns you can control the plot colours and symbols, and there is higher-level support for these idioms in the packages you load but haven't use. Check out R-Sig-Geo in future as a list relevant to this topic. When posting include examples relevant only to your question, and recreate or point to example data. Are the data gridded? If so I'd be going to the provider for a sensible format and avoid this raw table thing completely. If you can't get that use the tools in the Spatial suite to sort it out and streamline first. Cheers, Mike. On Wed, Apr 2, 2014 at 4:23 AM, Dao_De <z...@gmx.de> wrote: > I want to read the following file with and extract the longitude and latitude > for certain areas. > The file is satellite data from topex and contains the monthly wave energy > fluxes around the worlds oceans. > > > For doing that i have the following loop that reads the specific data. > > I then want to create a worldmap/the specific region for example the baltic > sea or whatever, that shows the the wave energy. Also i want to plot the > averages and the trend for the wave energy and eventually calcualte a slope > for the wave energy over time. > > > > > I got the following loop > > > > > library(sp) > library(maptools) > library(maps) > library(rgdal) > library(shape) > library(mapdata) > > # "pow_sat_file.txt" > > inputpath1<-"/Users/Sam/Desktop/MER/rem/" > inputfile1<-paste(inputpath1,"pow_sat_file.txt",sep="") > > sat<-read.table("pow_sat_file.txt",header=TRUE, sep="",nrow=-1) > sat.mat<-as.data.frame(sat) > > dims<-dim(sat.mat) > tempo<-matrix(0, nrow=dims[1], ncol=dims[2]) > tempo<-data.frame(tempo) > date<-seq(as.Date("1993/1/1"), as.Date("2005/10/1"), by="month") > > # France coordinates > long.min<--6 > long.max<-10 > lat.min<-40 > lat.max<-52 > > #Loop on "pow_sat_file.txt" to only keep the interesting points > for (i in 1:dims[1]){ > long<-sat.mat[i,1] > lat<-sat.mat[i,2] > if (((long>=-6 && long<=10)==TRUE ) && ((lat>=40 && lat<=52))==TRUE){ > tempo[i,1]<-long > tempo[i,2]<-lat > for (j in 3:dims[2]){ > tempo[i,j]<-sat.mat[i,j] > } > } > } > > > How do i continue from here to get a map of the specific region and a slope? > > Thx in advance > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Plotting-Satellite-tp4687971.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Software and Database Engineer Australian Antarctic Division Hobart, Australia e-mail: mdsum...@gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.