[Gdal-dev] ogrinfo output lists no features on a postgis layer created as a copy using "create table as"

Dolf Andringa dolf.andringa at elcyion.nl
Sat Dec 16 10:52:27 EST 2006


Hello everybody,

I have a problem with ogrinfo (gdal-1.3.2) and postgres 8.1.5/postgis 
1.1.6 running on debian linux.

I have imported a shapefile into postgis using the python ogr module. 
When I use ogrinfo to get the number of features of this pg table, the 
correct number of features is shown. All other data is correct as well. 
Using ogr2ogr to create a shapefile from this pg layer (as a check) 
gives a correct shapefile again, so the postgres table is ok.
Subsequently I do a create table as to make a copy of this table within 
postgres. I am doing these queries:
CREATE TABLE "promedico-acni_ds"."lw" AS SELECT * FROM "acni_bnd"."ACNi_shp"
INSERT INTO public.geometry_columns 
(f_table_catalog,f_table_schema,f_table_name,f_geometry_column,coord_dimension,srid,type) 
VALUES ('','promedico-acni_ds','lw','wkb_geometry',2,-1,'POINT')

where acni_bnd.ACNi_shp is the original table that I imported from 
shapefiles and promedico-acni_ds.kw it the new table.

In this step the contraints, sequences an primary key are not recreated 
on the new table.
I do an vacuum analyze on the new table and then use ogrinfo to list the 
new table. The output of ogrinfo on the old and new tables is shown below.
The thing is that the new table does not contain any features according 
to ogrinfo. It does contain all rows the original table contains (10260) 
and also all values are there.
Just to check if it mattered I made sure the new table also contained 
the same constraints, sequence and indexes as the original table. Still 
ogrinfo does not list any features for the new table.

Also creating a new shapefile using ogr2ogr from the new table results 
in a shapefile without any features.

Can somebody help me find where the problem is? I can give tabledumps of 
the two tables if required.

The output of ogrinfo on the two tables (first the original one then the 
new one):

using driver `PostgreSQL' successful.

Layer name: acni_bnd.ACNi_shp
Geometry: Point
Feature Count: 10260
Extent: (128383.468750, 445698.781250) - (134391.906250, 451365.968750)
Layer SRS WKT:
(unknown)
FID Column = ogc_fid
Geometry Column = wkb_geometry
adresnr: String (0.0)
huislt: String (0.0)
huisnr: String (0.0)
postk_a: String (0.0)
postk_n: String (0.0)
straat: String (0.0)
toev: String (0.0)
x_coord: String (0.0)
y_coord: String (0.0)



using driver `PostgreSQL' successful.

Layer name: promedico-acni_ds.lw
Geometry: Point
Feature Count: 0
Layer SRS WKT:
(unknown)
FID Column = ogc_fid
Geometry Column = wkb_geometry
adresnr: String (0.0)
huislt: String (0.0)
huisnr: String (0.0)
postk_a: String (0.0)
postk_n: String (0.0)
straat: String (0.0)
toev: String (0.0)
x_coord: String (0.0)
y_coord: String (0.0)



More information about the Gdal-dev mailing list