Thanks Mari,
The other option I was looking at was to run ROIMaskRaster on each of the rois. Then extract the data. I have not tried this.
I did implement the classic method. When I extracted values I still ended up with zeros. I also printed out the number of points in each roi, they were also zero. So I suspect my problem starts before the VectorRecordsToSeparateROI.
My original vector has 904 records. I created a new vector that is a subset by record, of the original. The new vector has 113 records. The new vector does have valid polygons that match the corresponding polygon in the original vector file. The only difference I can see is that the new vector has an arbitrary projection instead of the UTM projection of the original. I used OBJ_NEW( 'IDLffShape', test_file, /UPDATE, ENTITY_TYPE=5 ) to create the new vector, but I could not find any way to set the projection.
It appears that not having the projection set causes VectorRecordsToSeparateROI to produce rois with zero points. I changed my code to run VectorRecordsToSeparateROI on the original vector and rois that were created had varying numbers of points as I would expect.
So, it looks my problem is related to creating a new vector, subsetting it by records and not being able to set the projection information. How would I set the projection on the new vector?
Is the method I am using to subset a vector by records the best way, or is there an easier way to subset a vector by records?
Below is generally the code I have been using to subset the vector by records.
mynewshape = OBJ_NEW( 'IDLffShape', test_file, /UPDATE, ENTITY_TYPE=5 )
mynewshape->AddAttribute, 'CLASS_NAME', 7, 25, PRECISION=0
mynewshape->AddAttribute, 'AREA', 5, 15, PRECISION=8
mynewshape->AddAttribute, 'CLASS_CLRS', 7, 25, PRECISION=0
mynewshape->AddAttribute, 'MEAN', 5, 15, PRECISION=8
mynewshape->AddAttribute, 'MAXIMUM', 5, 15, PRECISION=8
attrNew = mynewshape.GetAttributes( /ATTRIBUTE_STRUCTURE )
index = WHERE( attributes[*].attribute_0 EQ TopClassName, count )
FOR i=0, (count-1) DO BEGIN
attname = attributes[ index[i] ].attribute_0
ent = shape->GetEntity( index[i] )
attrNew.attribute_0 = attributes[ index[i] ].attribute_0
attrNew.attribute_1 = attributes[ index[i] ].attribute_1
attrNew.attribute_2 = attributes[ index[i] ].attribute_2
mynewshape->PutEntity, ent
mynewshape->SetAttributes, i, attrNew
shape->DestroyEntity, ent
ENDFOR
|