Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top,New+York,NY&zoom=13&size=600x300&maptype=roadmap&markers=color:blue%7Clabel:S%7C40.702147,-74.015794&markers=color:green%7Clabel:G%7C40.711614,-74.012318&markers=color:red%7Ccolor:red%7Clabel:C%7C40.718217,-73.998284&sensor=false

shows a static map which is a png file.

If I do have a coordinate which lies between the coordinates of this static map file, then how should I plot that point on this map (which is basically a png)?


I would be doing it offline. Can't use the maps API. Will save that map as a PNG, then I have to plot the points.

share|improve this question

Check the API here:

Example,Brooklyn,NY&zoom=13&size=400x400& markers=color:blue%7Clabel:S%7C11211%7C11206%7C11222&sensor=true_or_false

share|improve this answer
Sorry, my fault. I should have mentioned that I would be doing it offline. Can't use the maps API. – TheIndependentAquarius Jul 13 '12 at 9:09
@AnishaKaul According to s 10(1)(3), what you're trying to do is against the TOS. The answer i've suggested is the only way you can legally make it happen. Otherwise, I'd suggest using OSM. – nagytech Jul 13 '12 at 9:27
The TOS says "except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation if you do so temporarily, securely, and in a manner that does not permit use of the Content outside of the Service;" Is that still illegal? – TheIndependentAquarius Jul 13 '12 at 9:30
@AnishaKaul Prefetching / Caching is not the issue. The subsection above that 10(1)(3)(i) explicitly states that the modification of tiles (ie. creating derivative works) is not permitted. I would be happy to help you otherwise, possibly with the use of GD or ImageMagik. Open Street Map would most likely permit you to do this if you followed the proper attribution methods. I'm not sure, however, how much OSM data is available for where your project is. – nagytech Jul 13 '12 at 9:41
Okay, I didn't read that. Sorry. BTW, now you mentioned ImageMagik, I found on search a library named "R":… that may not be legal but is that practical ? – TheIndependentAquarius Jul 13 '12 at 10:16

Another alternative (avoiding the TOS issue) would be to use OSM (as suggested by Geoist). That would be really simple, because you can easily work a position / offset position to a pixel offset into the image using the formula given at

You could still use PIL as I suggested in my other (proposed) answer.

share|improve this answer

Use gdal to build the right Transform (conversion from coordinate to pixel), and then add the icon to the pixel point. tells you how to build the transformation.

You can add the icon using many methods, including something like PIL., look for the paste() method.

share|improve this answer
For that you would have to know the exact tile level, and image scale which you aren't necessarily provided unless you specify it explicitly, and explicitly specifying it will not give you the best field of view. Not to mention, you left out how to actually add the icon to the pixel point. – nagytech Jul 13 '12 at 9:47
The tile level is in the URL. – BradHards Jul 13 '12 at 10:31
Indeed it is, because the user specified it. Read my comment more carefully. – nagytech Jul 13 '12 at 11:04
I don't understand your issue. You'll always have either a position and zoom level or geo-extent. Am I missing something? – BradHards Jul 13 '12 at 22:41
up vote 0 down vote accepted

The way to do this in R is as follows:

library (RgoogleMaps)
png (filename = "plotted.png", width=480, height=480)

lat    = c(40.702147,40.718217,40.711614)
lon    = c(-74.012318,-74.015794,-73.998284)
center = c(mean(lat), mean(lon))
zoom <- min (MaxZoom (range(lat), range(lon)))

MyMap <- GetMap (center   = center, 
                 zoom     = zoom,     
                 markers  = '&40.702147,-74.015794,blues%7C40.711614,-74.012318,greeng%7C40.718217,-73.998284,redc', 
                 destfile = 'original.png');

tmp <- PlotOnStaticMap (MyMap, 
                        lat = c(40.702147, 40.711614, 40.718217), 
                        lon = c(-74.015794,-74.012318,-73.998284), 
                        cex = 1.5, 
                        pch = 20, 
                        col = c('red', 'blue', 'green'), 
                        add = F)

To compile the above R code in C++, R has provided a package named RInside:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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