[R-sig-Geo] Interactive maps
Antonio Serrano
aasdelat at aim.com
Mon May 4 14:41:30 CEST 2015
Hi:
Thank you Barry. Your solution is adequate for my problem.
My map is divided in rectangles which sides are measured in degrees (longitude and latitude), not km. Each rectangle (and not each pixel) is associated with more information that has to be located, porcessed and presented to the user when he clicks in a rectangle.
I will try it.
Thank you very much.
Antonio Serrano
aasdelat at aim.com
ن
-----Original Message-----
From: Barry Rowlingson <b.rowlingson at lancaster.ac.uk>
To: Antonio Serrano <aasdelat at aim.com>
Cc: r-sig-geo <r-sig-geo at r-project.org>
Sent: Wed, Apr 29, 2015 5:02 pm
Subject: Re: [R-sig-Geo] Interactive maps
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
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list