Error getting Gx context
DavidHatch
Posts: 6
I am still working through some basics so apologies for the basic question. I have been able to open and read GDB files no problem but have become stuck opening and reading grids. Typing the following lines into python I get the message below:
import geosoft.gxpy.grd as grd
ctx = geosoft.gxpy.grd.GXgrd()
File "C:\Users\david.hatch\AppData\Local\Continuum\Anaconda3\lib\site-packages\geosoft\gxpy\grd.py", line 98, in __init__
self._img = gxapi.GXIMG.create(gxu.gx_dtype(dtype), kx, dim[0], dim[1])
TypeError: 'NoneType' object is not subscriptable
Process finished with exit code 1
import geosoft.gxpy.grd as grd
ctx = geosoft.gxpy.grd.GXgrd()
File "C:\Users\david.hatch\AppData\Local\Continuum\Anaconda3\lib\site-packages\geosoft\gxpy\grd.py", line 98, in __init__
self._img = gxapi.GXIMG.create(gxu.gx_dtype(dtype), kx, dim[0], dim[1])
TypeError: 'NoneType' object is not subscriptable
Process finished with exit code 1
0
Comments
-
Hello,
I believe this is what you are looking for: https://geosoftinc.github.io/gxpy/python/GXIMG.html#geosoft.gxapi.GXIMG.create_file.
Here is a sample to open an existing grid file.
import geosoft.gxpy.gx as gx
import geosoft.gxapi as gxapi
gxp = gx.GXpy()
grd = gxapi.GXIMG.create_file(gxapi.GS_TYPE_DEFAULT, 'C:\\data\\mygrid.grd', gxapi.IMG_FILE_READONLY)
Regards,
Joseph
0
This discussion has been closed.