<div dir="ltr"><div><div><div><div><div><div>Even,<br></div> Thank you for the response!<br><br></div>I'm actually rasterizing the PDF to PNG via pdftoppm before doing anything with gdal*, that's why the rotating and resizing surprises me.<br>
<br></div>When do the pixelSkew parameters get used vs. swapping the axes? The swapping works in this case is because the rotation is 90 degrees but what would happen with an arbitrary rotation (eg 37 degrees). <br><br>
The reason I'm curious about all this is that I'm wanting to use only the initially generated PNG for my final georeferenced image and not have to generate an additional one that is rotated by gdal with the skew parameters set to 0 and also resized.<br>
<br></div>If I can provide any more detail on my process or what I'm trying to accomplish please let me know.<br><br></div>Here's the general flow for Airport Diagrams:<br><br><div style="margin-left:40px">Source PDF -> create PNG, create list of GCPs from the PDF mapped to that PNG -> gdal_translate PNG to intermediate VRT -> gdal_warp intermediate VRT to final VRT<br>
</div><br></div><div>The final VRT displays properly in QGIS so the process is working correctly but I was hoping to be able to extract from it all of the parameters of the affine transformation necessary to properly display the PNG as a geoferenced image (origin, extents, pixel sizes and pixel skew) in a separate Android application. (This bitmap is to be used in a separate moving map application to display an airplane's real world position on the image)<br>
<br></div><div>-Jesse<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jun 28, 2014 at 12:01 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 class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Jesse,<br>
<br>
I'm not completely sure to really understand the axis swapping issue without<br>
reproducing what you do.<br>
The PDF driver should take into account the PDF rotation parameter when<br>
rasterizing it (so that it outputs something that is visually identical with<br>
what other PDF viewers do).<br>
<br>
To answer your questions:<br>
<br>
1) When not providing an existing target image, gdalwarp will indeed rectify<br>
images that have an arbitrary transform with skew/rotation terms, or GCPs, to<br>
an affine transform with squared pixels, which is generally the desired<br>
behaviour. If you prepare yourself the target dataset with the geotransform<br>
you whish, you should be able run gdalwarp on it. You can alternatively try<br>
the -ts option of gdalwarp to force the target dimensions.<br>
<br>
2) The resizing is a consequence of the output geotransform being different<br>
that the source geotransform.<br>
<br>
3) You could likely merge your step 1 and 2, i.e. directly generate a .png<br>
with the SRS and GCP set. However I'd recommand generating a tiled TIFF<br>
instead to make gdalwarp faster.<br>
<br>
Best regards,<br>
<br>
Even<br>
<br>
Le vendredi 27 juin 2014 19:49:35, Jesse McGraw a écrit :<br>
<div><div class="h5">> Gdal gurus,<br>
><br>
> I'm writing a utility to automatically georeference Instrument Approach<br>
> Procedures and Airport Diagrams from the FAA (<a href="http://github.com/jlmcgraw" target="_blank">github.com/jlmcgraw</a>, if<br>
> you're curious) and I'm hoping for some insight from the experts here as to<br>
> why I'm seeing the following behavior with Airport Diagrams<br>
><br>
> Most of the Airport Diagrams diagrams are portrait orientation (True North<br>
> up), however some of them are actually laid out in landscape orientation<br>
> (True North to the left or right) though the source PDF is still in<br>
> portrait<br>
><br>
> If I georeference these landscape oriented using GCPs then gdalwarp will<br>
> swap X and Y axes and also resize the resulting bitmap (it also resizes<br>
> portrait oriented ones too, though without swapping axes)<br>
><br>
> My questions:<br>
> 1) Why is gdalwarp swapping the axes rather than using the X and Y<br>
> pixel-skew parameters of the affine transformation (seems to be always 0)?<br>
> 2) Why is it re-sizing the bitmap?<br>
> 3) Do I have to do both of these steps separately (translate and then warp)<br>
> or can I simplify somehow?<br>
><br>
> Steps in the process:<br>
><br>
> 1) Generate a list of Ground Control Points from the PDF, rasterize the PDF<br>
> to a 300dpi PNG<br>
><br>
> 2) gdal_translate .PNG to an intermediate .VRT<br>
> ("gdal_translate -q -of VRT -strict -a_srs EPSG:4326 $gcpstring<br>
> '$targetpng' '$targetvrt'")<br>
><br>
> 3) gdalwarp intermediate .VRT to get the final georeferenced output .VRT<br>
> ("gdalwarp -q -of VRT -t_srs EPSG:4326 -order 1 -overwrite ''$targetvrt''<br>
> '$targetvrt2'")<br>
><br>
><br>
><br>
><br>
</div></div>> *example from a landscape diagram*<br>
<div class="">><br>
> (snippet of step 2 output from gdal_translate'd .vrt)<br>
> CA-SFO-00375AD-PDF-AIRPORT-DIAGRAM.vrt:<br>
</div>> *<VRTDataset rasterXSize="1613" rasterYSize="2475">*<br>
<div class="">><br>
> (snippet of step 3 output from gdalwarp'd .vrt)<br>
> warpedCA-SFO-00375AD.PDF-AIRPORT\ DIAGRAM.vrt:<br>
</div>> *<VRTDataset rasterXSize="2623" rasterYSize="1359"<br>
> subClass="VRTWarpedDataset">*<br>
> *<GeoTransform> -1.2242081739746585e+02, 2.9114844968978991e-05,<br>
> 0.0000000000000000e+00, 3.7641622693302779e+01, 0.0000000000000000e+00,<br>
> -2.9114844968978991e-05</GeoTransform>*<br>
><br>
><br>
> *example from a portrait diagram*<br>
<div class="">> (snippet of step 2 output from gdal_translate'd .vrt)<br>
</div>> *VA-RIC-00347AD-PDF-AIRPORT-*<br>
> *DIAGRAM.vrt*<br>
> *<VRTDataset rasterXSize="1613" rasterYSize="2475">*<br>
<div class="">><br>
> (snippet of step 3 output from gdalwarp'd .vrt)<br>
</div>> *warpedVA-RIC-00347AD.PDF-*<br>
> *AIRPORT\ DIAGRAM.vrt*<br>
><br>
><br>
><br>
> *<VRTDataset rasterXSize="1870" rasterYSize="2287"<br>
<div class="">> subClass="VRTWarpedDataset"><GeoTransform> -7.7341103107298423e+01,<br>
> 2.1580033523515700e-05, 0.0000000000000000e+00, 3.7529840835409082e+01,<br>
</div>> 0.0000000000000000e+00, -2.1580033523515700e-05</GeoTransform>*<br>
> Thanks!<br>
> -Jesse McGraw<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Geospatial professional services<br>
<a href="http://even.rouault.free.fr/services.html" target="_blank">http://even.rouault.free.fr/services.html</a><br>
</font></span></blockquote></div><br></div>