`

how to locate a point into a raster via maths method

阅读更多
Hi pierre:
     I have not solve the problem,to improve the speed of function  ST_WorldToRasterCoord() function . so accodording to your advice,  To make the query faster you could simply do the math yourself without
> relying on the ST_WorldToRasterCoord() function.  We do the math by ourselves. Here comes the procedure.
    1) draw an enveloping rectangle to contain the polygon of a certain city.  Get the coordinates of the 4 point of the enveloping rectangle. They are the (minX,maxY) , (maxX,maxY), (minx,minY), (maxX,minY).  
   2)  Transfer the point (maxX,maxY) into a point object int the space, via the function: (st_geomfromtext('POINT('|| maxx ||' '|| maxy ||')',4326), in this function we get the point Geographic Coordinate System.
3)Convert  the Geographic Coordinate System into the XI’AN 84 Coordinate System.( which is a geodetic coordinate system ) via the function: 
(st_transform(st_geomfromtext('POINT('|| maxx ||' '|| maxy ||')',4326),2382)
3)Transfer the point (minX,maxY) into a point object int the space .
4) Calculate the distance between thepoint(maxX,maxY)and the point(minX,maxY) via the function :
st_distance(st_transform(st_geomfromtext('POINT('|| maxx ||' '|| maxy ||')',4326),2382), st_transform(st_geomfromtext('POINT('|| minx ||' '|| maxy ||')',4326),2382)).   The unit of result is Meter.
5)Suppose the size of the raster is 100 meters. We can find out width of the raster.
   According to the same method, we can also find out the height of the raster.
6) Now we can do a maths method like the  ST_WorldToRasterCoord() function .  the SQL language looks like the fllows:
update sample  set (x,y) =
(
round(((longitude-minx)/width)*b.x+0.5),
round(((maxy-latitude)/height)*b.y+0.5)
)from city_xy b where b.name = city and sample.x is null;--get x y
update sample set geom = st_geomfromtext('point('||longitude||' '||latitude||')',4326)
where geom is null;--创建点对象

    Although we have solve th problem, yet it is a great pity,we use the function of geometry, not the function of the raster. How I hope ,  there will be a plan to improve  the function ST_WorldToRasterCoord() function . what is more could you please forword the mail to the author of the function ST_WorldToRasterCoord(), I will write more on my suggestion on that function. That is really a very important function in our project.
     Lastly,I still can not understand the idea, One way to improve everything is to tile the raster into small tiles (10x10) and to index them while loading the raster into the database. So far as I know, we can add index to the GEOM object via the GIST index, yet I still do not know how can we add index to the raster object. Hope you coluld show me an example.
  Recently we have a lot of projects on the geom and raster intersection, I have already known the power of postgis geom. Object,   yet I still do not find the approach to manage the raster object in a more efficeny way, for example to add index to the raster,  how you will guide us in this area.
zhanying
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics