I was looking for a way of extracting elevation values from a DEM and decided to use numpy for this purpose. The idea was to use a polyline, extract points every x m (interval is the raster cell size) and obtain the elevation for each point.
At first I tried using the “GetCellValue_management” tool, but when you do that a 100.000 times, it is pretty slow. When you convert a raster to numpy, the numpy array does not know the coordinates of each element of the array. To solve that you have to establish that relationship.
What I did was:
get the extent of the polyline
adapt the polyline extent using the raster extent and cell size
create a numpy array using the adapted extent (don’t extract more info than you need)
create a list of points from the polyline and using the cell size as interval
for each point determine the row and column of the point coordinates
extract the elevation value using the row column information.
This method turned out to be over 170x faster than using the repetitive use of the tool “GetCellValue_management” and still does not require a license level higher than ArcGIS for Desktop Basic and there is no need for the Spatial Analyst (or any other extension) either.