[GRASS-user] Importing a SDTS/DLG files?

I'm trying to import SDTS/DLG files. I attempted to use v.in.ogr, by importing the TR01CATD.DDF file:

v.in.ogr dsn=grassdata/USGS/BarHarbor/RD/TR01CATD.DDF
output=BHroads min_area=0.0001 snap=-1

The file was imported, however I got several warnings, informing me that
the feature was imported without the geometry. When I viewed the file I got a white screen without features.

I would like to try using v.in.dlg. It does not appear to be included in grass-6.2.0. Has this routine been discontinued in grass-6.2.0? It is shown as being ported from grass-5.3 to grass-6.0 in:

http://grass.gdf-hannover.de/wiki/GRASS_Module_Porting_List

I have had similar problems importing some shp files, but have also successfully imported shp files. Any history of this type of problem? Is it the data, software or me?

Thanks
Jim

James McManus wrote:

I'm trying to import SDTS/DLG files. I attempted to use v.in.ogr, by
importing the TR01CATD.DDF file:

v.in.ogr dsn=grassdata/USGS/BarHarbor/RD/TR01CATD.DDF
output=BHroads min_area=0.0001 snap=-1

The file was imported, however I got several warnings, informing me that
the feature was imported without the geometry. When I viewed the file I
got a white screen without features.

# change zoom to extent of map
g.region vect=BHroads
d.vect BHroads

?

what does "v.info BHroads" show? any features?

I would like to try using v.in.dlg. It does not appear to be included in
grass-6.2.0. Has this routine been discontinued in grass-6.2.0? It is
shown as being ported from grass-5.3 to grass-6.0 in:

http://grass.gdf-hannover.de/wiki/GRASS_Module_Porting_List

no, it has not been ported, OGR is the prefered way.
("no comment" means not ported in the wiki list)

Hamish

Hamish wrote:

James McManus wrote:
  

I'm trying to import SDTS/DLG files. I attempted to use v.in.ogr, by importing the TR01CATD.DDF file:

v.in.ogr dsn=grassdata/USGS/BarHarbor/RD/TR01CATD.DDF
output=BHroads min_area=0.0001 snap=-1

The file was imported, however I got several warnings, informing me that
the feature was imported without the geometry. When I viewed the file I got a white screen without features.
    
# change zoom to extent of map
g.region vect=BHroads
d.vect BHroads

?

what does "v.info BHroads" show? any features?

I would like to try using v.in.dlg. It does not appear to be included in grass-6.2.0. Has this routine been discontinued in grass-6.2.0? It is shown as being ported from grass-5.3 to grass-6.0 in:

http://grass.gdf-hannover.de/wiki/GRASS_Module_Porting_List
    
no, it has not been ported, OGR is the prefered way.
("no comment" means not ported in the wiki list)

Hamish

Hamish,

When I issue the "g.region vect=BHroads" or "v.info BHroads" I get the following error message:

ERROR: Cannot open old vector BHroads@PERMANENT on level 2

If the original location information is not the same as the data, would this problem occur? For instance if the resolution is not the same. I've not found good meta-data on the resolution of this data. I also suspect that some of the other location meta-data I am using may be incorrect. I tried using "expand area" without success. However, in all cases the file is imported. I just can't view it.

Jim

James McManus wrote:

When I issue the "g.region vect=BHroads" or "v.info BHroads" I get the
following error message:

ERROR: Cannot open old vector BHroads@PERMANENT on level 2

This means the file lacks topology, *maybe* due a segfault during
import with v.in.ogr. You would need to try importing it again, but
from the GRASS terminal, to spot if v.in.ogr crashes, as the GUI still
hides the eventuall segfaults from the user. Just a guess, hope this
sheds some light.

If the segfault is not the case, run v.build on the imported vector.
This will build the topology. Now GRASS commands should be able to use
your vector. Run g.region vect=the_map, d.vect, v.info -t ane let us
now the outcome.

Cheers,
Maciek

P.S. - for the devs

The message "ERROR: Cannot open old vector BHroads@PERMANENT on level
2" is missleading. Why "old vector"? Looks like some lagacy stuff.
Could this be fixed?

Maciek

James McManus wrote:

>> I'm trying to import SDTS/DLG files. I attempted to use v.in.ogr,
>> by importing the TR01CATD.DDF file:
>>
>> v.in.ogr dsn=grassdata/USGS/BarHarbor/RD/TR01CATD.DDF
>> output=BHroads min_area=0.0001 snap=-1
>>
>> The file was imported, however I got several warnings, informing me
>> that the feature was imported without the geometry. When I viewed
>> the file I got a white screen without features.

..

> what does "v.info BHroads" show? any features?

..

When I issue the "g.region vect=BHroads" or "v.info BHroads" I get the

following error message:

ERROR: Cannot open old vector BHroads@PERMANENT on level 2

If the original location information is not the same as the data,
would this problem occur? For instance if the resolution is not the
same. I've not found good meta-data on the resolution of this data. I
also suspect that some of the other location meta-data I am using may
be incorrect. I tried using "expand area" without success. However,
in all cases the file is imported. I just can't view it.

It doesn't sound like a projection problem. In general vector data
doesn't care about projection or resolution. The coordinates are exact.

- can you post the exact v.in.ogr messages here?
- can you post the result of "ogrinfo <filename>"? maybe with "-al"?
- can you use "ogr2ogr" to convert to a shapefile or something, then
import that into GRASS?
- maybe try "v.in.ogr location=" if you are concerned about projection
settings. This creates a new location using the input's data projection
settings.

>> I would like to try using v.in.dlg. It does not appear to be
>> included in grass-6.2.0. Has this routine been discontinued in
>> grass-6.2.0?

yes, as (theoretically) there is an OGR solution. You can always install
GRASS 5.4.0 along side GRASS 6, import it, then run v.convert in GRASS 6
to get the thing loaded.

Hamish

James McManus wrote:
..
> When I issue the "g.region vect=BHroads" or "v.info BHroads" I get the
>
> following error message:
>
> ERROR: Cannot open old vector BHroads@PERMANENT on level 2
>

SDTS files contain several tables with no geometry (OGR calls them "Layers")
that probably confuse v.in.ogr, and also contain point, line, and polygon
features. My guess is that v.in.ogr doesn't quite grok which things it needs
to ignore.

When I do an ogrinfo on an SDTS road file I see:

ogrinfo TR01CATD.DDF

ERROR 4: SDTS Driver doesn't support update.
Had to open data source read-only.
INFO: Open of `TR01CATD.DDF'
      using driver `SDTS' successful.
1: ARDF (None)
2: ARDM (None)
3: AHDR (None)
4: NP01 (Point)
5: NA01 (Point)
6: NO01 (Point)
7: LE01 (Line String)
8: PC01 (Polygon)

I bet if you were to use a "layer=NO01,LE01,PC01" option to v.in.ogr your
woes would go away. In fact, when I try to import the very same SDTS file
above, it worked fine and gave line, point, and polygon features; the vector
map displays Just Fine.

> >> I would like to try using v.in.dlg. It does not appear to be
> >> included in grass-6.2.0. Has this routine been discontinued in
> >> grass-6.2.0?

yes, as (theoretically) there is an OGR solution. You can always install
GRASS 5.4.0 along side GRASS 6, import it, then run v.convert in GRASS 6
to get the thing loaded.

There is no longer an equivalent of v.in.dlg in grass 6, as that module read
in the old style "DLG-Optional" format from the USGS. OGR does not support
the DLG-O format and not SDTS, so at this point the DLG-Optional format is
unusable in GRASS, and if you have DLG-O files you have to convert them to
shapefiles with another tool (I use Global Mapper). IIRC, v.in.dlg never
understood SDTS format DLGs from USGS --- in old grass 5.0 you used v.in.sdts
for that (a tool that did understand the various tables in an SDTS file, but
due to the poor attribute support in grass5 had to do some crazy things to try
to accommodate the complex attribute system).

--
Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/
Tijeras, NM QRPL#1592 K2#398 SOC#236 AHTB#1 http://kevan.org/brain.cgi?DDTNM
"And, isn't sanity really just a one-trick pony anyway? I mean all you get is
one trick, rational thinking, but when you're good and crazy, oooh, oooh,
oooh, the sky is the limit!" --- The Tick

On Thu, Nov 30, 2006 at 07:19:24AM -0700, we recorded a bogon-computron collision of the <russo@bogodyn.org> flavor, containing:

> James McManus wrote:
> ..
> > When I issue the "g.region vect=BHroads" or "v.info BHroads" I get the
> >
> > following error message:
> >
> > ERROR: Cannot open old vector BHroads@PERMANENT on level 2
> >

SDTS files contain several tables with no geometry (OGR calls them "Layers")
that probably confuse v.in.ogr, and also contain point, line, and polygon
features. My guess is that v.in.ogr doesn't quite grok which things it needs
to ignore.

When I do an ogrinfo on an SDTS road file I see:
> ogrinfo TR01CATD.DDF
ERROR 4: SDTS Driver doesn't support update.
Had to open data source read-only.
INFO: Open of `TR01CATD.DDF'
      using driver `SDTS' successful.
1: ARDF (None)
2: ARDM (None)
3: AHDR (None)
4: NP01 (Point)
5: NA01 (Point)
6: NO01 (Point)
7: LE01 (Line String)
8: PC01 (Polygon)

I bet if you were to use a "layer=NO01,LE01,PC01" option to v.in.ogr your
woes would go away. In fact, when I try to import the very same SDTS file
above, it worked fine and gave line, point, and polygon features; the vector
map displays Just Fine.

That particular choice of "layers" is appropriate for SDTS files that contain
only polylines (such as road layers), but not for anything that contains
meaningful polygons --- if you tried to use this on, say, a surface cover
layer all the attributes of the polygons would be missing because those are
in the centroids from the NA "module" (which is the SDTS terminology). To
get polygons with attributes you'll need to attach centroids to the polygons,
and those are in the NA module. You'll need to use the "type=" option to
v.in.ogr to read in "layers" with the right types. I'm not exactly sure how
to do that, although I think I can guess:

  v.in.ogr dsn=<catd file> layer=NO01,LE01,PC01,NA01 type=point,line,boundary,centroid output=...

If I read the v.in.ogr help correctly, that should import the NO01
module/"layer" as points, the LE01 module/"layer" as polylines, the PC01
"layer" as boundaries, and the NP01 "layer" as area centroids. But
someone more knowledgable should step in and correct me.

--
Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/
Tijeras, NM QRPL#1592 K2#398 SOC#236 AHTB#1 http://kevan.org/brain.cgi?DDTNM
"And, isn't sanity really just a one-trick pony anyway? I mean all you get is
one trick, rational thinking, but when you're good and crazy, oooh, oooh,
oooh, the sky is the limit!" --- The Tick

Tom Russo wrote:

James McManus wrote:
..
    

When I issue the "g.region vect=BHroads" or "v.info BHroads" I get the

following error message:

ERROR: Cannot open old vector BHroads@PERMANENT on level 2

SDTS files contain several tables with no geometry (OGR calls them "Layers")
that probably confuse v.in.ogr, and also contain point, line, and polygon
features. My guess is that v.in.ogr doesn't quite grok which things it needs
to ignore.

When I do an ogrinfo on an SDTS road file I see:
  

ogrinfo TR01CATD.DDF
    

ERROR 4: SDTS Driver doesn't support update.
Had to open data source read-only.
INFO: Open of `TR01CATD.DDF'
      using driver `SDTS' successful.
1: ARDF (None)
2: ARDM (None)
3: AHDR (None)
4: NP01 (Point)
5: NA01 (Point)
6: NO01 (Point)
7: LE01 (Line String)
8: PC01 (Polygon)

I bet if you were to use a "layer=NO01,LE01,PC01" option to v.in.ogr your
woes would go away. In fact, when I try to import the very same SDTS file
above, it worked fine and gave line, point, and polygon features; the vector
map displays Just Fine.

I would like to try using v.in.dlg. It does not appear to be
included in grass-6.2.0. Has this routine been discontinued in
grass-6.2.0?
          

yes, as (theoretically) there is an OGR solution. You can always install
GRASS 5.4.0 along side GRASS 6, import it, then run v.convert in GRASS 6
to get the thing loaded.
    
There is no longer an equivalent of v.in.dlg in grass 6, as that module read in the old style "DLG-Optional" format from the USGS. OGR does not support the DLG-O format and not SDTS, so at this point the DLG-Optional format is unusable in GRASS, and if you have DLG-O files you have to convert them to shapefiles with another tool (I use Global Mapper). IIRC, v.in.dlg never understood SDTS format DLGs from USGS --- in old grass 5.0 you used v.in.sdts for that (a tool that did understand the various tables in an SDTS file, but due to the poor attribute support in grass5 had to do some crazy things to try to accommodate the complex attribute system).

Defining all layers worked! It looks like it fixed the other problems I was having. It looks like the problem was with me. Live and learn.

Thanks!
Jim

Tom Russo wrote:

> SDTS files contain several tables with no geometry (OGR calls them
> "Layers") that probably confuse v.in.ogr, and also contain point,
> line, and polygon features. My guess is that v.in.ogr doesn't quite
> grok which things it needs to ignore.
>
> When I do an ogrinfo on an SDTS road file I see:
> > ogrinfo TR01CATD.DDF
> ERROR 4: SDTS Driver doesn't support update.
> Had to open data source read-only.
> INFO: Open of `TR01CATD.DDF'
> using driver `SDTS' successful.
> 1: ARDF (None)
> 2: ARDM (None)
> 3: AHDR (None)
> 4: NP01 (Point)
> 5: NA01 (Point)
> 6: NO01 (Point)
> 7: LE01 (Line String)
> 8: PC01 (Polygon)
>
> I bet if you were to use a "layer=NO01,LE01,PC01" option to v.in.ogr
> your woes would go away. In fact, when I try to import the very
> same SDTS file above, it worked fine and gave line, point, and
> polygon features; the vector map displays Just Fine.

That particular choice of "layers" is appropriate for SDTS files that
contain only polylines (such as road layers), but not for anything
that contains meaningful polygons --- if you tried to use this on,
say, a surface cover layer all the attributes of the polygons would be
missing because those are in the centroids from the NA "module" (which
is the SDTS terminology). To get polygons with attributes you'll
need to attach centroids to the polygons, and those are in the NA
module. You'll need to use the "type=" option to v.in.ogr to read in
"layers" with the right types. I'm not exactly sure how to do that,
although I think I can guess:

  v.in.ogr dsn=<catd file> layer=NO01,LE01,PC01,NA01
  type=point,line,boundary,centroid output=...

If I read the v.in.ogr help correctly, that should import the NO01
module/"layer" as points, the LE01 module/"layer" as polylines, the
PC01 "layer" as boundaries, and the NP01 "layer" as area centroids.
But someone more knowledgable should step in and correct me.

this sounds like the basis for a nice "v.in.sdts" script for GRASS 6.

Hamish

On Fri, Dec 01, 2006 at 01:46:30PM +1300, we recorded a bogon-computron collision of the <hamish_nospam@yahoo.com> flavor, containing:

Tom Russo wrote:
> > SDTS files contain several tables with no geometry (OGR calls them
> > "Layers") that probably confuse v.in.ogr, and also contain point,
> > line, and polygon features. My guess is that v.in.ogr doesn't quite
> > grok which things it needs to ignore.
> >

[...]

> >
> > I bet if you were to use a "layer=NO01,LE01,PC01" option to v.in.ogr
> > your woes would go away. In fact, when I try to import the very
> > same SDTS file above, it worked fine and gave line, point, and
> > polygon features; the vector map displays Just Fine.
>
> That particular choice of "layers" is appropriate for SDTS files that
> contain only polylines (such as road layers), but not for anything
> that contains meaningful polygons --- if you tried to use this on,
> say, a surface cover layer all the attributes of the polygons would be
> missing because those are in the centroids from the NA "module" (which
> is the SDTS terminology). To get polygons with attributes you'll
> need to attach centroids to the polygons, and those are in the NA
> module. You'll need to use the "type=" option to v.in.ogr to read in
> "layers" with the right types. I'm not exactly sure how to do that,
> although I think I can guess:
>
> v.in.ogr dsn=<catd file> layer=NO01,LE01,PC01,NA01
> type=point,line,boundary,centroid output=...
>
> If I read the v.in.ogr help correctly, that should import the NO01
> module/"layer" as points, the LE01 module/"layer" as polylines, the
> PC01 "layer" as boundaries, and the NP01 "layer" as area centroids.
> But someone more knowledgable should step in and correct me.

this sounds like the basis for a nice "v.in.sdts" script for GRASS 6.

It does, but now that I look over the v.in.ogr page and code again, I'm not
sure it's right, either. According to v.in.ogr:

type=string[,string,...]
    Optionaly change default input type:
    point -> import area centroids as points
    line -> import area boundaries as centroids
    boundary -> import lines as area boundaries
    centroid -> import points as centroids
    Options: point,line,boundary,centroid
    Default:

The code seems to OR together bits for the different type-change options,
and they apply across all layers being imported. It does not associate
types in the type list with layers in the layers list.

So it seems that specifying:
   layer=l1,l2,l3 type=t1,t2,t3
does not associate type t1 with layer 1, type t2 with layer 2, etc., but rather
   layer=NO01,LE01,PC01,NA01 type=point,line,boundary,centroid
apparently tries to change any centroids found into points, any boundaries
into lines, any lines into boundaries, and any centrioids into points, which
seems nonsense.

Could someone clarify to me how exactly to import from an ogr dataset that
contains points, lines, boundaries and centroids in such a way that the
feature type in the input is in fact the feature type imported into GRASS?

It certainly would be simple to do it piecemeal:
  v.in.ogr dsn=... layer=NO01 type=point output=some_point_map
  v.in.ogr dsn=... layer=PC01,NA01 type=boundary,centroid output=some_polyg_map
  v.in.ogr dsn=... layer=LE01 type=line output=some-line_map

and then patch 'em together to make a single vector map. Seems a convoluted
way of doing it, but I guess it would work. And would probably make a
reasonable starting point for a v.in.sdts script.

--
Tom Russo KM5VY SAR502 DM64ux http://www.swcp.com/~russo/
Tijeras, NM QRPL#1592 K2#398 SOC#236 AHTB#1 http://kevan.org/brain.cgi?DDTNM
"And, isn't sanity really just a one-trick pony anyway? I mean all you get is
one trick, rational thinking, but when you're good and crazy, oooh, oooh,
oooh, the sky is the limit!" --- The Tick