[postgis-users] Convert Corrdinate Pixel to Corrdinate Spatial

ValiSystem vali.system at free.fr
Wed Apr 11 03:28:31 PDT 2007


On 11 avr. 07, at 12:14, ValiSystem wrote:

>
> On 11 avr. 07, at 05:54, anhtin wrote:
>
>>
>> hi all
>> I have Point (194, 569) is corrdinate pixel i want convert to  
>> corrdinate
>> spatial on postgis
>> How can i do that ????
>> -- 
>> View this message in context: http://www.nabble.com/Convert- 
>> Corrdinate-Pixel-to-Corrdinate-Spatial-tf3557178.html#a9932812
>> Sent from the PostGIS - User mailing list archive at Nabble.com.
>>
>
>
> Hi,
>
> This is more a gdal thing, but there is no simple tool to do that.  
> But what you can do if you want to keep most of the work in  
> postgis, is to manually convert your pixel coordinates in your  
> image spatial coordinates system, and then convert it to your final  
> coordinates system (Lat Lon for example) inside postgis using  
> Transform().
>
> Assuming that your image projection use a orthogonal coordinates  
> system (it should), converting your pixel coordinates  xp, yp in  
> your image spatial coordinates system is easy, for an image that  
> have x1,y1 for bottom left corner and x2,y2 for top left corner  
> (get it with gdalinfo) you just have to do :
>
> x = xp/width * (x2 - x1) + x1
> y = yp/height * (y2 - y1) + y1
>
> then you can do
>
> SELECT Transform(AsEWKT("SRID=<IMAGE_SRID>;POINT(<x>, <y>)"),  
> <TARGET_SRID>);
>
> to let postgis calculate the complicated thing.
>
> But your message wasn't very clear, your may just need the first  
> part of my response :)
>
>
>
>

Wooops, some typos and mistakes (damn, bad habit to avoid verify what  
i post :) )

The correct query is :

SELECT Transform('SRID=<IMAGE_SRID>;POINT(<x> <y>)',  <TARGET_SRID>);

(no comma for the WKT point coordinates and and no need of  AsEWKT()  
call )





More information about the postgis-users mailing list