You are on page 1of 6

PGADMIN 

III PLUG­IN REGISTRATION: POSTGIS SHAPEFILE AND DBF LOADER      
Postgres OnLine Journal

        PostGIS in Action   PostgreSQL: Up and Running   Book Store   About the Authors   Consulting   PostgreSQL
     PostGIS
     

PGADMIN III PLUG­IN REGISTRATION: POSTGIS SHAPEFILE AND DBF LOADER
Printer Friendly
Recommended Books: PostGIS In Action  PostgreSQL 8.4 Official The SQL Language  PostgreSQL 8.4 Server Administration
PgAdmin 1.9+ has a simple Plug­In architecture which makes it relatively simple to introduce new plugins. It is pretty much all controlled by the file plugins.ini
If you want the executable to get passed database configuration settings, there is an option for that and you just have to build your executable to accept comman

You can download the windows version from http://postgis.net/windows_downloads. If you just want it without the PostGIS 1.5 binaries ­­ just download the one la

To enable said plugin, do the following:

1.  Open PgAdmin, and verify the location of the bin folder by choosing Options from the File menu

2.  You may want to change the location if its pointing at an old PostgreSQL or PgAdmin III install.

3.  Copy the postgisgui into the bin folder noted in the above dialog.
4.  Edit the plugins.ini file in your PgAdmin III install folder by adding the following lines (found in the ReadMe) or overwrite the plugins.ini with the packaged one, 

;
;PostGIS shp2pgsql­gui (Windows):
;
Title=PostGIS Shapefile and DBF loader
Command="$$PGBINDIR\postgisgui\shp2pgsql­gui.exe" ­h "$$HOSTNAME" ­p $$PORT ­U "$$USERNAME" ­d "
Description=Open a PostGIS ESRI Shapefile or Plain dbf loader console to the current database.
KeyFile=$$PGBINDIR\postgisgui\shp2pgsql­gui.exe
Platform=windows
ServerType=postgresql
Database=Yes
SetPassword=Yes
 

5.  Reopen PgAdmin and your Plugins menu should look like:
6.  If you don't have a database selected, the menu options will be disabled, but once you have a database selected, then you should be able to click the loader

7.  If you click the Options button

you can fine tune things a little, like for long lat data choosing to load in the new geography data type.

NOTE: That for geography your data most already be in WGS 84 long lat (4326) which is the only spatial ref supported for geography since transform support 
you get from Tiger and Census boundary files(although they are in NAD 83 long lat (4269), you can get away with lying and calling it 4326 for most use cases
the WGS 84 one)

Poste d by Le o Hsu and R e gina O be  in be ginne r, contrib spotlight, pgadm in, postgis at 14:19 | C om m e nts (22) | Track back s (0)

Related entries by tags:

PostgreSQL 9.2 pg_dump enhancements
Using PgAdmin PLPgSQL Debugger
Navigating PostgreSQL 9.1 beta 1 with PgAdmin III 1.14.0 Beta 1
PostgreSQL 9.0 pg_dump, pg_dumpall, pg_restore cheatsheet overview
pgAdmin pgScript
PgAdmin III 1.13 ­ change in plugin architecture and PostGIS Plugins
Explain Plans PostgreSQL 9.0 ­ Part 2: JSON and JQuery Plan Viewer
Explain Plans PostgreSQL 9.0 Text, JSON, XML, YAML ­ Part 1: You Choose
What is new in PgAdmin III 1.12.0
Database Administration, Reporting, and Light application development

TRACKBACKS
Trackback specific URI for this entry

PingBack
Weblog: gis­lab.info
Tracked: Dec 24, 20:32

PingBack

Weblog: www.nipalante.es
Tracked: Mar 25, 13:16

PingBack

Weblog: uomgeospatial.wordpress.com
Tracked: Mar 31, 09:56

PingBack

Weblog: www.postgresonline.com
Tracked: Oct 11, 10:28

Recommended Books: PostGIS In Action  PostgreSQL 8.4 Official The SQL Language  PostgreSQL 8.4 Server Administration

COMMENTS
Display comments as (Linear | Threaded)

I have installed the gui, but keep getting errors when I try to load a shapefile. Below is an example:

Connection: user=postgres password=******** port=5432 host=localhost dbname=postgres
Destination: public.hgac_zipcode
Source File: C:\ARC Files\GPL\Data2SDS\HAR2SDS\tx.houston\Data\Zipcode\hgac_zipcode
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
Failed SQL begins: "SET CLIENT_ENCODING TO UTF8;
SET STANDARD_CONFORMING_STRINGS TO ON;
BEGIN;
CREATE TABLE "public"."hgac_zipcode" (gid serial PRIMARY KEY,
"objectid_1" numeric(10,0),
"objectid" numeric(10,0),
"zip" varchar(5),
"po_name" varchar(28),
"state" varchar(2),
"s"
Failed in pgui_exec(): ERROR: function addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does not exist
LINE 16: SELECT AddGeometryColumn('public','hgac_zipcode','the_geom',...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Shapefile import failed.

Do I need to be setting something different in the Configuration or the Options? I currently have the following:

Configuration: 
Destination Schema: public
SRID: ­1
Destination Table: hgac_zipcode
Geometry Column: the_geom

Options:
DBF file character encoding: WINDOWS­1252
and only "Create spatial index automatically after load" checked.

Thanks for any help!

#1 Melanie Hammond on 2010­02­19 10:19

Melanie,

From the error, it seems you don't have PostGIS enabled in your database.

The easiest way to enable it is to 

Create a new database and choose template_postgis for the template.

Then you should be able to load this shape file into that PostGIS enabled database.

#1.1 Regina on 2010­02­20 01:34

Problems with "standard_conforming_strings" in the GUI interface of shp2psql:
­­­­­­­­­
I cannot device how can be toggled to off this parameter. My DB is 8.1 and does not let me change it to "obbey" the imports form shp2psql.

Always I get the same message. I paste it in extense:

Shapefile import failed.
Connection: user=fesago password=*** port=5432 host=127.0.0.1 dbname=mapasand
Destination: public.andalucia100
Source File: C:\Documents and Settings\Felix\Escritorio\andalucia100
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
Failed SQL begins: "SET CLIENT_ENCODING TO UTF8;
SET STANDARD_CONFORMING_STRINGS TO ON;
BEGIN;
CREATE TABLE "public"."andalucia100" (gid serial PRIMARY KEY,
"clave" int4,
"nombre" varchar(30));
SELECT AddGeometryColumn('public','andalucia100','the_geom','­1','MULTIPOLYGON',"
Failed in pgui_exec(): ERROR: parameter "standard_conforming_strings" cannot be changed

#2 Felix (Homepage) on 2010­03­05 18:20
Felix,

Which version of PostGIS are you running?

Unfortunately I fear this may be a limitation in PostgreSQL 8.1, that may be unavoidable. 

One thing that might work ­­ is click "Options" and check the "use copy" instead. 

The PostGIS GUI was packaged with PostGIS 1.5 which only supports PostgreSQL 8.3+. I have tried it in PostgreSQL 8.2 and workks fine. 

It was really just a stroke of luck that it works against lower versions of PostGIS and PostgreSQL. Evidentally I guess PostgreSQL 8.1 is too low.

I'll ask the developers to see if anything can be done about this, but I suspect the answer will be no.

#2.1 Regina on 2010­03­06 03:03

Ok I guessed 8.1 might be the "problem" (what abot a little of backwrds compatibility? Uhmm! we are talking not on Pg 7 or such.. 8.1 is not that old!). So, I a
be done at certain momment, but not just because of such importation. Uhmmm! (again!).

About the other propssed solution (working with the options), none of them seems to make it work. I could even say that none of the possible combinations o

Still I gess It shoul be easier to make the GUI able to make this parameter on and off. There must be a huge ammount of 8.1 (and lower) installations running 

Many thanks, in any case. The tool seems easing a obnoxious task when not done throught "programming" a batch file. Thanks also for the early response!

Regards

#2.1.1 FELIX (Homepage) on 2010­03­06 04:49

I know, but we had to make a decision to support older versions vs. look to the future.

So for each new version of PostGIS we support only 2 or 3 PostgreSQL versions. We do maintain support for older versions of PostGIS on older PostgreSQL
work with older versions.

It was a decision made to make testing on all platforms and supported PostgreSQL versions manageable.

#2.1.1.1 Regina on 2010­03­06 16:24

I can not load polygons (not multipolygons) using "postgis shapefile and dbf loader". 
I also can not load data to an existing table using "postgis shapefile and dbf loader"
I am using postgres8.4 with postgis1.5 in windows.
It seems that there is no option to define "polygong" and use an existing table.

Any advise please.

Thanking you
Nimal

#3 Nimal on 2010­11­11 23:09

Nimal,

Ah yes you are right the PostGIS 1.5 loader doesn't have an option to load to an existing table.

Try using the PostGIS 2.0 version which is still in alpha but for the most part I think works fine.

If you are on windows, you can download the lastest trunk binaries from:
http://www.postgis.org/download/windows/experimental.php

It also supports loading multiple files at once. For each file ­­ there is a mode drop down you get when you double­click on mode once you select a file to load. 
personally tried the append mode yet.

#3.1 Regina on 2010­11­13 17:04

Nimal,
I see what you mean about loading single polygons. I could have sworn I saw that feature before in the 1.5 or 2.0, but I don't see it in either so perhaps I was m

Anyrate ­­ please put in a enhancement ticket request for single mode. I'm sure its a trivial enhancement.
http://trac.osgeo.org/postgis/wiki

In the meantime ­­ if you need single polygon (rather than it coming in as multi), guesss you have to use the commandline version if you need that feature.

http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide.bqg

#3.2 Regina on 2010­11­13 17:13

Hi Regina­­I've just spent the better part of the day struggling with this myself. My world map edited in ArcMap had coordinates from ­180.01 to 180.01, and 
polygon rectangle from ­179.999 to 179.999 lon, and from ­89 to 89 lat. I then clipped my map using the rectangle, choosing the "preserve intersecting area"
180; I was able to upload the resulting shapefile easily.

FWIW, this is a frustrating limitation of the geography data type, since ArcMap apparently extends coordinates beyond 180 without asking or being asked.

#3.2.1 Sarah on 2011­06­17 17:44

Hi I seem to be having a problem importing a shapefile, any help will be appreciated, thanks.

error log:

Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
Importing shapefile (167176 records)...
Failed SQL begins: "INSERT INTO "postgres"."locations"
("objectid","uid","id_0","iso","name_0","id_1","name_1","varname_1","nl_name_1","hasc_1","cc_1","type_1","engtype_1","validfr_1","validto_1","remarks_1","id_2","name
Failed in pgui_exec(): ERROR: Coordinate values are out of range [­180 ­90, 180 90] for GEOGRAPHY type
LINE 1: ...LL,NULL,'1.64848538366e+003','6.07804729089e+003','010600000...
^

Failed record number #1963
Failed SQL begins: "INSERT INTO "postgres"."locations"
("objectid","uid","id_0","iso","name_0","id_1","name_1","varname_1","nl_name_1","hasc_1","cc_1","type_1","engtype_1","validfr_1","validto_1","remarks_1","id_2","name
Failed in pgui_exec(): ERROR: current transaction is aborted, commands ignored until end of transaction block

Failed record number #1964
Failed SQL begins: "INSERT INTO "postgres"."locations"
("objectid","uid","id_0","iso","name_0","id_1","name_1","varname_1","nl_name_1","hasc_1","cc_1","type_1","engtype_1","validfr_1","validto_1","remarks_1","id_2","name
Failed in pgui_exec(): ERROR: current transaction is aborted, commands ignored until end of transaction block

#4 Dave Arthur on 2011­04­10 19:45

Dave geography won't work unless your geometries are in WGS 84 long lat. I suspect they are not.

You know what spatial reference they are in?

Try importing using geometry type. In PostGIS 2.0 we do support transformation at least with the command line loader.

#4.1 Regina on 2011­04­12 07:35

Hi Regina, the spatial file is one from www.gadm.org which I believe is in WGS84. I'll try with the command line loader.

Thanks

Dave

#4.1.1 Dave Arthur on 2011­04­12 11:32

Dave,

Ah I vaguely remember having issues with that file. You should be able to bring it in even with the gui loader as geometry instead of geography and then fi

As I recall there is one record in there was the culprit because it wrapped. I think somewhere in Russia. I forget what I did with that one whether I shared

I think in PostGIS 2.0 we do have a patch for this to allow these kind of geometries but can't recall if its committed or not.

#4.1.1.1 Regina on 2011­04­14 14:01

Sir, 
I need to edit a shape file using postGIS or in .net...please provide me a demo project and step by step process to execute it...i have not used Shape files in .Net..

#5 Ravindhar A R on 2011­08­17 00:50

Is is possible to intall and use "Postgis shapefile and dbf loader" plugin on Linux environment? I have installed postgre and postgis 1.5.3 on redhat linux x64, but I am

#6 Lukas on 2011­12­05 05:15

Hi,
Anyone knows which kind of error is: Failed in pgui_exec(): ERROR: parameter "standard_conforming_strings" cannot be changed

I can't load a shape with the shp2pgui.
Thank you

#6.1 Sara on 2012­06­18 06:46

Which version of the gui are you using and against what version of PostgreSQL?

#6.1.1 Regina on 2012­06­20 19:40

Hi, I Hope someone has the answer to my problem. I have not been able to load any shapefile into PostGis 2.0 using the PostGis Shapefile and DBF Loader to the da
shapefile importations failed because the dbf file (.dbf) cannot be opened.
I have already PostGIS enabled in my database and before I loaded the shapefiles using SPIT (QUANTUM GIS), so I think is a general problem with the plugin.
Thanks for any help

#7 Alejandra on 2013­01­16 16:29

Which OS are you on. Are you using the windows packaged version or did you compile yourself or get from elsewhere.

I haven't had issue using it and use it all the time. What does the About box say ­­ should have the version on it. The .dbf error generally comes up if you are m
load with SPIT that is not the issue.

Are you able to load with the shp2pgsql command line?

#7.1 Regina on 2013­01­17 00:14

Thank you Regina, 
1. I’m on windows 7 and I’m using the windows packaged version. Do you think that I have perhaps a problem of installation?
2. The about box: I don’t know if I understand what is an About box. However, I am on PosgreSQL 9.2 with PostGIS 2.0, is it that what you meant?
The problem that I get is the following:
Connecting: host=localhost port=5432 user=postgres password='********' dbname=pm
Connection succeeded.
Importing with configuration: batiments, public,the_geom, C:\base_donne\batiment,
mode=c, dump=1, simple=0, geography=o, index=1, shape=1, srid=2950
C:\base_donne\batiment:dbf file (.dbf) can not be opened.
Shapefile import failed.
3. It’s the first time that I use the psql console, so I’ll try the command line and I’ll write to you again to let you know if I can do it this way.

#8 Alejandra on 2013­01­18 16:52

Alejandra,

So you definitely have a .dbf , shp, and shx files? It could be something with the file like the name. If you still have issue, please put a ticket in PostGIS bug trac
small enough and you don't have issue posting publically.

http://trac.osgeo.org/postgis/

#8.1 Regina on 2013­01­19 18:41

ADD COMMENT
Name
Email

Homepage

In reply
[ Top level ]
to

Comment
E­Mail addresses will not be displayed and will only be used for E­Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate 
submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be v

Enter the string from the spam­prevention image above: 

Remember Information? 
 
Subscribe to this entry

  Submit Comment   Preview

You might also like