[gdal-dev] How to add a OGRSpatialReference to an OGRLayer?

Frank Warmerdam warmerdam at pobox.com
Tue Sep 30 17:02:24 EDT 2008


On Tue, Sep 30, 2008 at 10:55 PM, Tom Kazimiers <2voodoo at gmx.de> wrote:
> Hi,
>
> unfortunately I have no experience with OGR and want to display a
> SHP-File (on WinCE, but I don't think that matters). The rendering works
> well, but is slow - so I will add some caching. One thing of faster
> rendering is to use SetSpatialFilterRect() I guess. This works, as
> written in the docs, with comparing the coorinates (they must be in the
> same coorinate systeme). Sadly, my shp files do not have any
> SpatialReference (I get NULL returned from OGRLayer::GetSpatialRef() ).
> If I use SetSpatialFilterRect() with this shp file datasource I will get
> back absolutely no features. I thought the reason for this could be the
> missing spatial referenc. So I wonder how to add/change a spatial
> reference (e. g. a coorinate interpretation, right?) to a layer?

Tom,

In fact there is no GDAL way to do this.  You can however manually
put a .prj file with an ArcGIS PE string along side the shapefiles.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent


More information about the gdal-dev mailing list