10

I wanted to re-project a QGIS project, but there is no such option. When searching for an answer I see ogr2ogr suggested for this task, by re-projecting each vector layer (shapefile in this example). However I don't get expected result:

C:\temp>ogrinfo -al -so misc.shp
INFO: Open of `misc.shp'
      using driver `ESRI Shapefile' successful.

Layer name: misc
Geometry: Line String
Feature Count: 10
Extent: (21.267388, 42.015857) - (21.270225, 42.017470)
Layer SRS WKT:
PROJCS["MGI_Balkans_zone_7_deprecated",
    GEOGCS["GCS_MGI",
        DATUM["Militar_Geographische_Institute",
            SPHEROID["Bessel_1841",6377397.155,299.1528128]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",21],
    PARAMETER["scale_factor",0.9999],
    PARAMETER["false_easting",7500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
id: Integer (10.0)

C:\temp>ogr2ogr -t_srs EPSG:4326 misc_re.shp misc.shp

C:\temp>ogrinfo -al -so misc_re.shp
INFO: Open of `misc_re.shp'
      using driver `ESRI Shapefile' successful.

Layer name: misc_re
Geometry: Line String
Feature Count: 10
Extent: (-34.004490, 0.000230) - (-34.004490, 0.000230)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_84",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]
id: Integer (10.0)

So new file has changed geographic coordinate system, but it's not projected.
How to do that?

5
  • Are you trying to reproject a shapefile? A project file has a .qqs ending, a shapefile ends with .shp. I don't think you can re-project a project file but I could be wrong.
    – djq
    Commented Dec 12, 2012 at 22:28
  • 1
    I assume you already know the "on the fly" reprojection in QGIS that enables reprojecting any vector layer.
    – steko
    Commented Dec 12, 2012 at 22:31
  • @steko: If "on the fly" is what is answered by djq, yes I already knew that.
    – zetah
    Commented Dec 12, 2012 at 22:50
  • 1
    No, that is another way and it will permanently change the data. On the fly reprojection is only defined in the QGIS project and will affect how the layers are visualized but not touch the underlying files.
    – steko
    Commented Dec 13, 2012 at 11:52
  • Thanks I didn't know about that, and Googling it showed me what you meant. It's exactly what I needed. If you could have only posted your last comment yesterday... I did lot of typing to get there ;)
    – zetah
    Commented Dec 13, 2012 at 15:12

1 Answer 1

20

Assuming you want to reproject a shapefile, one way within QGIS is to load the file, right-click on the layer, select Save As…, and then the following window appears:

enter image description here

If you click browse beside CRS you can choose a new projection to save your file in.

EDIT:

To reproject all shapfiles in the one folder, something like this could work:

set "str1=_projected"
for %f in (E:\data\*.shp) do ogr2ogr -t_srs EPSG:4326 %str1%"misc_re.shp %f

(I haven't tested this and am unfamiliar with string concatenation on windows, nor am I solving the ogr2ogr issue - but this code snippet loops through a folder and runs something on each file.)

14
  • Yes that's great, but I would have to do that for every layer, which is time consuming. By using command line I was hoping to re-project all shapefiles at once (with for loop)
    – zetah
    Commented Dec 12, 2012 at 22:48
  • Are all the shapefiles in the one folder?
    – djq
    Commented Dec 12, 2012 at 22:54
  • Yes, they are in same folder
    – zetah
    Commented Dec 12, 2012 at 22:55
  • thanks for your effort, but did you actually read my question?
    – zetah
    Commented Dec 12, 2012 at 23:18
  • 3
    yes... you can't reproject a qgis project file which is why I gave my first answer. Then I realized you wanted to reproject the shapefiles in bulk. One way of doing this is to loop through all the files in a folder using the command line with ogr (another would be to see if you can pass ogr a folder of shapefiles).
    – djq
    Commented Dec 12, 2012 at 23:22

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.