[postgis-users] Postgis, OGR2OGR and QGIS

chrispg chrisemberson at hotmail.com
Tue Aug 3 15:27:38 PDT 2010


I am having trouble using OGR2OGR to load a .csv file into postgis and using
QGIS to view the result. Even though I am setting the SRID to 27700 for BNG
I am unable to succeed in what sounds like a straightforward task... Below
are the steps I have taken. Any help is much appreciated.

create a new database..
sudo -u postgres -i -H
createdb -E UTF8 -O testuser YMNC
createlang plpgsql YMNC
psql -d YMNC -f /usr/share/postgresql/8.3/contrib/_int.sql
psql -d YMNC -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql
psql YMNC -c "ALTER TABLE geometry_columns OWNER TO testuser"
psql YMNC -c "ALTER TABLE spatial_ref_sys OWNER TO testuser"
exit

Then use ogr2ogr. Create settings file - YMNC.ovf...

<OGRVRTDataSource>
        <OGRVRTLayer name="Y14_header2">
        <SrcDataSource>Y14_header2.csv</SrcDataSource>
        <SrcLayer>Y14_header2</SrcLayer>
        <GeometryField encoding="PointFromColumns" x="EASTING"
y="NORTHING"/>
        <GeometryType>wkbPoint</GeometryType>
        </OGRVRTLayer>
</OGRVRTDataSource>

Use OGR to load csv file...

ogr2ogr -f "PostgreSQL" -select "EASTING,NORTHING" PG:"host=127.0.0.1
user=testuser dbname=YMNC password=" -a_srs "EPSG:27700" YMNC.ovf

The Y14_header2 table is visible in QGIS...
but CRS is WGS_84??!!

so trying reprojection:
UPDATE Y14_header2 SET wkb_geometry = ST_SetSRID(wkb_geometry, 27700);
DOES NOT WORK

so try dropping the column and creating new geometry column:
SELECT DropGeometryColumn ('public', 'Y14_header2', 'wkb_geometry');
THIS WORKS

Add a new geometry column, and call it the_geom instead:
SELECT AddGeometryColumn ('public', 'Y14_header2', 'the_geom', 27700,
'POINT',2);
THIS WORKS

but data no longer visible in QGIS..........

so try re-setting the SRID....
UPDATE Y14_header2 SET the_geom = ST_SetSRID(the_geom, 27700);
THIS WORKS

but data still not visible in QGIS..........
-- 
View this message in context: http://old.nabble.com/Postgis%2C-OGR2OGR-and-QGIS-tp29340858p29340858.html
Sent from the PostGIS - User mailing list archive at Nabble.com.




More information about the postgis-users mailing list