I need to rasterize my shapefile. This can only happen if both raster and shapefile are in same projection. I don't know if they are in same projection.

How do I compare the projection of these two files?

Vector layer

I converted my csv to shapefile using gdal and vrt file.

    <OGRVRTLayer name="tomato">
        <SrcDataSource relativeToVRT="1">tomato.csv</SrcDataSource>
        <GeometryField reportSrcColumn="false" encoding="PointFromColumns" x="longitude" y="latitude"/>
        <Field name="name" src="name" type="String" />

My csv was in format (name,longitude,latitude)

I got the projection of this shapefile using the following code.

layer = dataSource.GetLayerByIndex(0)
spatial_ref = layer.GetSpatialRef()
proj4 = spatial_ref.ExportToProj4()
print('Layer projection is: {proj4}\n'.format(proj4=proj4))

The layer projection turns out to be

Layer projection is: +proj=longlat +datum=WGS84 +no_defs 

Raster layer

My raster layer is landsat 8 rgb color composite tiff file. The projection of this tiff file is

proj = dataset.GetProjection()
print('Image projection:')
print(proj + '\n')

output : 

PROJCS["WGS 84 / UTM zone 43N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",75],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32643"]]
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Ian Turton
    Mar 13 '17 at 10:19
  • @iant was'nt aware of this feature of stackexchange. Thank you Mar 13 '17 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.