[R-sig-Geo] Save plot as Geotiff

Arnaud Mosnier a.mosnier at gmail.com
Wed Feb 7 17:07:46 CET 2018


Thanks Barry. That's a good idea that I may use/test if there is no other
option (I hope another one exists! :-) )

Arnaud

2018-02-07 11:00 GMT-05:00 Barry Rowlingson <b.rowlingson at lancaster.ac.uk>:

> I'd do this by saving the image on the graphics device as a PNG, then
> creating a "world" file (with extension PNGW) from the coordinates of the
> corners and the resolution of the PNG. This is a six line text file with
> sufficient information to georeference a grid. That's enough for `gdal` to
> understand it, and then the `gdal` utilities can convert it to a GeoTIFF
> (or load into R using `raster` and then save as a GeoTIFF).
>
> The tricky bit might be finding the corner coordinates of the graphics
> device image. This is complicated by R leaving space for margins, or not
> using your coordinate system.
>
>  If this is a base graphics plot using the coordinate system units then
> you can probably get them via some combination of the par() values, or you
> might have set the margins to zero and that gives you the corners from
> par()$usr (I think).
>
>  If its grid graphics (like spplot) then.... uhhh. someone else probably
> knows how to do it.
>
> Barry
>
>
> On Wed, Feb 7, 2018 at 3:07 PM, Arnaud Mosnier <a.mosnier at gmail.com>
> wrote:
>
>> Hi,
>>
>> Long version:
>> I made a plot (a map) including SpatialPolygons representing the coast of
>> my region of interest, and a SpatialPointsDataframe representing locations
>> of cities, and I want to save this map in GeoTiff format to allow other
>> people to use this map as a georeferenced background without having to
>> manage the various data sources. Is there a package/function in R that
>> would allow me to do that?
>> Note that converting the Spatial* objects to the raster format is not an
>> option because I want to be able to see the names of the cities on the
>> map.
>>
>>
>> In short:
>> Is there a way to save a plot composed of Spatial* elements in a GeoTiff
>> format?
>>
>> Thanks
>>
>> Arnaud
>>
>>         [[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