[gdal-dev] Change the spatial reference of a shapeile

Chaitanya kumar CH chaitanya.ch at gmail.com
Fri Jul 8 06:42:39 EDT 2011


Solimyr,

For shapefiles just copying and renaming the .prj file might be enough.
Extents can be computed and stored using the ogr2ogr utility.

If copying the .prj file didn't work, you can use the -s_srs option in the
ogr2ogr utility. You can get the SRS WKT from the ogrinfo output.

Of course, you can do this programatically using OGRDataSource::CopyLayer()
method. The spatial reference has to be set to each layer in a datasource.
There is no GeoTransform. You can force calculation of extent using
OGRLayer::GetExtent() method.

http://www.gdal.org/ogr_utilities.html
http://www.gdal.org/ogr/ogr_arch.html
http://www.gdal.org/ogr/annotated.html


On Fri, Jul 8, 2011 at 3:48 PM, Solimyr <giannicristian at msn.com> wrote:

> Hi guys,
> I have two shapefile with same features but one miss the extent and the
> projection. What I want to do is copy the extent and the projection from
> the
> first and set to the second. I did something  similar with two images using
> these step:
>
> inputimg = gdal.Open(str(fileName), GA_ReadOnly)
> gdalformat= inputimg.GetDriver().ShortName
> geoinput = inputimg.GetGeoTransform()
> projinput= inputimg.GetProjection()
> ..
> outimg = gdal.Open(str(result), GA_Update)
> outimg.SetProjection(projinput)
> outimg.SetGeoTransform(geoinput)
>
>
> Do you know if there is something similar to this but for shapefile? Do you
> have any suggests?
> thx
>
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Change-the-spatial-reference-of-a-shapeile-tp6561998p6561998.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110708/821933bc/attachment.html


More information about the gdal-dev mailing list