I'm trying to undertake some analysis on several raster data sets but am having some trouble. I have a DEM of my study area and a raster of population data for my study area. I am now trying to calculate the population numbers below a certain elevation using the elevation data derived from the DEM.

I know I have to use the raster calculator but am not savvy whatsoever with the use of python commands. Are there any sources where i can learn to better use python for this purpose or direct information?

  • 1
    Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq.
    – underdark
    Mar 20, 2016 at 13:43

2 Answers 2


There are a couple of different ways to approach this. I think these steps would be the most straightforward: 1) Calculate contour lines from your DEM 2) ID the the contour lines for your elevation threshold. 3). Then either split the population raster with the contour line or convert the contour to a polygon & then clip the population with the polygon.

It might also work to recode your DEM so that all values within your elevation threshold have a value of 1 and all others have a value 0. Then you can multiply the two rasters. However, I haven't tried this approach before, so I'm not sure how it will work out.


When you say " I am now trying to calculate the population numbers below a certain elevation..." I assume what you are actually asking is extract the population where the elevation is below a certain height?

This can be done simply with one tool, no python. You want to use the CON tool.

Your conditional raster would be the DEM, true raster would be your population raster, false raster just left blank to mean NODATA and the where clause would be something like [value] < 1000.

  • Yes that's what i meant and thank you. That's of great help
    – N.Monreal
    Mar 21, 2016 at 16:06
  • Hi o still just having a bit of trouble. As far as i can tell the code i should be inputting is con(DEM,Population <=2) to extract the population under two feet can you confirm if this correct ?
    – N.Monreal
    Mar 23, 2016 at 15:11
  • Use the CON tool first, get that working and IF you need to automate with python then you could look at the python snippet via the results window to see exactly how you should write it in a scripting environment.
    – Hornbydd
    Mar 23, 2016 at 15:26
  • Ok, but is my usage of the CON tool correct as i put it above to extract the populations at certain elevations. If not i would be greatly appreciative if you could point me in the right direction, many thanks
    – N.Monreal
    Mar 23, 2016 at 15:29
  • If you could write out the con command as i would input it i would be very grateful, just struggling to get my head round it
    – N.Monreal
    Mar 23, 2016 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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