How can I get information about Proj4 from shapefile.prj?

I use mapdotnet services for our gis application to download shapefiles, and this mapdotnet service wants to get information about proj4. I get them from sitereference.org, but for this forecast the details are proj4 blank . How can I get proj4 data from a .prj file or from a shapefile?

The following is a .prj shapefile:

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]]
+3
source share
4 answers

You can also use this Python script (see 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])
+6
source

Alternative uses of r and the rgdal library:

library(rgdal)
# read the .shp file - layer is the same name but without the .shp
mymap <- readOGR("CA_tract_2000.shp", layer="CA_tract_2000") 
# proj4 info is located in the layer proj4string slot
mymap@proj4string
+2

, perl script ( Geo:: GDAL):

#!/usr/bin/perl -w
use strict;
use Geo::OSR;
my $srs = Geo::OSR::SpatialReference->new;
my $prj_text = do { open my $fh, shift or die $!; local $/; <$fh> };
$srs->ImportFromWkt($prj_text);
print $srs->ExportToProj4, "\n";
+2

It should be possible to work with individual components. Proj.4 allows everything to be pointed. You will need ESRI documentation for PRJ files. This will include their definitions (for example, what is the difference between NAD83_HARN and normal NAD83? They are migth the same, but I don't know)

another approach might be to look at the GDAL / OGR library and utilities. They are able to read most PRJ files.

0
source

Source: https://habr.com/ru/post/1752448/


All Articles