[postgis-users] PostGIS installation/data import problem

Nicolas Ribot nicolas.ribot at gmail.com
Wed Aug 24 05:12:43 PDT 2011


>
> We installed Postgre 9.0 using one-click installer for Windows x86-32 and
> installed PostGIS 1.5 using Postgre’s Stack builder. The computers system
> type is x64-based PC and the operation system is Windows 7 professional. We
> are planning to use the software together with Qgis for creating and
> managing an object-relational database. The installation procedure went
> seemingly fine, and we managed to create databases successfully using
> pgAdmin III.
>
> Testing the PostGIS connection works well, but when we try to connect data
> our database, we get an error message that
> “PostGIS not available: The chosen database does not have PostGIS installed,
> but this is required for storage of spatial data.”
>
> When we use postGIS importer within pgAdmin III, testing of the connection
> is also successful, but importing fails. The error message is
> “Failed in pgui_exec(): ERROR: invalid byte sequence for encoding "UTF8":
> 0xe3b664. Shapefile import failed.”
>
> With PostGIS Manager plugin in Q we managed to create a database, but it
> lacks geometry. Only the attribute data was imported. When we try to add
> PostGIS tables in Q trunk, it only gives these databases with no geometry.
>
> The default schema is public and connections have been allowed.
>
> I hope that someone can help us with this!
>
> P.S. I would also like to know if there are alternative ways to create fully
> functional geographical relational databases in Q. Qspatialite seems to be
> too limited for our needs.
> --

Hi,

You have to enable Postgis on each database you want to use to store
spatial content:

psql -f postgis.sql <mydatabase>
psql -f spatial_ref_sys.sql <mydatabase>

The Postgis installer may also have created a database named "postgis"
that you can use as a database template to create new ones:
createdb -T postgis <mydatabase>

Concerning the encoding problem, it seems your data are not in UTF-8.
You have to set the correct encoding when loading data.
It is the -W switch with shp2pgsql, (don't know the GUI you are using).
If it is Swedish data, encoding could be latin1 (ISO-8859-1), thus:

shp2pgsql -W latin1 <other options...>

Nicolas



More information about the postgis-users mailing list