471,342 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,342 software developers and data experts.

Data Type Error Using Gdal

Hi guys,

I'm using a simple gdal script to load topography data from a .DEM file to a grid. However, when I do this gdal converts the data into 16 bit unsigned integers, which is no good for reading negative elevation. I though I told it to read the data as 32 bit floats, but it reads as uint16, then converts to float32. Here is my code:

import gdal
from gdalconst import *
import numpy

data = gdal.Open(topoFile,GA_ReadOnly)

band = data.GetRasterBand(1)

elevation = numpy.empty((band.YSize,band.XSize), dtype = numpy.float32)

for i in xrange(band.YSize):
elevation[i] = band.ReadAsArray(0, i, band.XSize, 1, band.XSize, 1)
Nov 26 '07 #1
0 1100

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by dave | last post: by
10 posts views Thread by Gregory A Greenman | last post: by
4 posts views Thread by Dan | last post: by
8 posts views Thread by Julien Fiore | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.