Thursday, 25 July 2019

gdal - DXF to georeferenced SHP


I know how to set projection and georeference bounds of scanned TIFF file, by using gdal, but I don't know how to do the same for vector file.


For example I georeferenced TIFF file by using this command:


gdal_translate -of GTiff -a_ullr x1 y1 x2 y2 -a_srs "7041.prj" input.tif output.tif


where 7041.prj is Gauss Kruger projection file.


I used CorelDraw to do the tracing, and both raster and DXF output share same bounds - vector file has boundbox same as raster image used for tracing. I wanted they overlay automatically when loaded in GIS.


For vector file, with ogr2ogr I can convert DXF to SHP and set projection, but I can't figure how to set georeference bounds as ogr2ogr doesn't accept -a_ullr argument, probably for some reason.


So my question is can I somehow set bounds for resulting SHP file?




Answer



Now it's possible by using latest gdal revision, released couple of minutes ago. ogr2ogr has new switch -gcp:



Every once in a while, we have the need to take non-georeferenced data (e.g. DXF or other CAD files) and draw it on top of a map.


One way to handle this would be to add the ability to specify GCPs in ogr2ogr that would be used to define a transformation that would then be applied to all vector coordinates during the translation. (The gdaltransform program kind of does this for small sets of coordinates, not for whole files)



more info and examples: http://trac.osgeo.org/gdal/ticket/4604


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...