comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: optimization; which point falls into a polygon
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: optimization; which point falls into a polygon [message #68027] Wed, 23 September 2009 08:56 Go to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Sep 23, 9:11 am, Klemen <klemen.zak...@gmail.com> wrote:
> Thank you both for suggestions, I will try both.
>
>> Is there an analytic expression for the satellite pixel corners, or do
>> you really have to go from the data? I'm trying to figure out if you
>> can directly compute it...
>
> Well, I have a layer containing latitude and longitude of each center
> point - from these coordinates I estimate the corners positions.

See the help on map_proj_forward and map_proj_inverse. They may be
useful to convert between latitude/longitude and pixel values,
depending on how your GIS rasters are sampled. ROIs as suggested above
are a more general way to find if points are in polygons, and are
useful in more situations, so I do not know which way will be more
appropriate for your case.
Re: optimization; which point falls into a polygon [message #68028 is a reply to message #68027] Wed, 23 September 2009 08:08 Go to previous messageGo to next message
hethomas is currently offline  hethomas
Messages: 19
Registered: December 2008
Junior Member
I did something similar a while ago for non-geostationary satellite
data..... I found the corner coordinates and used these to draw lines
around each pixel. I could then find out which points landed within
each pixel by using gt or lt expressions for the lines as compared to
the points.
Re: optimization; which point falls into a polygon [message #68030 is a reply to message #68028] Wed, 23 September 2009 05:11 Go to previous messageGo to next message
Klemen is currently offline  Klemen
Messages: 80
Registered: July 2009
Member
Thank you both for suggestions, I will try both.

> Is there an analytic expression for the satellite pixel corners, or do
> you really have to go from the data? I'm trying to figure out if you
> can directly compute it...

Well, I have a layer containing latitude and longitude of each center
point - from these coordinates I estimate the corners positions.
Re: optimization; which point falls into a polygon [message #68032 is a reply to message #68030] Wed, 23 September 2009 04:46 Go to previous messageGo to next message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
Something akin to JD's match_2d might work... it would at least tell
you the closest corner of a satellite pixel for each GIS point, and is
probably faster than building a triangulation.

Is there an analytic expression for the satellite pixel corners, or do
you really have to go from the data? I'm trying to figure out if you
can directly compute it...

-Jeremy.

On Sep 22, 5:57 pm, Klemen <klemen.zak...@gmail.com> wrote:
> Hi,
>
> I am working with geostationary satellite data and some GIS rasters.
> The satellite data do not have a regular sampling (pixel has a form of
> a parallelogram) but I know corner coordinates of each pixels.
>
> I would like to do some kind of spatial join - I would like to know
> which of my pixels in GIS rasters (regularly sampled) fall into each
> satellite pixel – I would like to create a raster where each GIS pixel
> contains an index of the corresponding satellite index. This can be
> easily done using 4 for loops when the GIS raster is small. However, I
> would like to do this on a 1000 * 1000 large GIS layer. Satellite data
> have factor 3 less pixels in one direction and factor 6 less pixels in
> the other direction. Such a way is then really time consuming.
>
> How to do it faster? I was reading of triangulation, but this would
> probably mean that I would have to triangulate each GIS raster point
> with satellite centre points and then check in which of four closest
> satellite pixels falls the raster pixel. But I can imagine, that
> building a triangulation for a million times is also not really fast.
>
> Does anybody have a suggestion?
>
> Thank you in advance!
> Klemen
Re: optimization; which point falls into a polygon [message #68033 is a reply to message #68032] Wed, 23 September 2009 04:38 Go to previous messageGo to next message
Maarten[1] is currently offline  Maarten[1]
Messages: 176
Registered: November 2005
Senior Member
On Sep 22, 11:57 pm, Klemen <klemen.zak...@gmail.com> wrote:

> I am working with geostationary satellite data and some GIS rasters.
> The satellite data do not have a regular sampling (pixel has a form of
> a parallelogram) but I know corner coordinates of each pixels.
>
> I would like to do some kind of spatial join - I would like to know
> which of my pixels in GIS rasters (regularly sampled) fall into each
> satellite pixel – I would like to create a raster where each GIS pixel
> contains an index of the corresponding satellite index.

[snip]

> Does anybody have a suggestion?

Approach from the other direction.

The IDLanROI class can do this for you. Loop over all Satellite
pixels, and create an IDLanROI object for it, using the corner
coordinates. Use the ContainsPoints method to figure out which GIS
raster point fall in this Satellite grid cell. ContainsPoints is array
aware. Use where on the result, and set the result in your destination
array to the intended value.

Caveats: Since you are geostationary, you won't have to deal with the
poles, but the dateline might be an issue. The correct way is to do
everything in Cartesian coordinates, but I never bothered.

Maarten
Re: optimization; which point falls into a polygon [message #68212 is a reply to message #68027] Fri, 25 September 2009 02:13 Go to previous message
Klemen is currently offline  Klemen
Messages: 80
Registered: July 2009
Member
> See the help on map_proj_forward and map_proj_inverse. They may be
> useful to convert between latitude/longitude and pixel values,

I process already projected data (Lambert conformal projection). I am
also trying to write a shape file at the same time, so I can check
each pixel to be sure.

I have tried the suggested solutions and I think the optimal for me is
ROI way. It took 27s to get the results on a layer with 200 by 200
pixels; geostatioary image has in this case 74 * 45 pixels.

I have tried also JD's match_2d to get the closest point and then I
wanted to proceed by approach suggested by hethomas, however, it took
me 45s just to compute the closest satellite centre point (without
checking if GIS point really fits into the polygon)...

But I would have gone for such a similar approach if I hadn't asked
you for an advice before. So thank you all.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Smoothing 3D array with periodic boundaries: what am I missing?
Next Topic: Re: Point Spread Function Simulation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:07:15 PDT 2025

Total time taken to generate the page: 0.00747 seconds