| Title: | 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. |
| Authors: | André Leite [aut, cre] (ORCID: <https://orcid.org/0000-0002-4718-9766>), Raydonal Ospina [aut] (ORCID: <https://orcid.org/0000-0002-9884-9090>), Hugo Vasconcelos [aut] (ORCID: <https://orcid.org/0000-0001-6249-0920>), Diogo Bezerra [aut] (ORCID: <https://orcid.org/0000-0002-1216-8674>) |
| Maintainer: | André Leite <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.4 |
| Built: | 2026-09-30 19:43:33 UTC |
| Source: | https://github.com/milkway/dwg2geo-r |
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.
dwg_as_sf(result, quiet = TRUE)dwg_as_sf(result, quiet = TRUE)
result |
A |
quiet |
Suppress the reading message. Defaults to |
An sf object with one row per feature and the CAD style
metadata as columns.
## Not run: shapes <- dwg_convert("drawing.dwg") |> dwg_as_sf() |> sf::st_set_crs(31983) ## End(Not run)## Not run: shapes <- dwg_convert("drawing.dwg") |> dwg_as_sf() |> sf::st_set_crs(31983) ## End(Not run)
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.
dwg_convert( path, polygonize_closed = FALSE, curve_tolerance = NULL, quiet = FALSE )dwg_convert( path, polygonize_closed = FALSE, curve_tolerance = NULL, quiet = FALSE )
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 |
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.
A list of class "dwg2geo_result" with elements:
geojsonThe FeatureCollection as a JSON string (local
drawing coordinates).
feature_count, model_space_entities
Totals.
converted, skipped, failed
Tibbles of per-entity-type
outcomes; skipped/failed include a reason column.
warningsCharacter vector of conversion warnings.
bboxNumeric c(xmin, ymin, xmax, ymax) in drawing units, or
NULL.
source_sha256SHA-256 of the input bytes (audit trail).
## 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)## 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
dwg_core_version()dwg_core_version()
A string: the version of the Rust dwg2geo crate compiled into
this package.
dwg_core_version()dwg_core_version()