Extract Multi Values to Points: correct values in GUI, incorrect values with Python

778
8
09-02-2013 08:12 AM
Joffreybaratheon
New Contributor
Hello,

I just ran into a strange problem, which surely has a logical explanation and an easy workaround, but I just can't seem to find it.

Let's assume I have a raster "raster1.tif" (Pixel type: unsigned integer, Pixel depth: 8 bit, 6 bands) and a point shapefile "points.shp". Both layers have the same projection.

I now want to extract point values of raster1 at locations specified by "points". I can do this in the GUI with the Extract Multi Values to Point-Tool and the result is as expected. For example, band 1 of "raster1.tif" has values in a range between 60 and 100, and points.shp has a column called "b1_raster1" with a range of 70-90.

However, I need to do this in Python. I write the corresponding code and execute it. No errors are given. However, when I check the values in points.shp, the column "b1_raster1" has values in a range between 9-12.

Here's the python code:

 
in_shp = "points.shp"
in_raster = "raster1.tif"
ExtractMultiValuesToPoints(in_shp, in_raster, "NONE")


I'd be grateful for any input. 🙂
0 Kudos
8 Replies
curtvprice
MVP Esteemed Contributor
Let's assume I have a raster "raster1.tif" (Pixel type: unsigned integer, Pixel depth: 8 bit,   6 bands) and a point shapefile "points.shp".


I think the multiband raster may be your issue. To specify the band you want, you need to specify its full path (the syntax varies by raster data type). For example:

 
in_shp = "points.shp"
in_raster = "raster1.tif/Band_1"
ExtractMultiValuesToPoints(in_shp, in_raster, "NONE")


The easiest way to find path for the band you want is to browse the raster in the Catalog window.
0 Kudos
Joffreybaratheon
New Contributor
I think the multiband raster may be your issue.  To specify the band you want, you need to specify its full path (the syntax varies by raster data type). For example:

 
in_shp = "points.shp"
in_raster = "raster1.tif/Band_1"
ExtractMultiValuesToPoints(in_shp, in_raster, "NONE")


The easiest way to find path for the band you want is to browse the raster in the Catalog window.


I will test this tomorrow when I'm at work.
However, the ArcGIS help about the Extract Multi Values to Points-Toll says:

"Any combination of rasters (single band or multiband) can be specified as input."
and:
"When the input is a multiband raster, a field will be added for all bands with a "b1_, b2_, �?�bn" prefix added to the name of the output field denoting the band number."

Also, in the GUI, I select the multiband raster as input, not individual bands, and it works fine.

But I'll still try it tomorrow. 😉
0 Kudos
curtvprice
MVP Esteemed Contributor
These tools (Extract Values to Points and Extract Multi Values To Points, Sample) have a history of being flakey from 9.x to the present.

My theory is there are a lot of ways for these seemingly simple tools to not work right, given all the raster formats, project on the fly etc., and since there are at least three tools that use the same thing, users don't report, and the bugs persist.

So, if this turns out to be a bug, please report it!
0 Kudos
Joffreybaratheon
New Contributor
So, I made a few more tests and the results are very inconsistent...

in_raster = ["raster_a.tif", "raster_b.tif", "raster_c.tif", "raster_d.tif", "raster1.tif"]
ExtractMultiValuesToPoints(in_shp, in_raster, "NONE")


-> "raster_a.tif" - "raster_d.tif" are floating points, and the values in points.shp seem to be correct for those raster.
For "raster1.tif" (integer), all bands have wrong values as described in my original post.


in_raster = "raster1.tif"
ExtractMultiValuesToPoints(in_shp, in_raster, "NONE")


-> The first 4 bands of "raster1.tif" have correct values in "points.shp", however band 5 and 6 have wrong values.

in_raster = "raster1.tif/Band_6"
ExtractMultiValuesToPoints(in_shp, in_raster, "NONE")


-> Correct values for band 6 of "raster.tif".

So, it seems indeed that this tool is quite buggy, thanks for the pointers in the right direction! 🙂
0 Kudos
Joffreybaratheon
New Contributor
Haha, I just thought of a workaround and googled to see if somebody already implemented it in python. Doing this, I found this:

http://support.esri.com/fr/knowledgebase/techarticles/detail/41145

This doesn't seem to be exactly the same bug, but it comes pretty close and the workaround should work.
0 Kudos
curtvprice
MVP Esteemed Contributor
Haha, I just thought of a workaround and googled to see if somebody already implemented it in python. Doing this, I found this:

http://support.esri.com/fr/knowledgebase/techarticles/detail/41145

This doesn't seem to be exactly the same bug, but it comes pretty close and the workaround should work.


The bug referenced above is:

#NIM085128 - The Extract Multi Values to Points tool reports only the first band and repeats the val...

Reportedly fixed in "10.2.1" ie when 10.2 SP1 comes out in a few months. Report those bugs!
0 Kudos
JuanLaguna
Esri Contributor
Hello, Joffrey.

This is Juan here, from the Spatial Analyst team at Esri.

I'm sorry you're having problems with this tool.

Is it possible for you to provide me a simplified dataset and scenario that replicates the problem?  With that, I will test it against the most current version of the software to make sure it has been resolved.

If you would, can you please enable the Messaging functionality so we can discuss this further?  To do that, when you are logged in with your Global account, click on Settings, then in the My Settings section, click on User Control Panel.  In the Messaging & Notification section, change the Private Messaging option to On.  Once that is done, please send me a message so we can get the details for delivering the test data sorted out. 

Thanks,

Juan
0 Kudos
Joffreybaratheon
New Contributor
Hi Juan,

I just enabled Messaging in my account, and I could send you my data if you tell me your preferred form of delivery (is a dropbox link ok?).
0 Kudos