1

I'm using ogr2ogr to transform an AutoCAD (DXF) file to GeoJSON. The GeoJSON file is generated, but with very large coordinates, for example "coordinates": [ [ [ 6319.645968701713173, 9523.353045375093643, 0.0 ].

This probably comes from the fact that the DXF file has no notion of coordinates, only dimensions (very large ones). I would like to "transform" those arbitrary coordinates to standard EPSG:4326 coordinates, by scaling them down. I have no preference on where it will get displayed on the final map, but I need this coordinates to fit in a fixed bounds.

I did not find any ogr2ogr method to "scale down" coordinates, any idea on how I could do this?

2
  • Most GIS packages are better at real-world conversons than arbitrary ones. Scaling arbitrary Cartesian coordinates into degrees is particularly error-prone.
    – Vince
    Oct 14, 2021 at 15:20
  • @Vince I know about that, but let's say we fix an "origin" point, if we just compute the position, based on a transformation method from my arbitrary coordinates to a metric system, with the origin it should be doable ? Maybe no such tool exist, but with a combination of existing tools (I've used turf in the past, which offer the ability to add point at specific length) Oct 14, 2021 at 15:51

1 Answer 1

2

Not only do you have to convert, you also have to transform. You take a (any) metric system and transform according to EPSG: 4326.

ogr2ogr -skipfailures  --config DXF_MERGE_BLOCK_GEOMETRIES FALSE  ^
    --config DXF_ENCODING "CP1252" -sql "select *, ogr_style from entities"  -nln "entities"  -f "GeoJSON"  ^
    -s_srs "EPSG:27398"  ^
    -t_srs "EPSG:4326" ^
    "target.GeoJSON" "source.dxf" 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.