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

lky moon_inwell at 163.com
Tue Nov 1 01:26:06 EST 2005


Frank Warmerdam,

Thanks for your help.

I have understood how to get the coordinate system and projection from .prj file. But I have another question about this. Since I can get the coordinate system and projection from .prj file, I also can write these information to it. But I didn't find the support about this. Can you tell me how to write the files?

Best regards

Kunyang Li

----- Original Message ----- 
From: "Frank Warmerdam" <warmerdam at pobox.com>
To: "lky" <moon_inwell at 163.com>
Cc: "gdal 邮件列表" <gdal-dev at lists.maptools.org>
Sent: Monday, October 31, 2005 11:03 PM
Subject: Re: [Gdal-dev] How can I get coordinate system and projection from shape files?


> On 10/31/05, lky <moon_inwell at 163.com> wrote:
>>
>> Hello,everyone:
>>
>> I'm a new learner of the gdal. During my study, I met some problems. I hope
>> I can find help here.
>>
>> I found these is one sentence "If a .prj files in old Arc/Info style or new
>> ESRI OGC WKT style is present, it will be read and used to associate a
>> projection with features." in \ogr\dev_shapefile.html.
>>
>> And I found there are some *.prj files with the same name shapefile in
>> directory C:\arcgis\arcexe83\Reference Systems(The directory which I install
>> arcinfo).In the ArcMap, that the frame map file is *.mxt.
>>
>> I try to use the OGRSFDriverRegistrar::Open function to open these *.prj
>> files but I failed.
>>
>> So I have the following questions.
>>
>> 1. Who can explain the use of these *.prj files in this directory? Which
>> shapefiles do they support? Or they only support project mode for AcrMap?
> 
> Kunyang Li,
> 
> You should open the shapefile normally with OGRSFDriverRegistrar::Open()
> and then fetch the layers from the datasource.  To find the coordinate
> system of a layer you can call OGRLayer::GetSpatialRef() to get a handle
> to the corresponding OGRSpatialReference object.
> 
> This method will read it from a correspondingly named .prj file if it
> is present.
> 
>> 2. What is the relation with the *.prj and *mxt files?
> 
> I don't know anything about mxt files.
> 
>> 3. How can I read the coordinate system and projection from the *.prj files?
>> And whether this prj file support the coordinate system and projection for
>> the same name shapefile or for the shapefiles in the same directory?
> 
> OGR assumes a .prj file applies to the shapefile with the same
> base filename.  If there is no corresponding .prj file, then GetSpatialRef()
> will return NULL.
> 
> 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