[GRASS-user] Import postgis vector form schema

Hi,

I tried to import a postgis layer from a non public schema.

I used this commands according to the documentation (http://grass.fbk.eu/gdp/html_grass64/v.in.ogr.html):

db.connect driver=pg database=“host=aaa,dbname=bbb” schema=administrative
db.login user=_____ ‘password=******’
db.connect -p
driver:pg
database:host=aaa,dbname=bbb
schema:administrative
group:
db.tables -p

administrative.test

v.in.ogr dsn=./ layer=test output=prova1
ERROR: Unable to open data source <./>

I’m using GRASS 6.4.0. Command such
v.in.ogr dsn=‘PG:host=aaa dbname=bbb user=____ password=*****’ output=prova layer=prova
worked since prova is in the public schema.

Many thanks!
Matteo

On 09/02/12 00:59, matteo poletti wrote:

Hi,
I tried to import a postgis layer from a non public schema.

I used this commands according to the documentation
(http://grass.fbk.eu/gdp/html_grass64/v.in.ogr.html):
> db.connect driver=pg database="host=aaa,dbname=bbb"
schema=administrative
> db.login user=_____ 'password=******'
> db.connect -p
driver:pg
database:host=aaa,dbname=bbb
schema:administrative
group:
> db.tables -p
...
administrative.test
...
> v.in.ogr dsn=./ layer=test output=prova1
ERROR: Unable to open data source <./>

If you are trying to import from PostgreSQL, dsn shouldn't be './', or ?

Moritz

I'm using GRASS 6.4.0. Command such
v.in.ogr dsn='PG:host=aaa dbname=bbb user=____ password=*****'
output=prova layer=prova
worked since prova is in the public schema.

Many thanks!
Matteo

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

If you are trying to import from PostgreSQL, dsn shouldn’t be ‘./’, or ?

In the manual page http://grass.fbk.eu/gdp/html_grass64/v.in.ogr.html, section “Support of database schema”, there is an example in which is used <./>.
Are there other ways?
Thanks!

Matteo


Da: Moritz Lennert mlennert@club.worldonline.be
A: matteo poletti pollo1_91@yahoo.it
Cc: GRASS list grass-user@lists.osgeo.org
Inviato: Giovedì 9 Febbraio 2012 11:13
Oggetto: Re: [GRASS-user] Import postgis vector form schema

On 09/02/12 00:59, matteo poletti wrote:

Hi,
I tried to import a postgis layer from a non public schema.

I used this commands according to the documentation
(http://grass.fbk.eu/gdp/html_grass64/v.in.ogr.html):

db.connect driver=pg database=“host=aaa,dbname=bbb”
schema=administrative
db.login user=_____ ‘password=******’
db.connect -p
driver:pg
database:host=aaa,dbname=bbb
schema:administrative
group:
db.tables -p

administrative.test

v.in.ogr dsn=./ layer=test output=prova1
ERROR: Unable to open data source <./>

If you are trying to import from PostgreSQL, dsn shouldn’t be ‘./’, or ?

Moritz

I’m using GRASS 6.4.0. Command such
v.in.ogr dsn=‘PG:host=aaa dbname=bbb user=____ password=*****’
output=prova layer=prova
worked since prova is in the public schema.

Many thanks!
Matteo


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hi,

2012/2/9 matteo poletti <pollo1_91@yahoo.it>:

db.tables -p

...
administrative.test
...

v.in.ogr dsn=./ layer=test output=prova1

ERROR: Unable to open data source <./>

I'm using GRASS 6.4.0. Command such
v.in.ogr dsn='PG:host=aaa dbname=bbb user=____ password=*****' output=prova
layer=prova
worked since prova is in the public schema.

try

v.in.ogr [...] layer=administrative.test

Martin

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

Hi,

2012/2/9 matteo poletti <pollo1_91@yahoo.it>:

In the manual page http://grass.fbk.eu/gdp/html_grass64/v.in.ogr.html,
section "Support of database schema", there is an example in which is used
<./>.

this example seems very weird to me. From user POV I would assume

db.connect driver=pg database=test schema=user1 group=group1
db.login driver=pg database=test user=user1 password=pwd1
v.in.ogr dsn=*PG:dbname=test* layer=river output=river # -> table
user1.river
db.select table=user1.river

`./` means that OGR tries to open current directory as a data-source.

Martin

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

try

v.in.ogr […] layer=administrative.test

I tried this, but failed:

v.in.ogr dsn=‘PG:host=aaa dbname=bbb user=____ password=*****’ output=prova layer=administrative.test
ERROR: Layer <administrative.test> not available


Da: Martin Landa landa.martin@gmail.com
A: matteo poletti pollo1_91@yahoo.it
Cc: GRASS list grass-user@lists.osgeo.org
Inviato: Giovedì 9 Febbraio 2012 12:56
Oggetto: Re: [GRASS-user] Import postgis vector form schema

Hi,

2012/2/9 matteo poletti <pollo1_91@yahoo.it>:

db.tables -p

administrative.test

v.in.ogr dsn=./ layer=test output=prova1
ERROR: Unable to open data source <./>

I’m using GRASS 6.4.0. Command such
v.in.ogr dsn=‘PG:host=aaa dbname=bbb user=____ password=*****’ output=prova
layer=prova
worked since prova is in the public schema.

try

v.in.ogr […] layer=administrative.test

Martin


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

this example seems very weird to me.

Same for me, I thought that db.connect would create some files in ./ but this is not true.

From user POV I would assume
db.connect driver=pg database=test schema=user1 group=group1
db.login driver=pg database=test user=user1 password=pwd1
v.in.ogr dsn=PG:dbname=test layer=river output=river # → table
user1.river
db.select table=user1.river

I’ve tried also this but still no results…


Da: Martin Landa landa.martin@gmail.com
A: matteo poletti pollo1_91@yahoo.it
Cc: GRASS list grass-user@lists.osgeo.org
Inviato: Giovedì 9 Febbraio 2012 13:00
Oggetto: Re: [GRASS-user] Import postgis vector form schema

Hi,

2012/2/9 matteo poletti <pollo1_91@yahoo.it>:

In the manual page http://grass.fbk.eu/gdp/html_grass64/v.in.ogr.html,
section “Support of database schema”, there is an example in which is used
<./>.

this example seems very weird to me. >From user POV I would assume

db.connect driver=pg database=test schema=user1 group=group1
db.login driver=pg database=test user=user1 password=pwd1
v.in.ogr dsn=PG:dbname=test layer=river output=river # → table
user1.river
db.select table=user1.river

./ means that OGR tries to open current directory as a data-source.

Martin


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

On 09/02/12 13:00, Martin Landa wrote:

Hi,

2012/2/9 matteo poletti<pollo1_91@yahoo.it>:

In the manual page http://grass.fbk.eu/gdp/html_grass64/v.in.ogr.html,
section "Support of database schema", there is an example in which is used
<./>.

this example seems very weird to me. From user POV I would assume

db.connect driver=pg database=test schema=user1 group=group1
db.login driver=pg database=test user=user1 password=pwd1
v.in.ogr dsn=*PG:dbname=test* layer=river output=river # -> table
user1.river
db.select table=user1.river

`./` means that OGR tries to open current directory as a data-source.

AFAICT, the example of the man page is about importing a shapefile 'river' into GRASS using a PostgreSQL database backend, not about importing a PostGIS layer from PostgreSQL into GRASS. I agree that this is not very clear, though.

AFAIK db.connect and db.login do not make any difference for importing data from PostGIS.

In order to import data from a PostGIS database into GRASS using schemas, you have to use the active_schema parameter in the connection string, i.e. (using the PostGIS import example from the v.in.ogr man page):

v.in.ogr dsn="PG:host=localhost dbname=postgis user=postgres active_schema=myschema" layer=polymap output=polygons type=boundary,centroid

See [1] for more info.

Moritz

[1] http://www.gdal.org/ogr/drv_pg_advanced.html

2012/2/9 matteo poletti <pollo1_91@yahoo.it>:

try

v.in.ogr [...] layer=administrative.test

I tried this, but failed:

v.in.ogr dsn='PG:host=aaa dbname=bbb user=____ password=*****'
output=prova layer=administrative.test

ERROR: Layer <administrative.test> not available

it should work in GRASS 7, I didn't try GRASS 6...

Martin

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

Thank you very much! I solved it…

Martin Landa wrote:

v.in.ogr […] layer=administrative.test

it should work in GRASS 7, I didn’t try GRASS 6…

Yes it works also in GRASS 6! I tried with a layer that wasn’t in the table geometry_columns of postgis, so it failed. With another one it works…

Moritz Lennert wrote:

In order to import data from a PostGIS database into GRASS using schemas, you have to use the active_schema parameter in the connection string, i.e. (using > the PostGIS import example from the v.in.ogr man page):

v.in.ogr dsn=“PG:host=localhost dbname=postgis user=postgres active_schema=myschema” layer=polymap output=polygons type=boundary,centroid

Also this solution worked for me!

Thank you for the great help!
Bye,
Matteo