Google Static Map tile as underlay

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Google Static Map tile as underlay

Callahan-2
Greetings,

I am attempting to write scripts that will accept a watershed basin, a
variable name and value range and then do the following:

   1. open up the appropriate shapefile containing SpatialLines for streams
   in the requested watershed
   2. get the bounding box
   3. use the bounding box to request an appropriate Google static terrain
   map
   4. plot the requested SpatialLines on top of the terrain map

Using the sp, rgdal and RgoogleMaps packages I can get pieces to work but no
the entire thing. I have tried two different approaches without success:

*RgoogleMaps Approach --*

I can use RgoogleMaps to grab an appropriate basemap and then display it
with the PlotOnStaticMap() function. This same function can overlay a set of
points if their coordinates are given as separate longitude and latitude
arrays. But this function does not handle the spatial types defined in the
'sp' package.

*sp/rgdal Approach --*

I can read in the .png file I downloaded with rgdal and display it with
commands like:

siu.png <- GDAL.open("siu_10.png")
displayDataset(siu.png)

But this isn't yet a 'sp' style spatial object that allows for overlays.

If I new how to read my .png file in as a 'sp' style spatial object and plot
it I believe I could transform my SpatialLines objects to the Google grid
using

google.prj <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +
x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"

as described in Tomislav Hengl's Practical Guide to Geostatistical
Mapping<http://www.lulu.com/content/paperback-book/a-practical-guide-to-geostatistical-mapping/8010854>
.

But I'm not quite facile enough with all the tools to achieve my goal.


Does anyone have any example script that does the following?

   1. ingests a Google map tile and shapefile lines or polygons (not points)
   2. creates an image displaying the SpatialLines properly georeferenced on
   top of the map tile


I know that I can generate KML to upload to GoogleMaps/~Earth but we have a
need for automated generation of static images.

Thanks in advance,

Jon

--
Jonathan Callahan, PhD
Mazama Science
206-708-5028
mazamascience.com

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Google Static Map tile as underlay

manuel.schneider
You could try

library(dismo)
library(rgdal)

data(meuse)
coordinates(meuse) <- ~x+y
proj4string(meuse) = CRS("+init=epsg:28992")
gproj <- CRS("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0
+y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs")
e <- extent(bbox(spTransform(meuse,gproj)))
r = gmap(e, type='terrain',exp=1.2)
plot(r, interpolate=F)
points(spTransform(meuse,gproj),pch=16,col=2)

Hth

Manuel

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo