[Qgis-developer] Python binding : wrong srid/epsg/srsid for some files

Martin Dobias wonder.sk at gmail.com
Mon May 5 15:20:03 EDT 2008


On Mon, May 5, 2008 at 6:22 PM, Michaël Douchin
<michael.douchin at laposte.net> wrote:
>
>  #####
>        #layer provider (ogr, postgres, etc.)
>        myprovider = layer.getDataProvider()
>
>        #layer EPSG projection
>        mysrs = myprovider.getSRS() #layer spatial reference system
>        myepsg = mysrs.epsg()
>        mysrsid = mysrs.srsid()
>        mysrid = mysrs.srid()
>  #####
>
>  this code returns right codes for some of my vector layer (postgresql or
> shapefiles), but wrong codes with others.

Michael,

you should first check return value of mysrs.isValid(). I expect that
in case of invalid SRS the fields will be incorrect.
What does invalid spatial reference mean? In case of some custom SRS
which is not located in QGIS database it won't be recognized and thus
marked as invalid (although OGR was able to parse the projection
file). However you can add custom projections to QGIS to overcome this
problem...

Martin


More information about the Qgis-developer mailing list