3

I'm looking to download the bathymetry of the Northwest Atlantic ocean as a txt file or any other file format that I can easily upload and use in R.

I once used the Global topography - Scripps Institution of Oceanography but it looks like I'm running into an error message this time...?

I have been looking at other websites, but I'm having a hard time to locate a new site where I could download a xyz file of my area of interest.

I would appreciate any recommendations. Thank you very much in advance,

  • What exactly is the error message? (A quick check shows that page is returning a fixed-field ASCII file, which is straightforward to read in R.) – whuber Apr 23 '12 at 20:05
5

Upon requesting "topography" for longitudes between -30 and -24 degrees and latitudes between 54 and 60 degrees, I noticed the file contained three columns, for longitude, latitude, and elevation, apparently in an XYZ ASCII output arrangement (totaling 239,704 lines). After the page was saved in ASCII text format, it could be read and processed in R:

x <- read.table("f:/temp/bathy.txt", header=FALSE)   # Read the data into an array
names(x) <- c("lon", "lat", "z")                     # Provide meaningful column names
nrows <- length(levels(as.factor(x$lon)))            # Count distinct longitudes
library(raster)                                      # Load the 'raster' library
z <- raster(matrix(x$z, nrow=nrows), xmn=min(x$lon), 
    xmx=max(x$lon), ymn=min(x$lat), ymx=max(x$lat))  # Create a raster from the array
plot(z)                                              # Plot it

Bathymetry

That's the Reykjanes Ridge in the upper left and part of the Eriador Seamount near the lower right, where they should be.

  • Thank you @whuber. Not quiet sure what was the bug this morning but I managed to download the file without any problem! Thanks for sharing your raster code, I've never used it until now. It's great! P.S Have you used the new geom_raster in ggplot2? – GodinA Apr 23 '12 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.