Select to view content in your preferred language

controlling feature class extent

976
1
05-30-2013 10:16 AM
CyndyBresloff
Emerging Contributor
Hello,

I have a feature class, that I call into a Python script, that I then convert to a raster, and perform a conditional statement with, with another raster.  The input feature class - and the derived raster from it - has a different, smaller, extent than the other raster I perform the conditional with.  Within the conditional statement, the feature class derived raster is part of the conditional statement; ie: basically I say 'where the feature class derived raster is null, use the other raster's value; else, use the feature class raster value".  The output result is of the extent of the feature class raster, and I need the extent to be of the other raster that is input in the statement.

Let me make that easier to follow 🙂

statement:
outCon = Con( IsNull(Raster("OutRaster")), Raster(gR), (Raster(gR) + 1.0))


OutRaster is the raster derived from the feature class. gR is a random raster.

I need outCon to have the extent of gR.  I cannot seem to do this for love of chocolate!  I tried to set the environment extent to what I need, but that appears to have no effect.  How can I make this work? 

Please let me know if I need to clarify my problem.  Thanks!

Cyndy
Tags (2)
0 Kudos
1 Reply
RhettZufelt
MVP Notable Contributor
Basically you are telling it to create a "copy" of the OutRaster file named outCon and changing the values in it depending on your where clause (looks at each cell of conditional raster and assigns a value based on clause).  So, it will create a raster the same size/extent of the OutRaster as it evaluates all cells in the conditional raster layer.

To match the extent of the gR raster, you could try the arcpy.env.mask = gR setting before the con statement as SA tools are all supposed to honor masks:  http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001w0000001t000000

If you have problems with mask, another way would be to clip the OutRaster to the extend of the gR raster before the con statement.


R_
0 Kudos