4

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?

2
  • can you explain why you want to set the bounds? Just run ogrinfo on either of the file to get the bounds
    – Ian Turton
    Commented Nov 28, 2012 at 8:15
  • @iant: Please see comment on johanvdw's answer. It has some more info.
    – zetah
    Commented Nov 28, 2012 at 11:21

3 Answers 3

3

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

1
  • I finally tried it, after several unsuccessful builds. Windows user can catch it (before 1.10 release) here: gisinternals.com/sdk Note: Get development version. It works as expected - everything is properly aligned after ogr2ogr transformation
    – zetah
    Commented Nov 30, 2012 at 12:08
2

To define the projection of your shapefile you can go to http://www.spatialreference.org and look up the projection by SRID#, EPSG#, projection name, and other codes that define your shapefiles projection. Available for download at that site are numerous definitions of just about every projection, in almost every format, for example proj4 definitions, USGS or .prj file etc.

Just download the .prj file you need there (for example, "45.prj" is the WGS 84 Web Mercator, and rename the .prj to match your shapefile, for example "mystreet.prj" etc.

To reproject your shapefile to another coordinate reference system, or some other projection that it actually isn't in, or to set bounds, hopefully someone else can answer that.

1

It is not possible to set the projection using a bounding box for a shapefile. There is indeed a reason: if items in the shapefile are changed the bounding box may change as well. If your data in dxf is not projected (which is not unlikely if coming from CAD) you have to reproject your data by manually selecting control points where the coordinates are known.

5
  • Avoiding manual control points was the idea. 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. Are you suggesting that it's not possible without manually adjusting control points?
    – zetah
    Commented Nov 28, 2012 at 11:20
  • Hi, if you have a georeferenced Tiff, my guess would be to load it directly into a GIS Application and do the tracing as a shapefile. The shapefile would then line up with the Tiff. Do you have extra productivity gains by tracing in CorelDraw verses a GIS Application?
    – user12711
    Commented Nov 28, 2012 at 14:59
  • @user12711 I'll try to answer your question, although it's off topic IMHO. Nodes in GIS lines/polygons does not have any spline properties (difficult for topological tracing). GIS doesn't know Bezier, with which I can define couple of points on slopes and software (and experience in positioning this points) does the rest, while in GIS I would have to draw thousands points to be able to do the same. Tracing with CorelDraw (or Inkscape, or Illustrator if user prefers Adobe) can't be compared to any GIS application.
    – zetah
    Commented Nov 28, 2012 at 16:01
  • In fact the bounding box defines four control points, so there is not that much manual work. Apart from that, many gis systems include support for arcs, and if you really want to digitize different maps you may want to look for GIS-tools to digitize, eg wiseimage, arcscan, autodesk raster design,...
    – johanvdw
    Commented Nov 28, 2012 at 22:27
  • Let me then continue my previous comment: ...and can't be compared to CAD tools or GIS CAD toolboxes, as they are designed for geometric primitives which are not useful for topological tracing.
    – zetah
    Commented Nov 28, 2012 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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