% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/write_geojson.R
\name{write_geojson}
\alias{write_geojson}
\alias{write_geojson_js}
\title{Functions to write GeoJSON files with usage analogous to \code{write.table}.}
\usage{
write_geojson(sp, file, pretty = TRUE, round = NA)

write_geojson_js(sp, file, name = NA, pretty = TRUE, round = NA)
}
\arguments{
\item{sp}{Spatial object to be written as GeoJSON file.}

\item{file}{File name of GeoJSON file.}

\item{pretty}{Format the JSON for readability.}

\item{round}{How many decimal points should the coordinate pairs be exported
with? Default is maximum but \code{6} is common for spatial data.}

\item{name}{Name of JavaScript object (only used in \code{write_geojson_js}).}
}
\description{
\code{write_geojson_js} is a simple extension which adds a \code{var} to the 
GeoJSON string so leaflet and other JavaScript libraries can assign the 
objects easily.
}
\examples{
\dontrun{

# Export spatial object as GeoJSON file
write_geojson(sp_thames_locks, "thames_locks.json", pretty = TRUE)

# Export spatial object as GeoJSON file ready for leaflet
write_geojson(sp_thames_locks, "thames_locks.js", name = "data_locks")

}

}
\author{
Stuart K. Grange
}
