This project is read-only.

Attempting to read or write protected memory

Aug 30, 2011 at 7:14 PM

Hello All,

    I'm just finishing up a project and I've run into this snag.  When creating grids the outputs do no not have projection info even though I am using the header from an input grid with a defined projection ("+proj=utm +zone=10 +datum=WGS84").  If I try to manually specify this projection information I get an Attempting to read or write protected memory error.  If I don't try to specify the projection everything works great.  I get the same error if the inputs/outputs are in tif or img format.  I've tried creating a header from scratch and specifying a projection on that, which seems to work some of the time but usually leads to the same memory error.  Anyone else encountered this?

Thanks for any suggestions, and once again fantastic package!


Below is the code I'm using to produce the output grids.

        'option 1 
        Dim header As New MapWinGIS.GridHeader
        header.NodataValue = outputCovariates2(pair.Key).NoDataValue
        header.NumberCols = outputCovariates2(pair.Key).numCols
        header.NumberRows = outputCovariates2(pair.Key).numRows
        header.dX = outputCovariates2(pair.Key).dx
        header.dY = outputCovariates2(pair.Key).dy
        header.XllCenter = outputCovariates2(pair.Key).xllCenter
        header.YllCenter = outputCovariates2(pair.Key).yllCenter
        header.Projection = "+proj=utm +zone=10 +datum=WGS84"

        'option 2
        ''header = covariateMD(pair.Key)
        'If header.Projection = "" Then
        '    'Nasty hack to address the fact that mapwingis will not pull the projection info
        '    header.Projection = "+proj=utm +zone=10 +datum=WGS84 +units=m +no_defs"
        'End If

        ' covariateMD(pair.Key).Projection = "+proj=utm +zone=10 +datum=WGS84 +units=m +no_defs"
        Dim outputGrid As New MapWinGIS.Grid
        outputGrid.CreateNew(outputFile, header, MapWinGIS.GridDataType.DoubleDataType, 0)
        outputGrid.PutFloatWindow(0, outputCovariates2(pair.Key).numRows - 1, 0, outputCovariates2(pair.Key).numCols - 1, outputpixels(0))

        'option 3
        'outputGrid.AssignNewProjection("+proj=utm +zone=10 +datum=WGS84 +units=m +no_defs")