| Title: | Convert Engineering 'DWG' Drawings to Auditable 'GeoJSON' |
| Version: | 0.2.3 |
| 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: 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. |
| 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 |
| RoxygenNote: | 7.3.3 |
| SystemRequirements: | Cargo (Rust's package manager), rustc (>= 1.85) |
| NeedsCompilation: | yes |
| Packaged: | 2026-07-24 10:12:04 UTC; leite |
| Author: | André Leite [aut, cre] |
| Maintainer: | André Leite <leite@castlab.org> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-04 10:10:02 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: 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.
Author(s)
Maintainer: André Leite leite@castlab.org
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()