5

我正在为我们的 gis 应用程序使用 mapdotnet 服务来加载 shapefile,而这个 mapdotnet 服务需要 proj4 详细信息。我从spatialreference.org 得到它们,但是对于这个投影,proj4 的细节是空白的。如何从 .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]]
4

5 回答 5

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])
于 2011-10-05T23:33:11.387 回答
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";
于 2012-01-09T09:38:17.230 回答
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
于 2011-02-14T04:42:41.843 回答
0

应该可以从各个组件中解决它。Proj.4 允许指定所有内容。您将需要其 PRJ 文件的 ESRI 文档。这将包括它们的定义(例如,NAD83_HARN 和普通 NAD83 有什么区别?它们可能相同,但我不知道)

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

于 2010-11-18T22:55:38.313 回答
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'
于 2020-07-03T22:39:53.493 回答