| Title: | Convert Engineering 'DWG' Drawings to Auditable 'GeoJSON' |
| Version: | 0.2.5 |
| Description: | Converts engineering 'DWG' drawings ('AutoCAD' 2013+ format) to 'GeoJSON' entirely in-process, with no 'CAD' software, 'LibreDWG', or 'GDAL' required. Wraps the pure-Rust 'dwg2geo' conversion core https://github.com/milkway/dwg2geo, which reads the 'DWG' format with the third-party 'acadrust' library by Hakan AK https://github.com/hakanaktt/acadrust (Mozilla Public License 2.0), bundled with the package: every feature carries resolved 'CAD' style metadata (layer, colour, line weight, text), skipped and failed entities are reported with reasons, and the output is deterministic: the same bytes always produce byte-identical 'GeoJSON'. Coordinates are kept in the drawing's local system; the package never guesses a coordinate reference system. Not affiliated with 'Autodesk'; 'DWG' and 'AutoCAD' are trademarks of 'Autodesk, Inc.'. |
| Copyright: | The R interface and the 'dwg2geo' conversion core are copyright of the package authors. The bundled 'acadrust' crate, which reads the 'DWG' format, is copyright of Hakan AK and distributed under the Mozilla Public License 2.0; its source is included in src/rust/vendor.tar.xz and the license text in inst/COPYRIGHTS. See inst/AUTHORS for the copyright holders and licenses of all bundled 'Rust' crates. |
| License: | MIT + file LICENSE |
| URL: | https://milkway.github.io/dwg2geo-r/, https://github.com/milkway/dwg2geo-r |
| BugReports: | https://github.com/milkway/dwg2geo-r/issues |
| Depends: | R (≥ 4.2) |
| Imports: | cli, jsonlite, rlang, tibble |
| Suggests: | sf, testthat (≥ 3.0.0), withr |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| SystemRequirements: | Cargo (Rust's package manager), rustc (>= 1.85) |
| NeedsCompilation: | yes |
| Config/roxygen2/version: | 8.0.0 |
| Packaged: | 2026-11-30 15:14:48 UTC; leite |
| Author: | André Leite |
| Maintainer: | André Leite <leite@castlab.org> |
| Repository: | CRAN |
| Date/Publication: | 2026-11-30 16:00:33 UTC |
dwg2geo: Convert Engineering 'DWG' Drawings to Auditable 'GeoJSON'
Description
Converts engineering 'DWG' drawings ('AutoCAD' 2013+ format) to 'GeoJSON' entirely in-process, with no 'CAD' software, 'LibreDWG', or 'GDAL' required. Wraps the pure-Rust 'dwg2geo' conversion core https://github.com/milkway/dwg2geo, which reads the 'DWG' format with the third-party 'acadrust' library by Hakan AK https://github.com/hakanaktt/acadrust (Mozilla Public License 2.0), bundled with the package: every feature carries resolved 'CAD' style metadata (layer, colour, line weight, text), skipped and failed entities are reported with reasons, and the output is deterministic: the same bytes always produce byte-identical 'GeoJSON'. Coordinates are kept in the drawing's local system; the package never guesses a coordinate reference system. Not affiliated with 'Autodesk'; 'DWG' and 'AutoCAD' are trademarks of 'Autodesk, Inc.'.
Author(s)
Maintainer: André Leite leite@castlab.org (ORCID)
Authors:
André Leite leite@castlab.org (ORCID)
Raydonal Ospina raydonal@castlab.org (ORCID)
Hugo Vasconcelos hugo.vasconcelos@ufpe.br (ORCID)
Diogo Bezerra diogo.bezerra@ufpe.br (ORCID)
Other contributors:
Hakan AK (Author of the bundled 'acadrust' Rust crate, which reads the 'DWG' format (MPL-2.0)) [copyright holder]
Authors of the vendored Rust crates (see inst/AUTHORS) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/milkway/dwg2geo-r/issues
Read a conversion result as an sf object
Description
Parses the GeoJSON produced by dwg_convert() into an
sf data frame. The geometry keeps the drawing's local
coordinates and carries no CRS; set the known one explicitly with
sf::st_set_crs() before any reprojection.
Usage
dwg_as_sf(result, quiet = TRUE)
Arguments
result |
A |
quiet |
Suppress the reading message. Defaults to |
Value
An sf object with one row per feature and the CAD style
metadata as columns.
Examples
## Not run:
shapes <- dwg_convert("drawing.dwg") |>
dwg_as_sf() |>
sf::st_set_crs(31983)
## End(Not run)
Convert a DWG drawing to GeoJSON
Description
Reads an AutoCAD 2013+ (AC1027) DWG file and converts its model-space
entities to a GeoJSON FeatureCollection, entirely in-process, with no CAD
software, LibreDWG, or GDAL required. Every feature carries resolved CAD
style metadata (layer, color_rgb, color_index, linetype,
lineweight_mm, text properties), and skipped or failed entities are
reported with reasons.
Usage
dwg_convert(
path,
polygonize_closed = FALSE,
curve_tolerance = NULL,
quiet = FALSE
)
Arguments
path |
Path to a |
polygonize_closed |
Convert closed polylines to polygons instead of
line strings. Defaults to |
curve_tolerance |
Maximum sagitta error, in drawing units, allowed
when tessellating arcs, circles, ellipses, and splines. |
quiet |
Suppress progress messages. Defaults to |
Details
Coordinates are kept in the drawing's local system: dwg2geo never
guesses a coordinate reference system. Georeference the result yourself:
e.g. read it with dwg_as_sf(), set the known CRS with
sf::st_set_crs(), and reproject with sf::st_transform().
The conversion is deterministic: the same bytes always produce byte-identical GeoJSON on a given platform.
Value
A list of class "dwg2geo_result" with elements:
geojsonThe
FeatureCollectionas a JSON string (local drawing coordinates).feature_count,model_space_entitiesTotals.
converted,skipped,failedTibbles of per-entity-type outcomes;
skipped/failedinclude areasoncolumn.warningsCharacter vector of conversion warnings.
bboxNumeric
c(xmin, ymin, xmax, ymax)in drawing units, orNULL.source_sha256SHA-256 of the input bytes (audit trail).
Examples
## Not run:
result <- dwg_convert("drawing.dwg")
result$feature_count
result$converted
# to sf, with an explicitly known CRS:
shapes <- dwg_as_sf(result) |>
sf::st_set_crs(31983) |>
sf::st_transform(4326)
## End(Not run)
Version of the embedded conversion core
Description
Version of the embedded conversion core
Usage
dwg_core_version()
Value
A string: the version of the Rust dwg2geo crate compiled into
this package.
Examples
dwg_core_version()