[GRASS-user] Grass7 - Inconsistencies with v.out.ogr and v.out.postgis

Martin Landa landa.martin at gmail.com
Sat Apr 27 01:36:05 PDT 2013


Hi,

2013/4/27 Mark Wynter <mark at dimensionaledge.com>:
>> Do you have fresh installation from svn?
>
> Thanks Martin.  Good advice - I just pulled the latest from svn!
>
> v.out.postgis now works, generating correct feature count and SRID=2193

the source of problem is missing EPSG in your location. There was
discussion about that in ML AFAIR some months ago, but with no result.
`v.out.ogr` knows which projection you are using, but doesn't know
which EPSG it could be. So when exporting data to PostGIS using
`v.out.ogr` the tries to find matching projection in
`spatial_ref_sys`. If no matching projection is found, then the new
projection is added to `spatial_ref_sys`.

Eg. when working in `nc` dataset (epsg: 3358)

$ db.select data=pgis_grass dri=pg sql="select proj4text from
spatial_ref_sys where srid = 3358" -c
+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +ellps=GRS80
+towgs84=0,0,0,0,0,0,0 +units=m +no_defs

$ v.out.ogr in=roadsmajor dsn=PG:dbname=pgis_grass format=PostgreSQL

Current projection is:

g.proj -jf
+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137
+rf=298.257222101 +towgs84=0.000,0.000,0.000 +to_meter=1

There is no exact match between them, so new srid is added to `spatial_ref_sys`.

$ db.select data=pgis_grass dri=pg sql="select proj4text from
spatial_ref_sys where srid = 900914" -c
+proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334
+lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +datum=NAD83 +units=m
+no_defs

> yet... v.out.ogr when writing directly to PostGIS  assigns SRID 900915 to the geometry column - when it should be 2193.
> SRID 2193 is in the PostGIS spatial_ref_sys table.

`v.out.postgis` behaves in similar way, unless you define `options=srid=3358`.

> v.out.ogr when writing to shapefile correctly assigns 2193 - see below.

? Naturally there is no information about EPSG.

ogrinfo /tmp/roadsmajor.shp -so roadsmajor
INFO: Open of `/tmp/roadsmajor.shp'
      using driver `ESRI Shapefile' successful.

Layer name: roadsmajor
Geometry: Line String
Feature Count: 355
Extent: (611136.499873, 197465.257810) - (676800.487681, 257970.129540)
Layer SRS WKT:
PROJCS["Lambert_Conformal_Conic",
    GEOGCS["GCS_grs80",
        DATUM["North_American_Datum_1983",
            SPHEROID["Geodetic_Reference_System_1980",6378137,298.257222101]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["standard_parallel_1",36.16666666666666],
    PARAMETER["standard_parallel_2",34.33333333333334],
    PARAMETER["latitude_of_origin",33.75],
    PARAMETER["central_meridian",-79],
    PARAMETER["false_easting",609601.22],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
cat: Integer (10.0)
MAJORRDS_: Real (24.15)
ROAD_NAME: String (16.0)
MULTILANE: String (3.0)
PROPYEAR: Integer (10.0)
OBJECTID: Integer (10.0)
SHAPE_LEN: Real (24.15)

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa


More information about the grass-user mailing list