Displaying 20 results from an estimated 400 matches similar to: "R matching lat/lon pairs from two datasets?"
2008 Oct 30
3
Save a function existing library
Hello all,
I am fairly new to R and I have created a function that I use quit
frequently. I was wondering if there is away to save this function in
an existing library so I can call it by using the function name once the
library is loaded?
Thanks,
Doug
--
---------------------------------
Douglas M. Hultstrand, MS
Senior Hydrometeorologist
Metstat, Inc. Windsor, Colorado
voice:
2011 Apr 12
1
How to set the dimension of a matrix correctly?
Hi all,
I use kriging to interpolate the precipitation from stations, but the map of this results show lots of stripes. (please see the attachment)I think there's something wrong with the setting of the dimension of this matrix, however, I have no idea how to know or test to see if this setting is correct or not.I've tried to switch the latitude and longitude, but still got the same
2010 Jun 23
2
Unique Data Frame Name?
Hello,
I am trying to create a data frame with a unique name, based on indexing
of for loop. I was wondering if there is a way to do this, I keep
running into errors when I try to do this. Below is a brief example, I
am trying to get two data frames (name1 and name2).
Any suggestions are appreciated.
Thanks,
Doug
# Example
for (i in 1:2) {
x=c(1,2,3,4)
y=c(10,20,30,40)
2010 Feb 04
3
Legend symbol?
Hello,
I am creating a plot/image using different data and a couple fit lines
(see attached image). In the legend, I want the Default and Exponential
symbol to be a line. I am using the pch command, I tried to use "-" to
represent a line but does not work so I currently have set as a "1".
Any thoughts or suggestions would be greatly appreciated.
Below are the commands
2010 Jun 28
3
data frame row statistics (mean)?
Hello,
I am trying to calculate the mean value of each row in a data frame (d),
I am having troubles and getting errors using the code I have written.
Below is a brief example of the code, any thought or suggestions would
be great.
Thank you for your time,
Doug
# Example Code:
d <- data.frame(st1=c(1,2,3,4), st2=c(2,5,6,7), st3=c(5,5,NA,7),
st4=c(6,5,7,8))
avg <-
2009 Dec 01
3
paste name in for loop?
Hello,
I am trying to create subsets of grouped data (by area size), and use
the area size as part of the output name. The code below works for area
(xout) 1 and 50, the other files are given NA for an area.
A simple example:
xout <- c(1,5,10,25,50,100)
for(i in xout) { print(paste("Areal_Ppt_",xout[i],"sqmi.txt", sep="")) }
[1] "Areal_Ppt_1sqmi.txt"
2009 Oct 15
2
Data frame search and remove questions
Hello,
I have a couple questions about removing rows from a data frame and
creating a new data frame with the removed values. I provided an
example data frame (d) below.
Questions:
1) How can I search for "-999.000" and remove the entire row from data
frame "d"? (all -999 values will be in sd_diff)
2) Can I create a new data frame "d.new" that only contains the
2018 May 20
1
How to average values from grid cells with coordinates
Hi lily,
It's not too hard to do it using dataframes. Getting the indexing
right is usually that hardest part:
# these values are the centers of the black cells
lat<-rep(28:38,11)
lon<-rep(98:108,each=11)
pop<-sample(80:200,121)
# just use the data.frame function
blackcells<-data.frame(lat=lat,lon=lon,pop=pop)
plot(0,type="n",xlim=c(97.5,108.5),ylim=c(27.5,38.5),
2010 Jan 20
2
Plot frame border to start at zero?
Hello,
I am creating plots of hourly precipitation and accumulated
precipitation (on different axis, see attached image). I was wondering
how can I have the plot frame (black border) start at zero, it looks
like it is plotted less than zero?
The code I use to create the png files is below:
CairoPNG(PNG_file,width=1000, height=600, pointsize=14, bg="white")
opar <-
2008 May 20
3
R for loop question
Hello,
I am trying to assign a variable name (x1,x2,x3...) in a loop statement
that is based on a counter (counter is based on the number of hours
within the datafile). The x1,x2 data will later be called for plotting
the data. Below is a clip of the for loop I am using, any suggestions?
k = 1
for (i in 1:length(stats$hour)) {
"x(i)" = dataset[k,(3:15)]
k = k+1
}
Thanks,
2009 Oct 22
1
Cairo package, png files within for loop are black?
Hello,
I am generating .png images using the Cairo package in a for loop
(looping on the number of zones, number of zones equals the number of
plots to create based on different zone data). When I run the R
script the .png files are created but they are all black? If I comment
out the for loop and force my zones to equal one the png file is created
correctly? Is there an issue with
2011 Jan 20
1
Generating time progressing line for Google Earth
Dear,
I am trying to visualise a time-progressing line (it's supposed to
represent spread patterns) using brew package and Google Earth.
The idea is to have a function which takes start and end point
geographic coordinates, as well as number of intervals to chop the path
up, and returns the collection of points segmenting this line.
Unfortunately my calculations fail for large distances,
2009 Nov 13
2
data frame subsets?
Hello,
I am trying to create data frame subsets based on binned temperature
data. I have code working to create the bins (d.1 and d.2), but it
takes two steps, I was wondering if I could merge into one step. See Below
d
n year mo da hr t td tw rh kPa
1 1 1945 3 1 0 1.1 0.0 0.6 92 101.7
2 2 1945 3 1 1 2.8 -1.1 1.1 76 101.8
3 3 1945 3 1 2 2.2 -1.7 0.6 75 101.9
4 4
2018 May 22
0
How to average values from grid cells with coordinates
Hi Jim,
Thanks. It works. I now have more complex problems. If at each blackcell,
there are two variables such as pop and mood. For each variable, there are
daily records in one year, so 365 records for pop and 365 records for mood.
The averaged values for the redcells should be daily records too. What kind
of format do you recommend for this problem? Right now, I just get the
latitudes and
2010 Jun 14
1
Times series data file?
Hello,
I currently splitting a file into individual files (time series each
separated into one file), the file I read in skips the first four lines
and extracts the data columns I need. I was wondering if there is a way
for R to automatically scan and separate the files based on the head
information?
The header delineates the observation with a 254 space time space day
space month space
2009 Sep 01
1
Read multiple files into dataframe?
Hello,
I am fairly new to R programming and am stuck with the following problem.
I am trying to read in multiple files (see attached file or at end of
email), the files all have the same general header information and
different precipitation (avgppt) and area (areasqmi) values. Some times
the number of records are different in the files.
I want to read in all files (.stdsummary), and create
2010 Jul 23
1
Midpoint between coordinates
Dear R users,
I need to find the coordinates for the point (midpoint) located half
way between two pairs of coordinates (lon1,lat1 and lon2,lat2)
assuming a straight line between them. What would be the best way? I
tried to find an answer in the help archives but without success. I
would greatly appreciate any help.
df<- data.frame(lon1=c(-4.568,-4.3980), lat1=c(59.235,56.369),
2009 Mar 24
3
Display Equation on plot
Hello,
I am using the lm to fit a linear model to data, I was wondering if
there is a way to display the equation on a plot using the extracted lm
coefficients? I am using the plot() function to create the plot/.png.
Example:
lm_mod <- lm(data1~data2)
intercept = 48.54
slope = 0.4856
I want to display equation on a plot as y=0.4856x+48.54
Any thoughts or suggestions are appreciated.
2007 Oct 30
2
calculate spatial distance
Hi,
I have a set of locations defined by longitude and latitude (in degrees),
and want to calculate the spatial (or geographic) distance among all
locations.
I did not find such a function in the spatial-related packages. (I *cannot*
use 'dist', as I have geographic, not cartesian coordinates).
thanks!
Robert
Robert Ptacnik
Norwegian Institute for Water Research (NIVA)
Gaustadall?en 21
2013 Jan 29
2
Netcdf and Raster Package Questions, Need .asc File for GIS
Hello R-Group,
I am new working with netcdf files and the raster package in R.I am
trying to read in a netcdf file using the package "ncdf".I am able to
get the lat, lon and parameter I need and can plot using
fill.contour.Ultimately, I am trying to create a .asc file to reafd into
GIS.I am using the package "raster" to read the parameter.When I read in
with