[postgis-users] Adding raster to PostGIS database

Duncan Golicher dgolicher at gmail.com
Mon Nov 26 22:33:28 PST 2012


Hello Smaran,

My best guess is that you aren't using a database that has PostGIS
raster correctly installed.  I have been trying to help some of my
students to install and use PostGIS raster from scratch recently and
they have had similar issues to yours and reported the same error
messages. Maybe this might help.

http://duncanjg.wordpress.com/2012/11/20/the-basics-of-postgis-raster/

It is all a bit confusing at first, but it does get easier once you
get past the first hurdles. Most problems are due to permission issues
and missing steps when installing the database.

All the best,

Duncan

On Mon, Nov 26, 2012 at 10:40 PM, Smaran Harihar
<smaran.harihar at gmail.com> wrote:
> Oh it seems the error was due to ownership being in the name of another
> user.
>
> Now I am able to get the gdalinfo,
>
> Driver: GTiff/GeoTIFF
> Files: Quercus_acutifolia_raw.tif
> Size is 3864, 1583
> Coordinate System is:
> GEOGCS["WGS 84",
>     DATUM["unknown",
>         SPHEROID["WGS84",6378137,298.257223563]],
>     PRIMEM["Greenwich",0],
>     UNIT["degree",0.0174532925199433]]
> Origin = (-179.960724061474451,86.577964063072983)
> Pixel Size = (0.093000000000000,-0.090400000000000)
> Metadata:
>   AREA_OR_POINT=Area
> Image Structure Metadata:
>   COMPRESSION=LZW
>   INTERLEAVE=BAND
> Corner Coordinates:
> Upper Left  (-179.9607241,  86.5779641) (179d57'38.61"W, 86d34'40.67"N)
> Lower Left  (-179.9607241, -56.5252359) (179d57'38.61"W, 56d31'30.85"S)
> Upper Right ( 179.3912759,  86.5779641) (179d23'28.59"E, 86d34'40.67"N)
> Lower Right ( 179.3912759, -56.5252359) (179d23'28.59"E, 56d31'30.85"S)
> Center      (  -0.2847241,  15.0263641) (  0d17' 5.01"W, 15d 1'34.91"N)
> Band 1 Block=3864x1 Type=Float32, ColorInterp=Gray
>   Min=0.000 Max=0.923
>   Minimum=0.000, Maximum=0.923, Mean=0.000, StdDev=0.000
>   NoData Value=-3.39999999999999996e+38
>   Metadata:
>     STATISTICS_MAXIMUM=0.92262234256096
>     STATISTICS_MEAN=0
>     STATISTICS_MINIMUM=5.6834812171638e-19
>     STATISTICS_STDDEV=0
>
> But when I execute,
>
> raster2pgsql -c -s 4326 -I Quercus_acutifolia_raw.tif
> public.Quercus_acutifolia_raw | psql -h localhost -d dbname -U usr
>
> I am still not able to create a Table? This is the output,
>
> Processing 1/1: Quercus_acutifolia_raw.tif
> Password for user postgres:
> BEGIN
> NOTICE:  CREATE TABLE will create implicit sequence
> "quercus_acutifolia_raw_rid_seq" for serial column
> "quercus_acutifolia_raw.rid"
> ERROR:  type "raster" does not exist
> LINE 1: ...us_acutifolia_raw" ("rid" serial PRIMARY KEY,"rast" raster);
>                                                                ^
> ERROR:  current transaction is aborted, commands ignored until end of
> transaction block
> ERROR:  current transaction is aborted, commands ignored until end of
> transaction block
> ERROR:  current transaction is aborted, commands ignored until end of
> transaction block
> ROLLBACK
>
> Thanks,
> Smaran
>
> On Mon, Nov 26, 2012 at 3:07 PM, Bborie Park <bkpark at ucdavis.edu> wrote:
>>
>> Run the following...
>>
>> gdalinfo Quercus_acutifolia_raw.tif
>>
>> If that returns an error, something may be wrong with the tif file.
>>
>> -bborie
>>
>> On 11/26/2012 02:03 PM, Smaran Harihar wrote:
>> > But I am executing the command in the directory where it is located
>> >
>> > I can list that raster using `ls`
>> >
>> > On Mon, Nov 26, 2012 at 2:46 PM, Bborie Park <bkpark at ucdavis.edu> wrote:
>> >
>> >> That error would only happen if raster2pgsql can't find the file in
>> >> your
>> >> current working directory. raster2pgsql supports relative paths for
>> >> input rasters.
>> >>
>> >> -bborie
>> >>
>> >> On 11/26/2012 01:37 PM, Smaran Harihar wrote:
>> >>> Thanks for the reply bborie,
>> >>>
>> >>> I ran this command,
>> >>>
>> >>> raster2pgsql -c -s 4326 -I Quercus_acutifolia_raw.tif
>> >>> public.Quercus_acutifolia_raw | psql -h localhost -d rasterdb -U
>> >>> postgres
>> >>>
>> >>> But this is the new error,
>> >>>
>> >>> ERROR: Unable to read raster file: Quercus_acutifolia_raw.tif
>> >>>
>> >>> Thanks,
>> >>> Smaran
>> >>>
>> >>> On Mon, Nov 26, 2012 at 2:27 PM, Bborie Park <bkpark at ucdavis.edu>
>> >>> wrote:
>> >>>
>> >>>> -D is not a valid flag recognized by raster2pgsql.  Remove the flag
>> >>>> as
>> >>>> raster2pgsql is assuming that -D is a file.
>> >>>>
>> >>>> -bborie
>> >>>>
>> >>>> On 11/26/2012 01:23 PM, Smaran Harihar wrote:
>> >>>>> Hi Guys,
>> >>>>>
>> >>>>> I am trying to add a raster to PostGIS database using,
>> >>>>>
>> >>>>> raster2pgsql -c -D -s 4326 -I Quercus_acutifolia_raw.tif
>> >>>>> public.Quercus_acutifolia_raw | psql -h localhost -d dbnm -U usr
>> >>>>>
>> >>>>> But I am getting this error,
>> >>>>>
>> >>>>> ERROR: Unable to read raster file: -D
>> >>>>>
>> >>>>> Any idea what is wrong? The database already has numerous point and
>> >>>> polygon
>> >>>>> shapefiles. Is that a problem that I cannot add rasters to the same
>> >>>>> database having shapefiles?
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> _______________________________________________
>> >>>>> postgis-users mailing list
>> >>>>> postgis-users at lists.osgeo.org
>> >>>>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>> >>>>>
>> >>>>
>> >>>> --
>> >>>> Bborie Park
>> >>>> Programmer
>> >>>> Center for Vectorborne Diseases
>> >>>> UC Davis
>> >>>> 530-752-8380
>> >>>> bkpark at ucdavis.edu
>> >>>> _______________________________________________
>> >>>> postgis-users mailing list
>> >>>> postgis-users at lists.osgeo.org
>> >>>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> postgis-users mailing list
>> >>> postgis-users at lists.osgeo.org
>> >>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>> >>>
>> >>
>> >> --
>> >> Bborie Park
>> >> Programmer
>> >> Center for Vectorborne Diseases
>> >> UC Davis
>> >> 530-752-8380
>> >> bkpark at ucdavis.edu
>> >> _______________________________________________
>> >> postgis-users mailing list
>> >> postgis-users at lists.osgeo.org
>> >> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>> >>
>> >
>> >
>> >
>> >
>> >
>> > _______________________________________________
>> > postgis-users mailing list
>> > postgis-users at lists.osgeo.org
>> > http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>> >
>>
>> --
>> Bborie Park
>> Programmer
>> Center for Vectorborne Diseases
>> UC Davis
>> 530-752-8380
>> bkpark at ucdavis.edu
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
>
>
> --
> Thanks & Regards
> Smaran Harihar
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>



-- 
Dr Duncan Golicher
Investigador Titular,
El Colegio de la Frontera Sur, Chiapas,Mexico
Mexico tel +52 1 967 137 94 20
Skype name duncangolicher

Publications: http://www.mendeley.com/profiles/duncan-golicher

Senior lecturer, Bournemouth University, UK
Centre for Conservation Ecology & Environmental Change
School of Applied Sciences
Christchurch House rm C218a
Bournemouth University
Fern Barrow
Poole (Dorset) BH12 5BB UK
Tel. +44 (0)1202 961682

For list of publications see Researcher ID:
http://www.researcherid.com/rid/B-4240-2009

dgolicher at bournemouth.ac.uk
dgoliche at ecosur.mx

Researcher ID:
http://www.researcherid.com/rid/B-4240-2009


More information about the postgis-users mailing list