<div dir="ltr"><div>Hello,</div><div><br></div><div>I've been testing PostGIS to GRASS imports / exports and there are some things I'm not sure I understand correctly. They are related to keeping primary keys coming from PostGIS.</div><div><br></div><div>My table of origin at PostGIS has a primary key called gid_building (integer). When using:</div><div><br></div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:"Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:11px;line-height:15px;white-space:pre"><div><span style="color:rgb(0,0,0)">grass </span><span style="color:rgb(0,16,128)">$GRASS_DB</span><span style="color:rgb(0,0,0)">/PERMANENT --exec \</span></div><div><span style="color:rgb(0,0,0)">  v.in.ogr --verbose --overwrite \</span></div><div><span style="color:rgb(0,0,0)">    input=</span><span style="color:rgb(163,21,21)">"PG:host=</span><span style="color:rgb(0,16,128)">$HOST</span><span style="color:rgb(163,21,21)"> dbname=cell_raw_data user=</span><span style="color:rgb(0,16,128)">$USER</span><span style="color:rgb(163,21,21)"> port=</span><span style="color:rgb(0,16,128)">$PORT</span><span style="color:rgb(163,21,21)"> password=</span><span style="color:rgb(0,16,128)">$PASS</span><span style="color:rgb(163,21,21)">"</span><span style="color:rgb(0,0,0)"> \</span></div><div><span style="color:rgb(0,0,0)">    layer=cat2020.building output=building \</span></div><div><span style="color:rgb(0,0,0)">    snap=0.01 \</span></div><div><span style="color:rgb(0,0,0)">    where=</span><span style="color:rgb(163,21,21)">"gid_building between 2633000 and 2633100"</span></div><div><span style="color:rgb(163,21,21)"><br></span></div><div><span style="color:rgb(163,21,21)">and then exporting with:</span></div><div><span style="color:rgb(163,21,21)"><br></span></div><div><div style="color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:"Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:11px;line-height:15px;white-space:pre"><div><span style="color:rgb(0,0,0)">grass </span><span style="color:rgb(0,16,128)">$GRASS_DB</span><span style="color:rgb(0,0,0)">/PERMANENT --exec \</span></div><div><span style="color:rgb(0,0,0)">  v.out.ogr --overwrite \</span></div><div><span style="color:rgb(0,0,0)">    input=building \</span></div><div><span style="color:rgb(0,0,0)">    type=area \</span></div><div><span style="color:rgb(0,0,0)">    output=</span><span style="color:rgb(163,21,21)">"PG:host=</span><span style="color:rgb(0,16,128)">$HOST</span><span style="color:rgb(163,21,21)"> dbname=cell_raw_data user=</span><span style="color:rgb(0,16,128)">$USER</span><span style="color:rgb(163,21,21)"> port=</span><span style="color:rgb(0,16,128)">$PORT</span><span style="color:rgb(163,21,21)"> password=</span><span style="color:rgb(0,16,128)">$PASS</span><span style="color:rgb(163,21,21)">"</span><span style="color:rgb(0,0,0)"> \</span></div><div><span style="color:rgb(0,0,0)">    output_layer=cat2020_topo_clean.building_dump \</span></div><div><span style="color:rgb(0,0,0)">    format=PostgreSQL \</span></div><div><span style="color:rgb(0,0,0)">    lco=FID=gid_building_dump \</span></div><div><span style="color:rgb(0,0,0)">    lco=GEOMETRY_NAME=geom</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">I found the following schema back in PostGIS:</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">gid_building_dump (integer, with a nextval sequence)</span></div><div><span style="color:rgb(0,0,0)">cat (integer)</span></div><div><span style="color:rgb(0,0,0)">...</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">But no trace of the original primary key in the PostGIS origin table gid_building. </span></div><div><span style="color:rgb(0,0,0)">My guesses:</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">v.in.ogr just don't use the primary key of the original table, gid_building. In</span></div><div><span style="color:rgb(0,0,0)">fact, if I drop the primary key from this column, it is imported normally.</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">GRASS add its cat field to store category.</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">v.out.ogr adds its own primary key with the nextval sequence.<br></span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">I'm happy with GDAL / GRASS adding their own internal primary keys to the data,</span></div><div><span style="color:rgb(0,0,0)">in fact, I understand this is the sensible thing to do given the disparity in</span></div><div><span style="color:rgb(0,0,0)">data models. My only question is: is there any way in v.in.ogr to keep the </span></div><div><span style="color:rgb(0,0,0)">primary key as a normal field?</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">Thanks a lot,<br></span></div></div></div></div></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">







<p>---<br></p><p><span>Juan Pedro Pérez Alcántara</span></p>
<p><span><a href="mailto:jp.perez.alcantara@gmail.com" target="_blank">jp.perez.alcantara@gmail.com</a></span></p></div></div></div></div></div></div></div>