Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8352171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:53:23+00:00 2026-06-09T08:53:23+00:00

I am trying to superimpose an image to a world map. This is may

  • 0

I am trying to superimpose an image to a world map. This is may code

   require(reshape)
   require(mapdata)
   df <- read.table('year.dat',head=F)
   names(df) <- c("value", "x", "y", "t")
   dfc <- cast(df[ ,-4], x ~ y)
   filled.contour(as.matrix(dfc),color.palette = colorRampPalette(c("lightblue",       "blue","violet", "black")),
   xlab = "Longitude (°)", ylab = "Latitude (°)",
   xlim = c(0, 360), ylim = c(-90, 90), 
   nlevels = 25,
   plot.axes = {axis(1); axis(2);           
   map('world2Hires', 
   xlim = c(0, 360), 
   ylim = c(-90, 90), 
   add = T, col = "darkgrey")}
   )

the data contained in the file “year.dat” are in the form

 0.35217720               1         201           1
 0.26413283               1         209           1
 1.1665874                1         210           1
 ...
 0.30815500               2         194           1
 0.15407741               2         196           1
 0.15407741               2         197           1
 0.33016610               2         205           1
 ...

where the first column is scalar value, the second column is a longitude index, third column is the latitude index and the fourth column is time index. Namely the row

 0.35217720               1         1           1

means that at time 1, in the coordinate -90° N, 0° E we have the value 0.35217720. The whole lattice contains 480×241 points.
The problem is the following, if i try to execute the previous code in R, the world map and the bar legend are drown but no colours are superimposed. If i comment the line

#xlim = c(0, 360), ylim = c(-90, 90),

then the image well coloured is drawn but no world map is present. So i tried different limits in xlim and ylim and indeed the problem is the scale of the input matrix. Namely R take the input range from 0 to 1 for both axes while actually they goes from 0 to 360 and 0 to 180. In which way can i tell R that the input scale goes from 0 to 360 for x axes and from 0 to 180 for y axes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:53:24+00:00Added an answer on June 9, 2026 at 8:53 am

    The solution is:

    require(reshape) 
    require(mapdata)
    require(mapproj)
    df <- read.table('year.dat',head=F)
    names(df) <- c("value", "x", "y", "t")
    dfc <- cast(df[ ,-4], x ~ y)
    mm<-as.matrix(dfc,ncol=480,nrow=241)
    #pdf('mappamondo.pdf')
     filled.contour(x=seq(0,360,length.out=480),y=seq(-90,90,length.out=241),mm,color.palette = colorRampPalette(c("lightblue", "blue","violet", "black")),
    xlab = "Longitude (°)", ylab = "Latitude (°)",
    plot.axes = {axis(1); axis(2);          
    map('world2Hires',
    xlim = c(0, 360), 
    ylim = c(-90, 90), 
    add = T, col = "black")}
    )
    
    #dev.off()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to launch and pass tel. no. to skype by this code from my
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
Trying to figure out how I can do this properly. The print_r looks like
trying to figure out why this is happening - I have an input text
Trying to read registry keys remotly (from a host on local intranet)... All the
Trying to figure out how to read in multiple variables through a file. for
Trying to do this, but is it wrong? Below is my style and script
Trying to find some information on this but am unable to get any results
Trying to do a simple insert, and this one line is giving me issues.
Trying to merge 8 pre-sorted arrays. I'm fairly new to C, but this is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.