Friday, 9 October 2015

qgis - How to convert Raster image to Shapefile WITHOUT flipping it upside down


I am using QGIS v 3.2.1 to convert Raster image to Shapefile


Unfortunately the resulting shapefile is upside down.


How to keep resulting shapefile right side up



Here is animated gif (link on GitHub)



Answer



If you want to show a camera picture of a coffee cup on a QGIS map you need to know some rules of the play. Images viewed by QGIS are usually georeferenced and if they are not then the default GeoTransform of GDAL is applied https://www.gdal.org/classGDALDataset.html#a5101119705f5fa2bc1344ab26f66fd1d.


The default transform is (0,1,0,0,0,1) which means that the Y coordinate is increasing line by line. Because QGIS is made to show maps the value of Y-axis is growing from bottom to top (because the equator has north coordinate of zero). This means that after the first line is drawn the next line will be drawn with y-coordinate increased by 1, so it goes above the first line and the image will be flipped.


As a workaround write a world file https://en.wikipedia.org/wiki/World_file for you coffee cup.


coffee_cup.wld
==============
1
0
0

-1
0
0

Value of -1 as the y-pixel size should turn your coffee cup so that it does not spill.


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...