I'm starting on a problem where I need to find the high point inside a polygon that exists inside the bounds of a DEM tile. I'm teaching myself GDAL and I'll be using Python to access the GDAL library. I've see Zonal Statistics, but isn't quite what I need. I need the elevation, AND longitude, latitude.

My impression is that I need to INTERSECT the polygon with the raster tile (ArcGrid, Geotiff) and extract an array of points (x,y,z) from the DEM. Then analyze the array of points.

In my learning, I need to figure out how to put these words into commands.

closed as unclear what you're asking by Spacedman, Vince, Fran Raga, Ian Turton Jun 4 at 16:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Check out the raster package in R e.g. rspatial.org/spatial/8-rastermanip.html#accessing-cell-values – mdsumner Jun 4 at 15:30
  • Do you have any programming experience? Python, R, C, Perl? Any GIS experience? ArcGIS, QGIS? What's our starting point here? – Spacedman Jun 4 at 15:43
  • Thank you for holding my feet to the fire on narrowing the question. Is it now time to take it off hold? Or am I still sitting in the corner? – Thomas Jun 7 at 19:45
  • What have you tried and where are you stuck? Including a single question mark appropriately in your question body is I think the best way to start improving your question. – PolyGeo Jun 7 at 21:37
  • The issue is pretty clear. – Thomas Jun 10 at 13:06

You are trying to clip a raster using a mask layer. Using Qgis, you can follow the following procedure.

  1. Load your dem and polygon on the canvas

  2. In the raster menu, go to Extraction -> Clip raster by mask layer

  3. There, put your DEM as input layer, your polygon as mask layer. You can pretty much leave the other fields as default

  4. In the Clipped(mask) field, select the place you want to save the results to (Save to file), select the file extension .xyz

You should be able to read the resulting file either in Qgis, Excel or another software depending on your needs.


This is possible, and not very complicated in most GIS software. The best way to learn it will be to figure out which tools/algorithms will be used, and find the relevant section of the software manual. If the manual doesn't have enough detail, find tutorials for those tools in your chosen software by using the name of the software and the name of the tool as search terms. Once you pick a software, you may find that the question has already been answered for that software on GIS StackExchange.

The operation will most likely be performed in two or three steps:

  1. Clip / intersect the raster to the polygon. Since rasters are always rectangular, the output of this step will be a rectangular raster with a "border" of nodata cells.
  2. Extract the raster values as points
  3. Depending on how the software handles the "no data" part of the raster, your output from step 2 may have points with "no data" values, which will need to be removed. You can handle this by running a clip or intersect operation (this will be a different tool/algorithm than used in step one, because the input layers are both vectors), or by selecting and deleting all points with "no data" values.

Eg, in QGIS, those steps would be:

  1. Use the tool Clip raster by mask layer or Clip raster with polygon. (Relevant section of the QGIS Manual).
  2. Raster pixels to points tool, or see this SE Q&A: How to convert raster to point in QGIS
  3. Use Intersection tool (relevant section of manual) if you want to copy attributes from the polygon to the points. Otherwise, use the Clip tool (relevant section of manual).
  • You understand the issue that I'm discussing..you must have a basic level of literacy. The tool I'll be using is Python/GDAL. This place seems to be for real techno-snobs. – Thomas Jun 10 at 13:09

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