[R-sig-Geo] Interactive maps

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Apr 29 17:02:03 CEST 2015


On Wed, Apr 29, 2015 at 2:36 PM, Antonio Serrano via R-sig-Geo
<r-sig-geo at r-project.org> wrote:

I suspect we may need some clarification...

>     I have a map which has been produced by a Fortran program. I have the sources of this Fortran program and can produce the map in many formats: eps, ps, png, jpeg, svg, etc.

 So the "map" is an image file, and every pixel is the same
rectangular (not necessarily square) size in degrees of latitude and
longitude? And you know those coordinates? Or equivalently you know
the limits of the map in lat-long and how many pixels it is?

>     And the point is: what format and metainformation has to have the map to be correctly read by R and to retrieve longitude and latitude when the user clicks, and not "figure" coordinates?.
>
>     I am thinking on inoculating some metainformation into the map, from the fortran program, and read and interpret it from R, but there is perhaps a more "correct" way to do this.

You can georeference any image by creating a companion "world" file.
This is usually the image file with a "w" on the extension, so the
world file for foo.png is foo.pngw. Details of the world file format
are in various places, try here:

https://en.wikipedia.org/wiki/World_file

Its a simple text file with only a few lines.

Once you have created that, then the image and its world file make up
a GDAL-compatible raster data source. Which means you can read it in
once you have the `raster` and `rgdal` packages installed, and its
location is known. When you plot it, it will plot at that location,
and if you do locator(type="p") and click somewhere you will get a
returned value in the image's geographic coordinates system.

The big problem will be if the assumptions I mention above are not
true. If you have a grid of 100km squares, then those grid cells have
different sizes in degrees as you go north-south. If that's not the
case then the above will work fine.

Barry




>
> Antonio Serrano
> aasdelat at aim.com
> ن
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list