Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Greetings,

Within the ESRI SDK resources there is an example of combining polygons by use of a geometry bag. The following code appears:

    'Define the spatial reference of the bag before adding geometries to it.
    geometryBag.SpatialReference = geoDataset.SpatialReference

That makes sense, based on some of the other documentation surrounding geometry bags, but when I tried it myself, I got a compile error saying that the method didn't exist. After looking at the geometry object model diagram, it appears as if the spatial reference property of a geometry bag is read-only... so what gives?

Thanks,

DR

share|improve this question
    
If this really is VBA, don't you need to use "set"? –  Kirk Kuykendall May 9 '11 at 13:39
add comment

1 Answer

up vote 4 down vote accepted

Cast the geometry bag to an IGeometry first, then try setting its SpatialReference property.

The behavior you describe is weird, though, since IGeometryBag descends directly from IGeometry. Are you sure you are trying to set the spatial reference on the correct interface?

share|improve this answer
    
Yes, thank you, that was a simple fix. –  DuncanRager May 9 '11 at 15:40
    
@DuncanRager Please mark the answer as accepted if it answered your question. –  Philip May 10 '11 at 17:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.