[Gdal-dev] python - get projection from a file

Ari Jolma ari.jolma at tkk.fi
Mon Mar 6 15:03:20 EST 2006


Brent Pedersen kirjoitti:
> hi, i'd like to be able to have a user upload a file (.shapefile for 
> now). i want to then use python/gdal to get the projection information 
> associated with that file. where do i start?
>
> i have ogr.Open(filename) and the simple stuff like that, but how do i 
> get the projection? i am having trouble seeing how ogr fits in with 
> stuff like osr.SpatialReference.ImportFromESRI ...

This is Perl but the interface should be rather similar in Python:

$o = ogr::Open("file.shp");
$l = $o->GetLayerByIndex(0);
$s = $l->GetSpatialRef;
$w = $s->ExportToPrettyWkt;
print "$w\n";

I hope this helps.

Ari

>
> thanks for any pointers,
> -brent
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gdal-dev mailing list
> Gdal-dev at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/gdal-dev


-- 
Prof. Ari Jolma
Kartografia ja Geoinformatiikka / Cartography and Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma




More information about the Gdal-dev mailing list