Skip to contents

Write GDAL's GMT/OGR ASCII vector format, retaining polygon holes, feature attributes, and CRS metadata. GMT itself is not needed to export.

Usage

Show/hide R code
write_gmt(x, file, overwrite = FALSE)

Arguments

x

A non-empty sf object with a known CRS and polygon geometry.

file

A local output filename ending in `.gmt`.

overwrite

Replace an existing file? Defaults to FALSE.

Value

The output path, invisibly.

Details

Output coordinates are WGS84 longitude/latitude (EPSG:4326). Multipart features are split into polygon records with repeated attributes; interior rings remain holes. Dateline crossings are split before export. Use GMT 6 `gmt plot file.gmt -R... -J...` to draw the result. This is a vector exchange helper, not a wrapper for GMT's plotting or grid modules.

Examples

Show/hide R code
path <- tempfile(fileext = ".gmt")
write_gmt(get_reporting_areas("541"), path)
unlink(path)