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 8292555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:31:19+00:00 2026-06-08T13:31:19+00:00

History: Extracted raster data from the static Google map png, loaded it on the

  • 0

History: Extracted raster data from the static Google map png, loaded it on the R device through ggimage.

library (png)
library (ggmap)

rasterArray <- readPNG ("My.png")

x = c (40.702147,40.718217,40.711614)
y = c (-74.012318,-74.015794,-73.998284)

myData <- data.frame (x, y)

print (ggimage (rasterArray, fullpage = TRUE, coord_equal = FALSE) 
    + geom_point (aes (x = x, y = y), data = myData, colour = I("green"), 
      size = I(5), fill = NA))

I did run dput on the rasterArray but the output is of 20 MBs, can’t post here.
BTW, this is the URL of that static map:

Question: For plotting “GPS coordinates” on the R device containing the map in pixels, do I need to scale the data.frame?

I saw this page: http://www-personal.umich.edu/~varel/rdatasets/Langren1644.html
Do I need to do scaling the way they have shown here?

If yes, then what else other than the man page of scale function do I need to understand to get this done?

Am I barking at the wrong tree?

  • 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-08T13:31:24+00:00Added an answer on June 8, 2026 at 1:31 pm

    I think your mistake was the following:

    • Trying to plot geographic data on an image, where that image doesn’t have any awareness of the map coordinates
    • Possibly transposing your latitude and longitudes in the data frame

    Here is how you should do it instead, in two steps:

    1. Get the map with get_map() and save it to disk using save()
    2. Plot the data with ggmap()

    First, get the map.

    library (ggmap)
    
    
    # Read map from google maps and save data to file
    
    mapImageData <- get_googlemap(
      c(lon=-74.0087986666667, lat=40.7106593333333), 
      zoom=15
    )
    save(mapImageData, file="savedMap.rda")
    

    Then, in a new session:

    # Start a new session (well, clear the workspace, to be honest)
    
    rm(list=ls())
    
    # Load the saved file
    
    load(file="savedMap.rda")
    
    # Set up some data
    
    myData <- data.frame(
        lat = c (40.702147, 40.718217, 40.711614),
        lon = c (-74.012318, -74.015794, -73.998284)
    )
    
    
    # Plot
    
    ggmap(mapImageData) +
        geom_point(aes(x=lon, y=lat), data=myData, colour="red", size=5)
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

History: I read from one of Knuth's algorithm book that first computers used the
History: I'm using the children method because I'll be looping through div s that
I want to store history data in a sqlite db. a max of 20
I'm trying to put together a command to extract the data from different tables
I have recently extracted a few subdirectories from a shared git repository with git
I would like to be able to get the navigation history from my users
I am looking for a way to extract / scrape data from Word files
I am building application that required some data from iPhone's Call log(read only). The
I'm trying to programmatically extract some data from this url: http://www.treasurydirect.gov/NP/BPDLogin?application=np The issue is
HISTORY: A system has passed through 1 - 19 or so statuses before being

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.