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

Home » Public Forums » archive » Re: How to extract pixel values from a GeoTIFF using an Esri Shapefile
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: How to extract pixel values from a GeoTIFF using an Esri Shapefile [message #74060] Sat, 01 January 2011 10:32 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul Magdon writes:

> In my case both the shape and the raster are in UTM projection which
> is already a Cartesian projection. So why should I convert them into a
> lat/long projection?

Right. Stay away from lat/lon projections if you want
things to make sense. :-)

> @David: I send send you the example files or is there an option to
> 'post' them here?

You can just send them to me or put them in a place
where I can pick them up. I am reluctant to publish
my e-mail on a newsgroup, since my spam will increase
10-fold. But my name is David and I live at the same
place as Coyote. :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: How to extract pixel values from a GeoTIFF using an Esri Shapefile [message #74061 is a reply to message #74060] Sat, 01 January 2011 10:24 Go to previous messageGo to next message
Paul Magdon is currently offline  Paul Magdon
Messages: 8
Registered: January 2011
Junior Member
On Dec 25 2010, 4:34 pm, David Fanning <n...@dfanning.com> wrote:
> Paul Magdon writes:
>> I tried your suggestion to use ROI_XRANGE and got the following Error:
>> % Keyword ROI_XRANGE not allowed in call to: OBJ_NEW
>> As fare as I understand the IDL documentation  ROI_XRANGE can not be
>> set for an IDLanROI object.
>
> Ah, right, I didn't notice that. Sorry. :-)
>
> OK, then I suppose you have to convert the pixel
> locations into the same units as the ROI (probably
> lat/lon). If your image coordinates are in projected
> XY space, then you put them into lat/lon space with
> Map_Proj_Inverse. Map_Proj_Forward goes the other way.
>
> I tend to *always* work in projection XY space, so
> I would probably convert the shape file to these
> coordinates before I stored them in the ROI.
>
> Anyway, if you send me the files, I'll write up an
> example for you, although I can't promise to be
> quick about it, unfortunately. Too much going on
> here, and money is running out faster than my
> fingers can type. :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Hi,
In my case both the shape and the raster are in UTM projection which
is already a Cartesian projection. So why should I convert them into a
lat/long projection?
@David: I send send you the example files or is there an option to
'post' them here?
Cheers Paul
Re: How to extract pixel values from a GeoTIFF using an Esri Shapefile [message #74078 is a reply to message #74061] Sat, 25 December 2010 07:34 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul Magdon writes:

> I tried your suggestion to use ROI_XRANGE and got the following Error:
> % Keyword ROI_XRANGE not allowed in call to: OBJ_NEW
> As fare as I understand the IDL documentation ROI_XRANGE can not be
> set for an IDLanROI object.

Ah, right, I didn't notice that. Sorry. :-)

OK, then I suppose you have to convert the pixel
locations into the same units as the ROI (probably
lat/lon). If your image coordinates are in projected
XY space, then you put them into lat/lon space with
Map_Proj_Inverse. Map_Proj_Forward goes the other way.

I tend to *always* work in projection XY space, so
I would probably convert the shape file to these
coordinates before I stored them in the ROI.

Anyway, if you send me the files, I'll write up an
example for you, although I can't promise to be
quick about it, unfortunately. Too much going on
here, and money is running out faster than my
fingers can type. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: How to extract pixel values from a GeoTIFF using an Esri Shapefile [message #74079 is a reply to message #74078] Sat, 25 December 2010 05:32 Go to previous messageGo to next message
Paul Magdon is currently offline  Paul Magdon
Messages: 8
Registered: January 2011
Junior Member
On 23 Dez., 22:34, David Fanning <n...@dfanning.com> wrote:
> Paul Magdon writes:
>> ;Convert SHP to ROI object
>> myroi = OBJ_NEW( 'IDLanROI',( *ent.vertices)[0,*] ,(*ent.vertices)
>> [1,*] )
>
>> ;Apply ComputMask method
>> maskResult = myroi -> ComputeMask(DIMENSIONS = [s[0],
>> s[1]],MASK_RULE=2)
>
>> ; Here starts the problem;  I have a 5000x5000 raster (img) and the
>> image coordinate system start with [0,0] but the myroi coordinates are
>> much higher (eg  227984.00 ; 991472.00) Thus everything is masked.
>> ;There is a keyword LOCATION for ComputeMask but I am not sure how to
>> use it and where to get the right values for it
>
> I have to admit I have never done this before. (Although
> I would like to try if you could make the image and
> shape file available to me.) But, it seems to me
> that when you create the ROI, you will have to give
> the ROI the range of the image to make this work.
>
>    mapCoord -> GetProperty, XRANGE=xr, YRANGE=yr
>    myroi = OBJ_NEW( 'IDLanROI',( *ent.vertices)[0,*] ,$
>       (*ent.vertices)[1,*], ROI_XRANGE=xr, $
>       ROI_YRANGE=yr )
>
> That way, the ROI and the image are mapped to the same
> coordinate system.
>
> I'm curious to know if that works. :-)
>
> Cheers,
>
> David
>
> P.S. The next book I am thinking of writing is a small
> book about map projections in IDL. The more examples I
> have like this, the better. I have to write this book
> before I forget everything I've learned in the past four
> years. :-)
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")


Dear David,
sorry for my late reply but as we have Christmas there are other
duties as well :) . By the way: merry Christmas!
I tried your suggestion to use ROI_XRANGE and got the following Error:
% Keyword ROI_XRANGE not allowed in call to: OBJ_NEW
As fare as I understand the IDL documentation ROI_XRANGE can not be
set for an IDLanROI object.
Today I will try to use the LOCATION keyword or find an other option
to transfer the UTM coordinates into proper pixel coordinates.
I will send you a shp + corresponding raster as soon as possible.
Cheers,
Paul
Re: How to extract pixel values from a GeoTIFF using an Esri Shapefile [message #74091 is a reply to message #74079] Thu, 23 December 2010 13:34 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Paul Magdon writes:

> ;Convert SHP to ROI object
> myroi = OBJ_NEW( 'IDLanROI',( *ent.vertices)[0,*] ,(*ent.vertices)
> [1,*] )
>
> ;Apply ComputMask method
> maskResult = myroi -> ComputeMask(DIMENSIONS = [s[0],
> s[1]],MASK_RULE=2)
>
> ; Here starts the problem; I have a 5000x5000 raster (img) and the
> image coordinate system start with [0,0] but the myroi coordinates are
> much higher (eg 227984.00 ; 991472.00) Thus everything is masked.
> ;There is a keyword LOCATION for ComputeMask but I am not sure how to
> use it and where to get the right values for it

I have to admit I have never done this before. (Although
I would like to try if you could make the image and
shape file available to me.) But, it seems to me
that when you create the ROI, you will have to give
the ROI the range of the image to make this work.

mapCoord -> GetProperty, XRANGE=xr, YRANGE=yr
myroi = OBJ_NEW( 'IDLanROI',( *ent.vertices)[0,*] ,$
(*ent.vertices)[1,*], ROI_XRANGE=xr, $
ROI_YRANGE=yr )

That way, the ROI and the image are mapped to the same
coordinate system.

I'm curious to know if that works. :-)

Cheers,

David

P.S. The next book I am thinking of writing is a small
book about map projections in IDL. The more examples I
have like this, the better. I have to write this book
before I forget everything I've learned in the past four
years. :-)


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: How to extract pixel values from a GeoTIFF using an Esri Shapefile [message #74195 is a reply to message #74060] Mon, 03 January 2011 04:30 Go to previous message
Paul Magdon is currently offline  Paul Magdon
Messages: 8
Registered: January 2011
Junior Member
On 1 Jan., 19:32, David Fanning <n...@dfanning.com> wrote:
> Paul Magdon writes:
>> In my case both the shape and the raster are in UTM projection which
>> is already a Cartesian projection. So why should I convert them into a
>> lat/long projection?
>
> Right. Stay away from lat/lon projections if you want
> things to make sense. :-)
>
>> @David: I send send you the example files or is there an option to
>> 'post' them here?
>
> You can just send them to me or put them in a place
> where I can pick them up. I am reluctant to publish
> my e-mail on a newsgroup, since my spam will increase
> 10-fold. But my name is David and I live at the same
> place as Coyote. :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Hi David,
did you received my mail with the test dataset? I don't want to
stress you it's just that I am not sure if I used the right E-mail
adress :)
Cheers
Paul
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: division to move a decimal point
Next Topic: array handling

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

Current Time: Wed Oct 08 11:40:19 PDT 2025

Total time taken to generate the page: 0.00606 seconds