[Gdal-dev] How can I get coordinate system and projection from shape files?

Frank Warmerdam warmerdam at pobox.com
Wed Nov 2 09:30:11 EST 2005


On 11/2/05, lky <moon_inwell at 163.com> wrote:
> Here, poSourceSRS is a pointer of the coordinate system and projection of the source data,and poTargetSRS is a pointer of the coordinate system and projection of the target data.I have tried two ways, but both failed.Firstly, I got the poSourceSRS by the OGRLayer::GetSpatialRef() method, but I can't change this pointer. Secondly I use the TargetSRS in the OGRDataSource::CreateLayer() method to specify the coordinate system and projection, I will get the result. But this is not useful in the shapefile. When I open the shapefile by ArcMap, the note pop up that is "Note: one or more layers is missing spatial reference information.  Data from these layers cannot be projected.".

Kunyang Li,

OK, how did you prepare poTargetSRS?  If you pass a pointer to a valid
coordinate system to CreateLayer() it should get written out as a .prj
file (after morphing to ESRI format).   Does a .prj file get written out?
Perhaps it is just incompatible with the ArcMap software in someway
I will need to correct.

BTW, what you want to do should also be easily accomplished
at the commandline with "ogr2ogr".

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