Sunday, 10 September 2017

Cropping with GDALWarp in QGIS


I followed this post, the first answer, to clip a USGS Quad in order to remove the borders so that I can tile them. Basically it utilized the lat/long at the corners in a .txt file to import a rectangle using "add delimited text layer". I then reproject the rectangle to match the CRS of the USGS quad. After I clip it I get black edges, see image.


black corners


I offered the error as a comment in the aforementioned post and it was answered that its likely from re-projecting the rectangle and that I should use -dstalpha or -dstnodata to make it white. When I use those two options, I just get a colored rectangle. I actually want that area transparent for when I tile multiple USGS Quad maps. I even tried to re-project the quad map to the CRS of the rectangle.


Does anyone know how I can clip the USGS quad without having the black corners for tiling pruposes? FYI... I am using QGIS 2.2 on Windows 7.


EDIT:


The mask that I have compiled using the delimited text layer matches the area that I would like to clip perfectly. So I dont think that I have an error. I downloaded the Newburgh and the Cornwall on Hudson Quads. Reading the corner coordinates I developed the following two .txt files:


Newburgh




Nr;WKT 1;POLYGON((-74.00 41.5, -74.125 41.5, -74.125 41.625, -74.00 41.625, -74.00 41.5))



Cornwall on Hudson



Nr;WKT 1;POLYGON((-74.00 41.375, -74.125 41.375, -74.125 41.5, -74.00 41.5, -74.00 41.375))




Answer



The source map comes with paletted colours, but only 12 are used.


So I have set the nodata value to 255 in the clipper dialogue, and the nodata areas are not black, nor are the black parts set to nodata:



enter image description here


If you intend to combine the rasters to a vrt, it is better to expand them to rgba (but only after you applied the nodata value).


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...