<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Aptos",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:11.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='word-wrap:break-word'><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt'>The only reason I can think why QGIS and DBeaver would show something different is how they are projecting.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'>I’m guessing they are both projecting to Web Mercator or some such thing  to overlay your geometry on the map, and their assumptions about SRID </span><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>28992  are different.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>I’d try transforming both your geometries to 4326<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>ST_Transform( ST_Polygon(…), 4326)<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>I’m guessing whatever spatial projecting they do from 4326 should be consistent.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Alternatively ditch the map overlay and then maybe they won’t try to reproject.</span><span style='font-size:11.0pt'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Eloi Ribeiro <mail@eloiribeiro.eu> <br><b>Sent:</b> Thursday, March 21, 2024 11:47 AM<br><b>To:</b> PostGIS Users Discussion <postgis-users@lists.osgeo.org><br><b>Subject:</b> RE: How to properly rotate a raster<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Hi Regina and all,<o:p></o:p></p></div><div><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>I' seeing different things depending on what application I use. On QGIS the rotated raster appears smaller in width and height. On DBeaver, both rotate, although in different directions.<o:p></o:p></span></p></div><div><p class=MsoNormal style='background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>-- Create raster from polygon (<b>black line</b>)<o:p></o:p></span></p><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>DROP TABLE IF EXISTS public.rast_not_rotated;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>CREATE TABLE public.rast_not_rotated AS<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>    SELECT ST_AsRaster(t.geom,1000,1000,'8BUI',1,0) AS rast<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>    FROM (SELECT ST_GeomFromText('POLYGON((166989.36462303242 505764.77048559673,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                 166996.25788353998 505576.476318614,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                 167265.54134611748 505585.94966528506,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                 167258.67088940175 505774.2438322678,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                 166989.36462303242 505764.77048559673))',28992) geom) t;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>ALTER TABLE public.rast_not_rotated ADD COLUMN rid SERIAL PRIMARY KEY;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>CREATE INDEX rast_not_rotated_rast_gist ON public.rast_not_rotated USING gist (st_convexhull(rast));<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>SELECT AddRasterConstraints('public'::name, 'rast_not_rotated'::name,'rast'::name);<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>-- rotate previous raster (<b>blue</b>)<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>DROP TABLE IF EXISTS public.rast_rotated_from_raster;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>CREATE TABLE public.rast_rotated_from_raster AS SELECT <b>ST_SetRotation</b>(rast, <b>-0.5</b>) rast FROM public.rast_not_rotated;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>ALTER TABLE public.rast_rotated_from_raster ADD COLUMN rid SERIAL PRIMARY KEY;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>CREATE INDEX rast_rotated_from_raster_rast_gist ON public.rast_rotated_from_raster USING gist (st_convexhull(rast));<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>SELECT AddRasterConstraints('public'::name, 'rast_rotated_from_raster'::name,'rast'::name);<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>-- rotate polygon and then save as raster (<b>red</b>)<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>DROP TABLE IF EXISTS public.rast_rotated_from_vector;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>CREATE TABLE public.rast_rotated_from_vector AS<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>    SELECT ST_AsRaster(t.geom,1000,1000,'8BUI',1,0) AS rast<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>    FROM (SELECT <b>ST_Rotate</b>(<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                    ST_GeomFromText('POLYGON((166989.36462303242 505764.77048559673,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                    166996.25788353998 505576.476318614,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                    167265.54134611748 505585.94966528506,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                    167258.67088940175 505774.2438322678,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                    166989.36462303242 505764.77048559673))',28992)<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>                                    ,<b>-0.5</b>, 166989.36462303242, 505764.77048559673) geom) t;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>ALTER TABLE public.rast_rotated_from_vector ADD COLUMN rid SERIAL PRIMARY KEY;<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>CREATE INDEX rast_rotated_from_vector_rast_gist ON public.rast_rotated_from_vector USING gist (st_convexhull(rast));<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>SELECT AddRasterConstraints('public'::name, 'rast_rotated_from_vector'::name,'rast'::name);<o:p></o:p></span></p></div></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>On QGIS.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>black line - raster from polygon<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>red - the rotated polygon and then converted to raster<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>blue - rotated raster, different from how it is displayed in DBeaver.<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><br>On DBeaver this is how it shows the rotated raster.<br><br><o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal>On DBeaver this is how it shows the rotated polygon and then converted to raster.<o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;font-family:"Arial",sans-serif'><o:p> </o:p></span></p></div><div><p class=MsoNormal>On Tuesday, March 19th, 2024 at 14:58, Regina Obe <<a href="mailto:lr@pcorp.us">lr@pcorp.us</a>> wrote:<br><br><o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>An easier way to compare what is happening is to look at the ST_Polygon output of the two. <a href="https://postgis.net/docs/en/RT_ST_Polygon.html" target="_blank">https://postgis.net/docs/en/RT_ST_Polygon.html</a></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>I’m thinking the confusion (which I had thought myself) is that the width and height is measured against the X y axis, but now I think about it, I think it’s measured along the skew so width and height would remain the same in both cases. In the case of your polygon you rotate and then save as raster, the new raster is axis aligned and so there you do see the width and height change.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>So when I run this query:</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>SELECT ST_Polygon(r1.rast) AS orig_geom_rast, ST_Polygon(r2.rast) AS rotated_geom_rast, ST_Width(r1.rast) AS orig_width, ST_Width(r2.rast) AS rotated_width</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>FROM (SELECT rast FROM rast_not_rotated) AS r1,</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>(SELECT ST_SetRotation(rast, -0.5 ) AS rast FROM rast_not_rotated) AS r2;</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>The dashed polygon is the original polygon and the filled in one is after you rotate the raster. In both cases the ST_Width and ST_Height do not change so that’s not a good measure of what is going on.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><img border=0 width=387 height=391 style='width:4.0312in;height:4.0729in' id="Picture_x0020_1" src="cid:image001.png@01DA7C6A.9085DB00"><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Eloi Ribeiro <<a href="mailto:mail@eloiribeiro.eu">mail@eloiribeiro.eu</a>> <br><b>Sent:</b> Tuesday, March 19, 2024 6:56 AM<br><b>To:</b> PostGIS Users Discussion <<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>><br><b>Subject:</b> RE: How to properly rotate a raster</span><o:p></o:p></p></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Hi all,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Here an example with the code.</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>If you compare <u>rast_rotated_from_raster</u> with <u>rast_rotated_from_vector</u>, the latest is rotated as expected and the first is not.<o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>I guess, I must be doing something wrong when creating <u>rast_rotated_from_raster</u>.</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>Any guess?</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#6A9955'>-- non rotated raster</span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>DROP</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>IF</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>EXISTS</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_not_rotated;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>CREATE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#DCDCAA'>public</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>.rast_not_rotated </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>AS</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>    </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> ST_AsRaster(t.geom,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>1000</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>1000</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'8BUI'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>1</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>0</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>) </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>AS</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> rast </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>    </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>FROM</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> (</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> ST_GeomFromText(</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'POLYGON((166989.36462303242 505764.77048559673,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                 166996.25788353998 505576.476318614,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                 167265.54134611748 505585.94966528506,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                 167258.67088940175 505774.2438322678,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                 166989.36462303242 505764.77048559673))'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>28992</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>) geom) t;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ALTER</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_not_rotated </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ADD</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> COLUMN rid </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SERIAL</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>PRIMARY KEY</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>CREATE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>INDEX</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#DCDCAA'>rast_not_rotated_rast_gist</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ON</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_not_rotated </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>USING</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> gist (st_convexhull(rast));</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> AddRasterConstraints(</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'public'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>, </span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'rast_not_rotated'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'rast'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>);</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#6A9955'>-- rotate previous raster</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>DROP</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>IF</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>EXISTS</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_rotated_from_raster;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>CREATE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#DCDCAA'>public</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>.rast_rotated_from_raster </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>AS</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> ST_SetRotation(rast, </span><span style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>-</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>0</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>.</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>035162353342492736</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>) rast </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>FROM</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_not_rotated;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ALTER</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_rotated_from_raster </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ADD</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> COLUMN rid </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SERIAL</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>PRIMARY KEY</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>CREATE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>INDEX</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#DCDCAA'>rast_rotated_from_raster_rast_gist</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ON</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_rotated_from_raster </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>USING</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> gist (st_convexhull(rast));</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> AddRasterConstraints(</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'public'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>, </span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'rast_rotated_from_raster'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'rast'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>);</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#6A9955'>-- rotate polygon and then save as raster</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>DROP</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>IF</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>EXISTS</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_rotated_from_vector;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>CREATE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#DCDCAA'>public</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>.rast_rotated_from_vector </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>AS</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>    </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> ST_AsRaster(t.geom,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>1000</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>1000</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'8BUI'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>1</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>0</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>) </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>AS</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> rast </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>    </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>FROM</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> (</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> ST_Rotate(</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>                    ST_GeomFromText(</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'POLYGON((166989.36462303242 505764.77048559673,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                    166996.25788353998 505576.476318614,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                    167265.54134611748 505585.94966528506,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                    167258.67088940175 505774.2438322678,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>                                    166989.36462303242 505764.77048559673))'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>28992</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>)</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>                                    ,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#D4D4D4'>-</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>0</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>.</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>035162353342492736</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>, </span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>166989</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>.</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>36462303242</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>, </span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>505764</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>.</span><span style='font-size:10.5pt;font-family:"Courier New";color:#B5CEA8'>77048559673</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>) geom) t;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ALTER</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>TABLE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_rotated_from_vector </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ADD</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> COLUMN rid </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SERIAL</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>PRIMARY KEY</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>CREATE</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>INDEX</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#DCDCAA'>rast_rotated_from_vector_rast_gist</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>ON</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> public.rast_rotated_from_vector </span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>USING</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> gist (st_convexhull(rast));</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'> AddRasterConstraints(</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'public'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>, </span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'rast_rotated_from_vector'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>,</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CE9178'>'rast'</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>::</span><span style='font-size:10.5pt;font-family:"Courier New";color:#569CD6'>name</span><span style='font-size:10.5pt;font-family:"Courier New";color:#CCCCCC'>);</span><o:p></o:p></p></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Eloi</span><o:p></o:p></p></div></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div></div></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>On Monday, March 18th, 2024 at 19:11, Eloi Ribeiro <<a href="mailto:mail@eloiribeiro.eu" target="_blank">mail@eloiribeiro.eu</a>> wrote:<o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Hi Regina and all,</span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Elaborating a bit more. I have a vector layer consisting of a rectangle (farm plot), and this rectangle is subdivided into several (polygons) stripes parallel to the outer edge of the rectangle. I want to produce a raster where the rectangle and stripes long edges are parallel to the latitude line.</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Using ST_Rotate(geom, -0.035, x, y) in all vector layers together with ST_AsRaster(), I managed to get what I want. Good.</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Nevertheless, if I first produce the raster and then try to rotated it using ST_SetRotation(rast, -0.035), I barely see any rotation. In this step, I must be doing something wrong.</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>I would like to first rasterize vector and then rotate the raster. Instead of rasterize non rotated vector and then, again rasterize rotated vector.</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt;background:white'><span style='font-size:10.5pt;font-family:"Arial",sans-serif;color:black'>The change in size (width and height), I mentioned in my first message, was while testing with 0.5 rad, not with -0.035 rad.</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- input raster</span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-family:"Courier New";color:#CCCCCC'> ST_Width(rast), ST_Height(rast), ST_SkewX(rast) </span><span style='font-family:"Courier New";color:#569CD6'>FROM</span><span style='font-family:"Courier New";color:#CCCCCC'> plot_3;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--  st_width | st_height | st_skewx </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- ----------+-----------+----------</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--      1000 |      1000 |        0</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#CCCCCC'> </span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- output raster of ST_SetRotation(rast, -0.035162353342492736)</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-family:"Courier New";color:#CCCCCC'> ST_Width(rast), ST_Height(rast), ST_SkewX(rast) </span><span style='font-family:"Courier New";color:#569CD6'>FROM</span><span style='font-family:"Courier New";color:#CCCCCC'> plot_3_rotated_from_raster;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--  st_width | st_height |       st_skewx       </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- ----------+-----------+----------------------</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--      1000 |      1000 | 0.006952538312005269</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#CCCCCC'> </span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- output raster of ST_SetRotation(rast, -0.035162353342492736)</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-family:"Courier New";color:#CCCCCC'> ST_Width(rast), ST_Height(rast), ST_SkewX(rast) </span><span style='font-family:"Courier New";color:#569CD6'>FROM</span><span style='font-family:"Courier New";color:#CCCCCC'> plot_3_rotated_from_vect;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--  st_width | st_height | st_skewx </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- ----------+-----------+----------</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--       977 |       964 |        0</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#CCCCCC'> </span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- output raster of ST_SetRotation(rast, -0.5)</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#569CD6'>SELECT</span><span style='font-family:"Courier New";color:#CCCCCC'> ST_Width(rast), ST_Height(rast), ST_SkewX(rast) </span><span style='font-family:"Courier New";color:#569CD6'>FROM</span><span style='font-family:"Courier New";color:#CCCCCC'> plot_3_rotated_from_raster_05;</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--  st_width | st_height |      st_skewx       </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>-- ----------+-----------+---------------------</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-family:"Courier New";color:#6A9955'>--      1000 |      1000 | 0.09481479675190897</span><o:p></o:p></p></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Cheers,</span><o:p></o:p></p></div><div><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Eloi</span><o:p></o:p></p></div></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div></div></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'>On Monday, March 18th, 2024 at 14:01, Regina Obe <<a href="mailto:lr@pcorp.us" target="_blank">lr@pcorp.us</a>> wrote:<o:p></o:p></p><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>By size, what do you mean exactly? It would change the width and height.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>What are you expecting rotation to do. Perhaps you can give example out of the below and some sample</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'>ST_Width, ST_Height, ST_SkewX before and after and what you were expecting.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'><a href="https://postgis.net/docs/en/RT_ST_SetRotation.html" target="_blank">https://postgis.net/docs/en/RT_ST_SetRotation.html</a></span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:11.0pt'> </span><o:p></o:p></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Eloi Ribeiro <<a href="mailto:mail@eloiribeiro.eu" target="_blank">mail@eloiribeiro.eu</a>> <br><b>Sent:</b> Monday, March 18, 2024 4:57 AM<br><b>To:</b> PostGIS Users Discussion <<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a>><br><b>Subject:</b> How to properly rotate a raster</span><o:p></o:p></p></div></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Hi all,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;margin-bottom:12.0pt'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>I need to rotate a raster, for that I'm using the function </span><code><b><span style='font-size:10.0pt'>ST_SetRotation</span></b></code><code><span style='font-size:10.0pt'>, like so:</span></code><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;line-height:14.25pt;background:#1F1F1F'><span style='font-size:10.5pt;font-family:"Courier New";color:#6A9955'>CREATE TABLE plot_3_rotated AS <br>SELECT ST_SetRotation(rast, 0.03516235334249185) rast <br>FROM plot_3;</span><o:p></o:p></p></div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>But I see that is not producing the expected results and is changing size of the raster. What am I doing wrong?<br><br>Cheers,</span><o:p></o:p></p></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div><div><div><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'>Eloi</span><o:p></o:p></p></div></div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.5pt;font-family:"Arial",sans-serif'> </span><o:p></o:p></p></div></div></div></div></div></blockquote><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p></div></blockquote><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p></div></div></div></blockquote><p class=MsoNormal><o:p> </o:p></p></div></div></div></body></html>