[Gfoss] prj2epsg

Paolo Corti pcorti a gmail.com
Mer 6 Apr 2011 16:37:23 CEST


> Penso che giĆ  conoscevate
>
> http://prj2epsg.org/search
>
> non sempre infallibile....ma a volte e a qualcuno potrebbe essere
> utile...:-)
>

Usando GDAL (testato sulla 1.8) e senza usare un servizio on line.
Crea il file esriprj2standards ed inserisci le seguenti linee:

import sys
from osgeo import osr

def esriprj2standards(shapeprj_path):
    prj_file = open(shapeprj_path, 'r')
    prj_txt = prj_file.read()
    srs = osr.SpatialReference()
    srs.ImportFromESRI([prj_txt])
    print 'Shape prj is: %s' % prj_txt
    print 'WKT is: %s' % srs.ExportToWkt()
    print 'Proj4 is: %s' % srs.ExportToProj4()
    srs.AutoIdentifyEPSG()
    print 'EPSG is: %s' % srs.GetAuthorityCode(None)

esriprj2standards(sys.argv[1])

a questo punto puoi eseguire il programmino, dandogli in pasto un prj:

$ python esriprj2standards.py /home/pcorti/data/shapefile/country.prj
Shape prj is: GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
WKT is: GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
Proj4 is: +proj=longlat +datum=WGS84 +no_defs
EPSG is: 4326

Divertiti a modificarlo come meglio credi, buon divertimento

ciao
P

-- 
Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti


Maggiori informazioni sulla lista Gfoss