[R-sig-Geo] import a jpg/etc. map into R?

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Tue Sep 13 19:09:33 CEST 2011


On Tue, Sep 13, 2011 at 11:33 AM, Malcolm Fairbrother
<m.fairbrother at bristol.ac.uk> wrote:
> Dear all,
>
> The answer may well be 'no', but does anyone know of a straightforward way to import into R a map in the form of a simple jpeg (or bmp, gif, etc.) image file?

 Straightforward? No!


> . What I'd like to do is read in this kind of file, have R find the edges (identified somehow by differences in pixel colours I guess), and convert the areas defined by those edges into a SpatialPolygons object, with lat/long coordinates.

 Edge-finding is hard - the 1492 map has rivers and text and things to
trap you. You'd have to mask the colours and then do some clever
erosion thing that might take out all the black. Still leaves you with
a raster image though, which you then have to vectorise...

> There may well be no easy way to do this (or not even a difficult way), but I thought I'd check if anyone has any ideas. I prefer to use R, but if some other (preferably open source) software could help me, I'd be interested to know. Even suggestions like "IF you could get it into X format, THEN you could…" might be useful. I'm not a GIS person, unfortunately. On the other hand, I am pretty handy with R, and a regular user of several of the maps/spatial/raster packages.

 I've just used Quantum GIS (open-source GIS package) to warp the
image and register it to a lat-long map data file.

 QGIS has a georeferencer plugin - you load the image and then click
on the points with known lat-long (you can use your graticule
intersections, or well-known features). Then tell it to warp and
assign coordinates.

 Again this gives you a georeferenced _raster_ which might be no good
to you, but at least then you can put known geographic points on top
of it.

 If you really want a vector shapefile of fairly simple boundaries, it
might be quicker to digitise it using QGIS - you can georeference the
raster and click over it to create the polygons. However it would be
very very useful to know the original projection - for the 1492 map my
money is on some kind of Lambert conical..

Barry



More information about the R-sig-Geo mailing list