[postgis-users] Difficulty importing example file nyc_buildings.sql
Ben Madin
lists at remoteinformation.com.au
Mon Aug 15 18:43:04 PDT 2011
Bruce,
On 15/08/2011, at 6:28 PM, bac at brucecallander.com wrote:
> $ /usr/local/pgsql-9.0/bin/psql -f /Users/bacmac/nyc_buildings.sql nyc
>
> The Geoserver instructions are not explicit about where to put the nyc_buildings.sql file so I have left it in my own user directory 'bacmac'.
It doesn't matter, as long as the -f part of the command describes it as you have. You may find it convenient to keep all these scripts together in a single directory somewhere while you are starting.
> Execution of the command produces a string of errors beginning with:
>
> CREATE TABLE
> psql:/Users/bacmac/nyc_buildings.sql:4: ERROR: function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does not exist
> LINE 1: SELECT AddGeometryColumn('','nyc_buildings','the_geom','2908...
> HINT: No function matches the given name and argument types. You might need to add explicit type casts.
> psql:/Users/bacmac/nyc_buildings.sql:5: ERROR: current transaction is aborted, commands ignored until end of transaction block
> psql:/Users/bacmac/nyc_buildings.sql:6: ERROR: current transaction is aborted ... and so on.
>
>
> I realise that part of my difficulties stem from a lack of conceptual awareness of how the various parts of PostGIS fit together (databases, data stores, tables, clusters...) and what directory structure the PostGIS installation creates. I am very familiar with Access databases but that may be dangerous because the basic paradigm for PostGIS may be different. Are there any diagrams out there that give a basic conceptual view of Geoserver and PostIGIS? Also, I am coming at this from an enterprise SDI policy and implementation end, not from an IT/Unix background (probably very obvious!). Trying to construct a coherent overall picture based on the predominantly text-based, IT-heavy advice online is proving a challenge.
One of the neat / good / bad / helpful / troublesome things that you can do in postgres is define two functions with the same name, as long as they have different parameters and or parameter types. In this case, the import script is loading your sql, but has inappropriately enclosed the srid in quotes '2908'
the function you want is:
text AddGeometryColumn(varchar schema_name, varchar table_name, varchar column_name, integer srid, varchar type, integer dimension);
which specify that the srid should be integer. Because your call starts like :
> SELECT AddGeometryColumn('','nyc_buildings','the_geom','2908...
it won't match one of the above calls (unknown can go into varchar columns, but not into integer columns, which must be integer.)
The quickest fix might be to edit the nyc.sql file and remove the quotes from around the srid part of the addgeometrycolumn call.
cheers
Ben
More information about the postgis-users
mailing list