I use the following line of code to define the extent setting of the environments GP.Extent = "144566.589424822 351191.130242809 145772.160224822 353810.742942809". However, I need to define it programmatically via the boundaries of a layer like the procedure is carried out in any relevant window (e.g. in Clip window) :'Environments'-'General Settings'-'Extent'-'Same as layer...'. Thanks Demetris

2 Answers 2


You can use the following code to find the rectangular extent of a feature. This will format it to a string you can use as an input to a geoprocessing tool or use it to set GP.Extent.

Dim pEnvelope As IEnvelope = pFeature.Shape.Envelope
Dim rectangle As String = ""
rectangle &= pEnvelope.XMin & " " & pEnvelope.YMin & " " & pEnvelope.XMax & " " & pEnvelope.YMax

The interface IGeoDataset can be used to return the extent of a layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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