[GRASS-user] 3D Streets Data

Matthew Pulis mpulis at gmail.com
Mon Jan 14 10:47:53 EST 2008


Thanks again Markus,

I am trying to follow your suggestions, and tried to use the v.to.db however
I read that you need to prepare the table first, so am trying to do so :

GRASS 6.3.0RC1 (nc_spm_06):~ > v.db.addtable streets3d columns="the_geom
geometry"
Using vector map name as table name: streets3d
ERROR: There is already a table linked to layer <1>

So I tried to delete the table using v.db.droptable but gave me this :

GRASS 6.3.0RC1 (nc_spm_06):~ > v.db.droptable -f streets3d layer=1

Removing table <streets3d> linked to layer <1> of vector map <streets3d>
Dropping table <streets3d>...
DBMI-Postgres driver error:
Cannot execute:
DROP TABLE streets3d

ERROR:  table "streets3d" does not exist


ERROR: Error while executing: 'DROP TABLE streets3d
       '
ERROR: An error occured while running db.execute
GRASS 6.3.0RC1 (nc_spm_06):~ >

In the whole process there was NO streets3d table created. I am for sure
connected to the PostGIS database and this is the result of my db.connect -p
:
GRASS 6.3.0RC1 (nc_spm_06):~ > db.connect -p
driver:pg
database:host=localhost,dbname=thesis
schema:
group:

I have tried some db.columns, db.describe, db.select commands on the tables
in the database, and they show that I am connected to the database.

The problem then is why it is hard to add a new table streets3d with the 3d
data. I tried to follow the manual but it still gave me that error. 

I also tried to run db.test to see if there is a problem with the PostgreSQL
connection but to my eyes there are no significant problems :
GRASS 6.3.0RC1 (nc_spm_06):~ > db.test test=test1
create table grass_test1 (i1 integer, d1 double precision, c1 varchar(20))
EXECUTE: OK
insert into grass_test1 values ( 1, 123.456, 'abcd' )
EXECUTE: OK
insert into grass_test1 values ( 2, null, 'xxx' )
EXECUTE: OK
select * from grass_test1
EXECUTE: OK
1c1
< 1|123.456|abcd
---
> 1|123.456000|abcd
ERROR: RESULT: ******** ERROR ********
select c1 from grass_test1 where d1 < 500 / 2 and i1 <> 2  and c1 ~ 'bc'
EXECUTE: OK
RESULT: OK
insert into grass_test1 values ( 3, 0.0, '_''_' )
EXECUTE: OK
alter table grass_test1 add column i2 integer
EXECUTE: OK
update grass_test1 set d1 = 18.6, i2 = 987  where i1 = 2
EXECUTE: OK
select * from grass_test1
EXECUTE: OK
1,3c1,3
< 1|123.456|abcd|
< 3|0|_'_|
< 2|18.6|xxx|987
---
> 1|123.456000|abcd|
> 2|18.600000|xxx|987
> 3|0.000000|_'_|
ERROR: RESULT: ******** ERROR ********
drop table grass_test1
EXECUTE: OK
GRASS 6.3.0RC1 (nc_spm_06):~ >


Anyone else has any suggestion please on how I can import this 3d data file
into PostGIS please?

Thanks a lot for your continous support and sorry for so many questions :(


( BTW is there an online version of the Grass book I can buy? Since I am
really getting fed up of waiting for it to come by post :\ )

Matthew

-----Original Message-----
From: neteler.osgeo at gmail.com [mailto:neteler.osgeo at gmail.com] On Behalf Of
Markus Neteler
Sent: Monday, January 14, 2008 9:44 AM
To: Matthew Pulis
Cc: grass-user at lists.osgeo.org
Subject: Re: [GRASS-user] 3D Streets Data

Matthew,

On Jan 13, 2008 10:20 PM, Matthew Pulis <mpulis at gmail.com> wrote:
> Thanks for your prompt answer Markus.
>
> The v.out.ogr is what I tried before, but redid it on the new shape-file.
> These are the first row of the new data :
>
>
wkt_geom,cat,STSEG,STID,STNAME,DIR_PRE,DIR_SUF,STYPE,CLASS,F_ELEV,T_ELEV,MAP
>
,PRIV,FRLEFT,TOLEFT,FRRIGHT,TORIGHT,FRLEFT_A,TOLEFT_A,FRRIGHT_A,TORIGHT_A,ST
>
ATEROAD,CARTONAME,CORP,SPEED,ONE_WAY,CLASSNAME,L_ZIPNAME,R_ZIPNAME,FT_COST,T
> F_COST,LABELNAME,F_NODE,T_NODE,CARTOLEVEL,SHAPE_LEN
> LINESTRING(625304.649659 214113.544271, 625301.199687 214078.520974,
> 625299.489761 214056.176602, 625299.289850
>
214050.649031),1,36074,20863,FIREFLY,,,RD,12,8,8,W0750-03,,101,199,100,198,1
> 01,119,100,118,0,FIREFLY RD,HS,25,BI,CITY,HOLLY SPRINGS,HOLLY
> SPRINGS,0.094452,0.094452,FIREFLY RD,0,0,,207.131131
>
> This is how I generated the shape file :
>
> GRASS 6.3.0RC1 (nc_spm_06):~ > v.out.ogr input=streets3d_new type=line
> dsn=streets3d_new_shps olayer=testogr lco="SPHT=ARCZ"

There is a trick here - avoid typos: It is
 lco="SHPT=ARCZ"
not:
 lco="SPHT=ARCZ"

(I again recommend copy-paste from the manual page)

If you specify lco="SPHT=ARCZ" correctly, it will indicate 3D export:

 v.out.ogr input=streets3d type=line dsn=streets3d_new_shps
olayer=testogr lco="SHPT=ARCZ"
 WARNING: Vector map <streets3d> is 3D. Use format specific layer creation
          options (parameter 'lco') to export in 3D rather than 2D (default)
 Exporting 49746 points/lines...
 ...

(personally I find the "WARNING" here inappropriate since I use lco!)

> Ogrinfo on the streets3d new shape file gave me :
>
> GRASS 6.3.0RC1 (nc_spm_06):~ > ogrinfo streets3d_new_shps/
> INFO: Open of `streets3d_new_shps/'
> using driver `ESRI Shapefile' successful.
> 1: testogr (Line String)

To get useful output, better run

ogrinfo -so streets3d_new_shps/ testogr
INFO: Open of `streets3d_new_shps/'
      using driver `ESRI Shapefile' successful.

Layer name: testogr
Geometry: 3D Line String       <<========= !! worked
Feature Count: 49746
Extent: (610869.384850, 196653.348553) - (676816.248304, 258102.572101)
Layer SRS WKT:
PROJCS["Lambert Conformal Conic",
    GEOGCS["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: Real (11.0)
STSEG: Real (11.0)
STID: Real (11.0)
STNAME: String (80.0)
...


> What I am seeing wrong is that there is no extra column being added to the
> dataset which contains the elevation. I am attaching a screenshot which
> shows this : http://solutions-lab.net/thesis/elevation.jpg

Ah, you want it as *attribute* column? This wasn't clear to me. So far
we worked on creating 3D geometry. Please note that GRASS is not
other proprietary GIS and hence it supports true 3D geometry. But you
can also generate a 2D SHAPE with 3rd dimension as attribute, check
the v.to.db page for this (or enjoy the new GRASS book :-)

good luck,
Markus

-- 
I am using the free version of SPAMfighter for private users.
It has removed 19279 spam emails to date.
Paying users do not have this message in their emails.
Get the free SPAMfighter here: http://www.spamfighter.com/len



More information about the grass-user mailing list