[postgis-users] Raster2pgsql.py Possible No Data Problem

Andreas Forø Tollefsen andreasft at gmail.com
Wed Mar 2 12:38:19 PST 2011


Hi. Sorry. I was confused and used the Python 2.5.

Now i get some other errors when using python 2.6. Could it be my setup
which is not correct?

C:\Python26>python raster2pgsql.py -r
c:\prio_grid\source\mountain\mean_mnt_bin.
tif -t mountain -s 4326 -I -o mountain.sql
Traceback (most recent call last):
  File "raster2pgsql.py", line 1036, in <module>
    main()
  File "raster2pgsql.py", line 999, in main
    gt = wkblify_raster(opts, filename.replace( '\\', '/') , i, gt)
  File "raster2pgsql.py", line 941, in wkblify_raster
    summary = wkblify_raster_level(options, ds, options.overview_level,
band_ran
ge, infile, i)
  File "raster2pgsql.py", line 901, in wkblify_raster_level
    hexwkb += wkblify_band(options, band, level, xoff, yoff,
read_block_size, bl
ock_size, infile, b)
  File "raster2pgsql.py", line 790, in wkblify_band
    target_block_size[0], target_block_size[1])
  File "C:\Python26\Lib\site-packages\osgeo\gdal.py", line 978, in
ReadAsArray
    import gdalnumeric
  File "C:\Python26\Lib\site-packages\osgeo\gdalnumeric.py", line 1, in
<module>

    from gdal_array import *
  File "C:\Python26\Lib\site-packages\osgeo\gdal_array.py", line 24, in
<module>

    _gdal_array = swig_import_helper()
  File "C:\Python26\Lib\site-packages\osgeo\gdal_array.py", line 23, in
swig_imp
ort_helper
    return _mod
UnboundLocalError: local variable '_mod' referenced before assignment

C:\Python26>

2011/3/2 Jorge Arévalo <jorge.arevalo at deimos-space.com>

> On Wed, Mar 2, 2011 at 5:40 PM, Andreas Forø Tollefsen
> <andreasft at gmail.com> wrote:
> > Hi,
> > Postgresql 8.4.7
> > postgis-pg84-binaries-2.0.0svn.zip
> > Tested with latest raster2pgsql.py rev 6860
> > I have a raster which is giving me problems when creating the raster
> table.
> > The raster does not have any digits for no data but 'no data'.
> > Could this be the cause of the below problem? I tried a different raster
> > which normally have been working with the old gdal2wktraster.py script.
> > Any suggestions?
> > The error:
> > C:\Python25>python raster2pgsql.py -r
> > c:\prio_grid\source\mountain\mean_mnt_bin.
> > tif -t mountain -o mountain.sql
> > Traceback (most recent call last):
> >   File "raster2pgsql.py", line 1036, in <module>
> >     main()
> >   File "raster2pgsql.py", line 999, in main
> >     gt = wkblify_raster(opts, filename.replace( '\\', '/') , i, gt)
> >   File "raster2pgsql.py", line 941, in wkblify_raster
> >     summary = wkblify_raster_level(options, ds, options.overview_level,
> > band_ran
> > ge, infile, i)
> >   File "raster2pgsql.py", line 853, in wkblify_raster_level
> >     nodata_values = collect_nodata_values(ds, band_from, band_to)
> >   File "raster2pgsql.py", line 532, in collect_nodata_values
> >     if nodata is not None and not math.isnan(nodata):
> > AttributeError: 'module' object has no attribute 'isnan'
> > C:\Python25>
> >
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
> >
>
> Hi,
>
> The problem is with the 'isnan' function. I see it was included in
> Python 2.6. We need a replacement in case of lower Python versions.
> I'll fix it asap (hopefully, when I arrive home).
>
> Best regards, and thanks for the feedback
>
> --
> Jorge Arévalo
> Internet & Mobilty Division, DEIMOS
> jorge.arevalo at deimos-space.com
> http://es.linkedin.com/in/jorgearevalo80
> http://mobility.grupodeimos.com/
> http://gis4free.wordpress.com
> http://geohash.org/ezjqgrgzz0g
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110302/fcaab6a4/attachment.html>


More information about the postgis-users mailing list