<div>Hi,</div><div> </div><div>Thanks for your responses. I checked and my shapefile and tiff file are in the same projection. The ticket posted by Etienne showed that this problem of gdalwarp has been reported before. This is what was mentioned in  ticket #3947 and I tried it. </div>
<div> </div><div>"I should add that not adding -crop_to_cutline results in no shift. Commands I ran:<p>(1) gdalwarp -cutline cluj_co.shp -crop_to_cutline sample.tif cropped.tif</p><p>result is shifted</p><p>(2) gdalwarp -cutline cluj_co.shp sample.tif out.tif</p>
<p>result is not shifted"</p><p>However, although using only -cutline places the carved out raster from the bigger raster correctly (without shifting it 500m), it does not reduce the size of the whole image (in the sense, it gives 0 values everyhwere outside the state but still has all those 3399 columns and 3747 rows. This defeats the purpose of my whole exercise of trying to carve ot only a portion of the raster on the basis of the state shapefile. gdal2xyz generates the csv file, but excel fails to open all the rows! </p>
<p>Any suggestions, again?</p><p>Thanks,</p><p>Tilo</p></div><div><br><br> </div><div class="gmail_quote">On Mon, Jan 30, 2012 at 7:43 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@mines-paris.org" target="_blank">even.rouault@mines-paris.org</a>></span> wrote:<br>
<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">
Selon Etienne Tourigny <<a href="mailto:etourigny.dev@gmail.com" target="_blank">etourigny.dev@gmail.com</a>>:<br>
<div><br>
> 1) Probably a datum issue, as shapefiles do not include datum shift<br>
> information. You could work this around by making a new shape file<br>
> with the same datum as the gtiff file.<br>
><br>
> What are the datums of your gtiff and shape files?  Please post the<br>
> contents of the .prj file.<br>
<br>
</div>It might be the same as <a href="http://trac.osgeo.org/gdal/ticket/3947" target="_blank">http://trac.osgeo.org/gdal/ticket/3947</a><br>
<div><div><br>
><br>
> Etienne<br>
><br>
> On Mon, Jan 30, 2012 at 9:39 AM, Tilottama Ghosh <<a href="mailto:waggymaggy@gmail.com" target="_blank">waggymaggy@gmail.com</a>><br>
> wrote:<br>
> > Hi,<br>
> ><br>
> > I have a huge tiff image (covering an entire country) with 3399 columns and<br>
> > 3747 rows, so a total of 12,736,053 cells. The cell size is 1000m or 1km. I<br>
> > need to extract the data per km2. Of course, I didn't think it was smart to<br>
> > work with such a huge dataset in one go. So, I followd these steps in<br>
> > Quantum gis -<br>
> ><br>
> > 1. I used the gdalwarp -crop_to_cutline in the command line to carve out a<br>
> > portion of the raster image based on the shapefile  of a state of the<br>
> entire<br>
> > country. The problem is that although the gdalwarp command worked it is<br>
> > clearly causing a shift (of about 500m) during this step.<br>
> ><br>
> > 2. Then, I used the gdal2xyz tool from the command line to create the csv<br>
> > file corresponding to the 'cut out' raster image or only the raster image<br>
> of<br>
> > the state.<br>
> ><br>
> > 3. Then I used the 'Create a Layer from a Delimited Text file' plugin in<br>
> > qgis to get the centroid shapefile.<br>
> ><br>
> > My problems are-<br>
> ><br>
> > 1. The shift in the image caused by the gdalward tool. Does anyone know how<br>
> > to work around that, so that no shift is caused?<br>
> ><br>
> > 2. The image is in 32 bit floating point and so does not show the attribute<br>
> > table. Even after getting the csv file I am unable to link the created csv<br>
> > file with the raster image, and thus cannot understand which pixel<br>
> > corresponds to which value in the csv file.<br>
> ><br>
> > Can anyone suggest any better way of doing this?<br>
> ><br>
> > Thanks very much for your help.<br>
> ><br>
> > Best Regards,<br>
> ><br>
> > Tilo<br>
> ><br>
> ><br>
> > --<br>
> ><br>
> > _______________________________________________<br>
> > Qgis-user mailing list<br>
> > <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
> > <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
> ><br>
> _______________________________________________<br>
> Qgis-user mailing list<br>
> <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
><br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>