1

I'm trying to take a survey site created in AutoCAD Civil 3D and export the drawing to a DXF which I then load into postgres/postgis with GDAL ogr2ogr (https://gdal.org/programs/ogr2ogr.html).

I then use Django rest framework and djangorestframework-gis to query the data and return GeoJSON which I then load into OpenStreetMaps in the browser.

Everything works fine so far, the steps outlined above work.

The problem is that the coordinates are not correct in the postgis database when I run the ogr2ogr utility script to load the data into postgis. The coordinates are the same units as the autocad model space units and don't have the correct lat/long values, so I cannot view the survey site in the openstreetmaps map in the browser.

When I import the DXF file into QGIS, the coordinates look correct there though which is interesting. Also, in Civil 3D, if I add the map background, the drawing looks like it is in the correct geolocation.

To be honest, I am not sure what I am doing here as I am not a GIS engineer and it is quite complex.

Basically, I just want to render this survey site plan in the correct position in openstreetmaps but I'm missing some step to either project it or convert the autocad coordinates to the proper lat/long coordinates somewhere.

Here's some sample GeoJSON output from the browser with the incorrect coordinates (the same ones from the autocad model space):

{
"type": "FeatureCollection",
"features": [
    {
        "type": "Feature",
        "geometry": {
            "type": "LineString",
            "coordinates": [
                [
                    312563.1073890633,
                    23909.43858888965
                ],
                [
                    312563.10055573,
                    23909.43858888965
                ]
            ]
        },
        "properties": {
            "ogc_fid": 22145,
            "layer": "lines"
        }
    },
    {
        "type": "Feature",
        "geometry": {
            "type": "LineString",
            "coordinates": [
                [
                    312543.87787196774,
                    23844.021558701224
                ],
                [
                    312543.8776843011,
                    23844.021552290338
                ],
                [
                    312543.8774975095,
                    23844.02153308757
                ],
                [
                    312543.8773124637,
                    23844.021501182455
                ],
                [
                    312543.87713002664,
                    23844.021456723753
                ],
                [
                    312543.8769510488,
                    23844.021399918747
                ],
                [
                    312543.87677636475,
                    23844.021331032287
                ],
                [
                    312543.8766067889,
                    23844.02125038556
                ],
                [
                    312543.87644311186,
                    23844.021158354568
                ],
                [
                    312543.8762860969,
                    23844.021055368412
                ],
                [
                    312543.8761364759,
                    23844.020941907256
                ],
                [
                    312543.87599494663,
                    23844.02081850011
                ],
                [
                    312543.87586216885,
                    23844.020685722353
                ],
                [
                    312543.8757387617,
                    23844.020544193056
                ],
                [
                    312543.87562530057,
                    23844.020394572097
                ],
                [
                    312543.8755223144,
                    23844.020237557073
                ],
                [
                    312543.8754302834,
                    23844.020073880067
                ],
                [
                    312543.87534963666,
                    23844.019904304212
                ],
                [
                    312543.8752807502,
                    23844.01972962015
                ],
                [
                    312543.8752239452,
                    23844.01955064234
                ],
                [
                    312543.8751794865,
                    23844.019368205256
                ],
                [
                    312543.8751475814,
                    23844.019183159508
                ],
                [
                    312543.8751283786,
                    23844.01899636786
                ],
                [
                    312543.87512196775,
                    23844.018808701225
                ]
            ]
        },
        "properties": {
            "ogc_fid": 22146,
            "layer": "lines"
        }
    },
    {
        "type": "Feature",
        "geometry": {
            "type": "LineString",
            "coordinates": [
                [
                    312543.87512196775,
                    23844.018808701232
                ],
                [
                    312543.8751283786,
                    23844.018621034596
                ],
                [
                    312543.8751475814,
                    23844.01843424295
                ],
                [
                    312543.8751794865,
                    23844.0182491972
                ],
                [
                    312543.8752239452,
                    23844.018066760116
                ],
                [
                    312543.8752807502,
                    23844.017887782305
                ],
                [
                    312543.87534963666,
                    23844.01771309824
                ],
                [
                    312543.87543028337,
                    23844.017543522386
                ],
                [
                    312543.8755223144,
                    23844.01737984538
                ],
                [
                    312543.87562530057,
                    23844.017222830356
                ],
                [
                    312543.8757387617,
                    23844.017073209397
                ],
                [
                    312543.87586216885,
                    23844.0169316801
                ],
                [
                    312543.87599494663,
                    23844.016798902343
                ],
                [
                    312543.8761364759,
                    23844.016675495197
                ],
                [
                    312543.8762860969,
                    23844.016562034038
                ],
                [
                    312543.87644311186,
                    23844.01645904788
                ],
                [
                    312543.8766067889,
                    23844.01636701689
                ],
                [
                    312543.87677636475,
                    23844.016286370163
                ],
                [
                    312543.8769510488,
                    23844.016217483706
                ],
                [
                    312543.87713002664,
                    23844.016160678697
                ],
                [
                    312543.8773124637,
                    23844.016116219995
                ],
                [
                    312543.8774975095,
                    23844.01608431488
                ],
                [
                    312543.8776843011,
                    23844.016065112115
                ],
                [
                    312543.87787196774,
                    23844.016058701225
                ]
            ]
        },
        "properties": {
            "ogc_fid": 22147,
            "layer": "lines"
        }
    }
]

}

Vince
  • 20,017
  • 15
  • 45
  • 64
  • 2
    In Civil 3D have you tried using command MAPEXPORT to export a shapefile in EPSG:4326 lats and longs? – Pointdump May 07 '23 at 18:31
  • What is your ogr command line? – Ian Turton May 07 '23 at 20:11
  • Can you share how you are creating the GeoJSON? Does the GeoJSON specify the CRS as something like "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::28355" } } (28355 to be replaced by the EPSG code of the local coordinate system your drawing is using). Although, if it's for web map application you may need to stick to the GeoJSON format specification which requires coordinates to be in EPSG:4326 lat/longs and you need to add this to your conversion pipeline. Apparently specifying CRS was dropped in the 2016 specs. https://gis.stackexchange.com/a/437311/98784 – she_weeds May 10 '23 at 02:08

0 Answers0