如何从shapefile的.prj文件中获取Proj4详细信息?

时间:2010-06-30 12:13:12

标签: map gis shapefile map-projections

我正在使用mapdotnet服务为我们的gis应用程序加载shapefile,而这个mapdotnet服务需要proj4细节。我从spatialreference.org获取它们,但对于this projection,proj4详细信息为blank。如何从.prj文件或shapefile中获取proj4详细信息?

下面是shapefile的.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]]

5 个答案:

答案 0 :(得分:6)

您也可以使用此Python脚本(在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])

答案 1 :(得分:2)

替代使用和rgdal库:

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's proj4string slot
mymap@proj4string

答案 2 :(得分:2)

使用perl脚本的另一种解决方案(需要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";

答案 3 :(得分:0)

应该可以从各个组件中进行处理。 Proj.4允许指定所有内容。您将需要有关其PRJ文件的ESRI文档。这将包括他们的定义(例如,NAD83_HARN与普通NAD83之间有什么区别?他们的迁移是相同的,但我不知道)

另一种方法可能是查看GDAL / OGR库和实用程序。它们能够读取大多数PRJ文件。

答案 4 :(得分:0)

我使用了来自圣地亚哥的GIS门户网站的PyCRSAddress APN shapefile

PyCharm中的Python控制台:

import pycrs
crs = pycrs.load.from_file("C:\GIS\Address_APN\Address_APN.prj")
crs.to_proj4()

输出:

> '+proj=lcc +datum=NAD83 +ellps=GRS80 +a=6378137.0 +rf=298.257222101
> +pm=0 +x_0=6561666.666666666 +y_0=1640416.666666667 +lon_0=-116.25 +lat_1=32.78333333333333 +lat_2=33.88333333333333 +lat_0=32.16666666666666 +units=us-ft +axis=enu +no_defs'
相关问题