Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get Proj4 details from the shapefile's .prj file?

I am using mapdotnet services for our gis application to load the shapefiles, and this mapdotnet service wants the proj4 details. I'm getting them from spatialreference.org, but for this projection the proj4 details are blank. How can I get the proj4 details from the .prj file or from the shapefile?

Below is the shapefile's .prj:

PROJCS["NAD_1983_HARN_WISCRS_EauClaire_County_Feet",GEOGCS["GCS_North_American_1983_HARN",DATUM["D_North_American_1983_HARN",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",394000.0],PARAMETER["False_Northing",300812.797],PARAMETER["Central_Meridian",-91.28888888888889],PARAMETER["Standard_Parallel_1",45.87228112638889],PARAMETER["Scale_Factor",1.000035079],PARAMETER["Latitude_Of_Origin",45.87228112638889],UNIT["Foot_US",0.3048006096012192]]
like image 634
Tushar Maru Avatar asked Jun 30 '10 12:06

Tushar Maru


People also ask

What information is included in a .prj file?

This PRJ file contains a projected coordinate system. It begins with a name for the projected coordinate system. Then it describes the geographic coordinate system. Then it defines the projection and all the parameters needed for the projection.

What is PRJ file in Qgis?

prj file, QGIS will automatically assign the proper coordinate or projection system to the shapefile. A fresh QGIS project will be assigned the Coordinate Reference System (CRS) for the first geographic file that is loaded.


1 Answers

You can also use this Python script (seen elsewhere on the Internet):

#!/usr/bin/env python

import osr
import sys

def main(prj_file):
    prj_text = open(prj_file, 'r').read()
    srs = osr.SpatialReference()
    if srs.ImportFromWkt(prj_text):
        raise ValueError("Error importing PRJ information from: %s" % prj_file)
    print srs.ExportToProj4()
    #print srs.ExportToWkt()

if __name__=="__main__":
    main(sys.argv[1])
like image 61
charlax Avatar answered Nov 30 '22 08:11

charlax