I have been given some shapefiles WITHOUT a projection. So I need to add the projection in order to display it on google map. I found the projection information I need at http://spatialreference.org/ref/epsg/2066.

How can I add the projection using an open source method (don't have access to ESRI's software)?


6 Answers 6


Use ogr2ogr from GDAL:

ogr2ogr -a_srs EPSG:2066 output.shp input.shp

What's neat about ogr is that it can use an existing PRJ file as input as well:

ogr2ogr -a_srs input.prj output.shp input.shp

  • 2
    I'm getting the following error when I try the utility above: "Can't transform coordinates, source layer has no coordinate system. Use -s_srs to set one."
    – ChrisJ
    Feb 3, 2012 at 20:53
  • @chris I wrote the wrong usage, so try a_srs to "assign" an output projection
    – SaultDon
    Feb 3, 2012 at 21:44
  • Didn't know you could supply a .prj to -a_srs. Thanks!
    – aendra
    Jan 27, 2015 at 17:54

Projection in .shp file is in shapefilename.prj. It is basically text file, with info you found. Have a look at some of your shape files and figure out how information is written. Or less complited, if you have other .shp file in the same projection, just copy it and change the name accordinagly.

  • I did manually create a file with the information I found online. But it still isn't being displayed correctly. Is there a utility I can use to create the projection file with this data??
    – ChrisJ
    Feb 3, 2012 at 20:26
  • 3
    You can also use spatialreference.org where you can find and download a .PRJ file, then rename it to the same prefix as the .SHP file
    – Mike T
    Feb 4, 2012 at 0:25

Create a .prj file with the same basename as your shapefile (i.e. foo.prj), open the file in a text editor and add the contents of, in this case, http://spatialreference.org/ref/epsg/2066/prj/


Download the .prj file at the link you posted and then rename it to match your shape file.

  • 1
    this is also probably the easiest method given that there's no need to create any intermediate data
    – SaultDon
    Feb 6, 2018 at 2:11

Find attached a little script that writes the projection reference from spatialreference.org into a .prj file. It adds a projection file to all specified files in a directory. For instance, all the shapefiles in the directory E:\ .Just worry about the EPSG code of the projection you want to embed, the extension of the files you want to add a projection file to and the directory where these are. It will recursively go through all subdirectories, so use with care.

    import os

    def getWKT_PRJ (epsg_code):
     import urllib.request, urllib.parse, urllib.error

    # Access projection information
     wkt = urllib.request.urlopen("http://spatialreference.org/ref/epsg/{0}/prettywkt/".format(epsg_code))
     decoded = (wkt.read().decode('utf-8')) 

    # Remove spaces between charachters
     remove_spaces = decoded.replace(" ","")        
    # Place all the text on one line
     output = remove_spaces.replace("\n","")
     return output

    def referencer(folder_path, extension):
        for path, subdirs, files in os.walk(folder_path):
            for name in files:
                file_extension = os.path.splitext(name)[-1]
                if(extension in file_extension):
                    file_path = os.path.join(path,name)
                    file_name = os.path.splitext(file_path)[0]
                    prj = file_name + ".prj"
                    projection = open(prj,"w")

    epsg = getWKT_PRJ("25831")              
    referencer('E:\Testfolder', '.shp')

Try using Geokettle http://www.spatialytics.org/ it reads shapefiles and has an option to add an SRS in its transformations. Otherwise use ogr2ogr gui (windows only) to see the srid

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.