Jiameng Hu
Jiameng Hu

Reputation: 31

Import raster by raster2pgsql, but get a sql syntax error

I try to import a raster file into my postgres database following this tutorial [http://www.postgis.org/documentation/manual-svn/using_raster.xml.html][1]

Environment: windows7, Postgres 8.4, postgis 2.0.

My command line are:

cd C:\Program Files (x86)\PostgreSQL\8.4\bin
raster2pgsql -s 4236 -I -G -M kiwi.jpg -F -t 100x100 public.gis > out.sql
psql -U postgres -d mydb2 -f out.sql

The picture named "kiwi" was in the "C:\Program Files (x86)\PostgreSQL\8.4\bin" folder. The out.sql can be generated successfully. But after input "psql -U postgres -d mydb2 -f out.sql" , there is an error.

psql:out.sql:98: ERROR: syntax error at or near"Available"

LINE 1: Available GDAL raster formats:

Thank you! This is the contents of the query:(I'm very new about postgis, so I can't figure out what's wrong here. Because I just follow the tutorial, it should work )

    Available GDAL raster formats:
      Virtual Raster
      GeoTIFF
      National Imagery Transmission Format
      Raster Product Format TOC format
      ECRG TOC format
      Erdas Imagine Images (.img)
      CEOS SAR Image
      CEOS Image
      JAXA PALSAR Product Reader (Level 1.1/1.5)
      Ground-based SAR Applications Testbed File Format (.gff)
      ELAS
      Arc/Info Binary Grid
      Arc/Info ASCII Grid
      GRASS ASCII Grid
      SDTS Raster
      DTED Elevation Raster
      Portable Network Graphics
      JPEG JFIF
      In Memory Raster
      Japanese DEM (.mem)
      Graphics Interchange Format (.gif)
      Graphics Interchange Format (.gif)
      Envisat Image Format
      Maptech BSB Nautical Charts
      X11 PixMap Format
      MS Windows Device Independent Bitmap
      SPOT DIMAP
      AirSAR Polarimetric Image
      RadarSat 2 XML Product
      PCIDSK Database File
      PCRaster Raster File
      ILWIS Raster Map
      SGI Image File Format 1.0
      SRTMHGT File Format
      Leveller heightfield
      Terragen heightfield
      USGS Astrogeology ISIS cube (Version 3)
      USGS Astrogeology ISIS cube (Version 2)
      NASA Planetary Data System
      EarthWatch .TIL
      ERMapper .ers Labelled
      NOAA Polar Orbiter Level 1b Data Set
      FIT Image
      GRIdded Binary (.grb)
      Raster Matrix Format
      EUMETSAT Archive native (.nat)
      Idrisi Raster A.1
      Intergraph Raster
      Golden Software ASCII Grid (.grd)
      Golden Software Binary Grid (.grd)
      Golden Software 7 Binary Grid (.grd)
      COSAR Annotated Binary Matrix (TerraSAR-X)
      TerraSAR-X Product
      DRDC COASP SAR Processor Raster
      R Object Data Store
      Portable Pixmap Format (netpbm)
      USGS DOQ (Old Style)
      USGS DOQ (New Style)
      ENVI .hdr Labelled
      ESRI .hdr Labelled
      Generic Binary (.hdr Labelled)
      PCI .aux Labelled
      Vexcel MFF Raster
      Vexcel MFF2 (HKV) Raster
      Fuji BAS Scanner Image
      GSC Geogrid
      EOSAT FAST Format
      VTP .bt (Binary Terrain) 1.3 Format
      Erdas .LAN/.GIS
      Convair PolGASP
      Image Data and Analysis
      NLAPS Data Format
      Erdas Imagine Raw
      DIPEx
      FARSITE v.4 Landscape File (.lcp)
      NOAA Vertical Datum .GTX
      NADCON .los/.las Datum Grid Shift
      NTv2 Datum Grid Shift
      ACE2
      Snow Data Assimilation System
      Swedish Grid RIK (.rik)
      USGS Optional ASCII DEM (and CDED)
      GeoSoft Grid Exchange Format
      Northwood Numeric Grid Format .grd/.tab
      Northwood Classified Grid Format .grc/.tab
      ARC Digitized Raster Graphics
      Standard Raster Product (ASRP/USRP)
      Magellan topo (.blx)
      SAGA GIS Binary Grid (.sdat)
      Kml Super Overlay
      ASCII Gridded XYZ
      HF2/HFZ heightfield raster
      OziExplorer Image File
      USGS LULC Composite Theme Grid
      Arc/Info Export E00 GRID
      ZMap Plus Grid
      NOAA NGS Geoid Height Grids

I have no idea about this error after searching a lot. I really appreciate that if you can give me some suggestions.


  [1]: http://www.postgis.org/documentation/manual-svn/using_raster.xml.html
  [2]: https://i.sstatic.net/YxjNJ.png

Upvotes: 3

Views: 5404

Answers (1)

kgrittn
kgrittn

Reputation: 19501

The psql utility in PostgreSQL is for processing SQL commands. The file you show doesn't contain SQL commands, it appears to contain information to help someone choose an option for the raster2pgsql program. A quick web search turned up documentation here:

http://www.postgis.org/documentation/manual-svn/using_raster.xml.html

Notice that the -G option is used to "Print the supported raster formats." The command line you used to run the program included that switch. If your goal is to produce SQL statements, that's not an option you should include. I don't know whether any other adjustments need to be made to your command, but you could start by dropping that and see what you get.

Upvotes: 5

Related Questions