[GRASS-user] create raster from line vector

Hello everyone.
A simple question, but I'm getting mad with it!
I simply have to convert a vector line to raster. I've done it many
times in the past, but this time I can't make it work:

v.to.rast input=border output=border use=val type=line layer=1 value=1

The output is simply blank (MAX and MIN values are NULL)
What stupid error am I doing?

Giovanni

On Mon, 2009-02-16 at 15:17 +0100, G. Allegri wrote:

Hello everyone.
A simple question, but I'm getting mad with it!
I simply have to convert a vector line to raster. I've done it many
times in the past, but this time I can't make it work:

v.to.rast input=border output=border use=val type=line layer=1 value=1

The output is simply blank (MAX and MIN values are NULL)
What stupid error am I doing?

Giovanni

The first thing that fall into my mind:

MASK?
Perhaps it's a irrelevant thought, but I remember some "strange"
behaviour with floating point values (in your case the pixels that
compose your raster line). Could it be they are rounded down to 0?

Regards, Nikos

Thnaks Nikos. I don't have neither MASKs nor raster values near 0...
As you can see in my command I've set the value to 1.
I start to think there's something wrong with my GRASS build...

2009/2/16 Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de>:

On Mon, 2009-02-16 at 15:17 +0100, G. Allegri wrote:

Hello everyone.
A simple question, but I'm getting mad with it!
I simply have to convert a vector line to raster. I've done it many
times in the past, but this time I can't make it work:

v.to.rast input=border output=border use=val type=line layer=1 value=1

The output is simply blank (MAX and MIN values are NULL)
What stupid error am I doing?

Giovanni

The first thing that fall into my mind:

MASK?
Perhaps it's a irrelevant thought, but I remember some "strange"
behaviour with floating point values (in your case the pixels that
compose your raster line). Could it be they are rounded down to 0?

Regards, Nikos

I share my vector, if someone wants to reproduce this problem:

http://www.geospatial.it/allegri/bordi.tar.gz
EPSG:32632

2009/2/16 G. Allegri <giohappy@gmail.com>:

Thnaks Nikos. I don't have neither MASKs nor raster values near 0...
As you can see in my command I've set the value to 1.
I start to think there's something wrong with my GRASS build...

2009/2/16 Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de>:

On Mon, 2009-02-16 at 15:17 +0100, G. Allegri wrote:

Hello everyone.
A simple question, but I'm getting mad with it!
I simply have to convert a vector line to raster. I've done it many
times in the past, but this time I can't make it work:

v.to.rast input=border output=border use=val type=line layer=1 value=1

The output is simply blank (MAX and MIN values are NULL)
What stupid error am I doing?

Giovanni

The first thing that fall into my mind:

MASK?
Perhaps it's a irrelevant thought, but I remember some "strange"
behaviour with floating point values (in your case the pixels that
compose your raster line). Could it be they are rounded down to 0?

Regards, Nikos

On Mon, 2009-02-16 at 15:40 +0100, G. Allegri wrote:

I share my vector, if someone wants to reproduce this problem:

http://www.geospatial.it/allegri/bordi.tar.gz
EPSG:32632

Giovanni,

the shapefile's attribute table looks messed up. I just opened it with
QGIS and the column names are senseless characters. In addition, all
rows are filled with NULL.

I don't know it's just a "codepage" sort of problem or the reason for
your empty raster.

I will try with GRASS now. If I'll find something useful I'll post back.

Kind regards, Nikos

On Mon, 2009-02-16 at 15:52 +0100, Nikos Alexandris wrote:

On Mon, 2009-02-16 at 15:40 +0100, G. Allegri wrote:
> I share my vector, if someone wants to reproduce this problem:
>
> http://www.geospatial.it/allegri/bordi.tar.gz
> EPSG:32632

Giovanni,

the shapefile's attribute table looks messed up. I just opened it with
QGIS and the column names are senseless characters. In addition, all
rows are filled with NULL.

I don't know it's just a "codepage" sort of problem or the reason for
your empty raster.

I will try with GRASS now. If I'll find something useful I'll post back.

Sorry, I can't even read it with ogrinfo.

ogrinfo /home/nik/Desktop/in/bordi.shp -al | head -100

ERROR 3: fread(65004) failed on DBF file.

ERROR 3: fread(65004) failed on DBF file.

[...]

INFO: Open of `/home/nik/Desktop/in/bordi.shp'
      using driver `ESRI Shapefile' successful.

Layer name: bordi
Geometry: Line String
Feature Count: 9
Extent: (1009114.847644, 4446909.136474) - (1312106.717266,
4668313.355348)
Layer SRS WKT:
PROJCS["WGS_1984_UTM_Zone_32N",
    GEOGCS["GCS_WGS_1984",
        DATUM["WGS_1984",
            SPHEROID["WGS_1984",6378137,298.257223563]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",9],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
��N���nL@Q: String (17.0)
L$D=�u����: String (207.0)
�=?��e�: String (191.0)
��GMI�FYYY: String (78.0)
'6:�+JX�fW`: String (235.0)
g��ʚ*;: String (243.0)
_"*gD88Z��: String (109.0)
2U]「��@QU�: String (119.0)
�'@TN�]����: String (223.0)

�魗n�676t: String (117.0)
+&<JWv���: String (136.0)
����\��: String (212.0)
o����7ʤ��: String (247.0)
<�_\��: String (126.0)
ˆøßøŒÿÛù¯L: S├⎼␋┼± (207.0)
;4OÓÓÐà4´Þ: S├⎼␋┼± (32.0)
B8¬┘┴šì¶%þ¿: S├⎼␋┼± (33.0)
dž¸˜øæ%¬?│: S├⎼␋┼± (200.0)
[...]

# it continues like that :frowning:

??? even the new one that I've uploaded?

2009/2/16 Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de>:

On Mon, 2009-02-16 at 15:52 +0100, Nikos Alexandris wrote:

On Mon, 2009-02-16 at 15:40 +0100, G. Allegri wrote:
> I share my vector, if someone wants to reproduce this problem:
>
> http://www.geospatial.it/allegri/bordi.tar.gz
> EPSG:32632

Giovanni,

the shapefile's attribute table looks messed up. I just opened it with
QGIS and the column names are senseless characters. In addition, all
rows are filled with NULL.

I don't know it's just a "codepage" sort of problem or the reason for
your empty raster.

I will try with GRASS now. If I'll find something useful I'll post back.

Sorry, I can't even read it with ogrinfo.

ogrinfo /home/nik/Desktop/in/bordi.shp -al | head -100

ERROR 3: fread(65004) failed on DBF file.

ERROR 3: fread(65004) failed on DBF file.

[...]

INFO: Open of `/home/nik/Desktop/in/bordi.shp'
     using driver `ESRI Shapefile' successful.

Layer name: bordi
Geometry: Line String
Feature Count: 9
Extent: (1009114.847644, 4446909.136474) - (1312106.717266,
4668313.355348)
Layer SRS WKT:
PROJCS["WGS_1984_UTM_Zone_32N",
   GEOGCS["GCS_WGS_1984",
       DATUM["WGS_1984",
           SPHEROID["WGS_1984",6378137,298.257223563]],
       PRIMEM["Greenwich",0],
       UNIT["Degree",0.017453292519943295]],
   PROJECTION["Transverse_Mercator"],
   PARAMETER["latitude_of_origin",0],
   PARAMETER["central_meridian",9],
   PARAMETER["scale_factor",0.9996],
   PARAMETER["false_easting",500000],
   PARAMETER["false_northing",0],
   UNIT["Meter",1]]
��N���nL@Q: String (17.0)
L$D=�u����: String (207.0)
�=? �� �: String (191.0)
��GMI�FYYY: String (78.0)
'6:�+JX�fW`: String (235.0)
g ��ʚ *; : String (243.0)
_"*gD88Z��: String (109.0)
2U]「��@QU�: String (119.0)
�'@TN�]����: String (223.0)

�魗n�676t: String (117.0)
+&<J W v���: String (136.0)
���� \�� : String (212.0)
o����7ʤ��: String (247.0)
<�_\ ��: String (126.0)
ˆøßøŒÿÛù¯L: S├⎼␋┼± (207.0)
;4OÓÓÐà 4´Þ: S├⎼␋┼± (32.0)
B8¬┘┴šì¶%þ¿: S├⎼␋┼± (33.0)
dž¸ ˜øæ%¬?│: S├⎼␋┼± (200.0)
[...]

# it continues like that :frowning:

On Mon, 2009-02-16 at 16:00 +0100, Nikos Alexandris wrote:

> > I share my vector, if someone wants to reproduce this problem:
> >
> > http://www.geospatial.it/allegri/bordi.tar.gz
> > EPSG:32632

It works now. No problem.

Cheers, Nikos
---

history

1 v.in.ogr dsn=/home/nik/Desktop/in/bordi.shp out=testbordi
2 d.mon x0
3 g.region vect=testbordi
4 g.region vect=testbordi -pa
5 d.vect testbordi
6 v.info testbordi
7 v.to.rast testbordi out=testbordirast use=val value=1
8 d.rast -o testbordirast
9 r.info testbodirast
10 r.info testbordirast
11 history

# r.info
r.info testbordirast -hgr

min=1
max=1
north=4668313.355348
south=4446909.136474
east=1312106.717266
west=1009114.847644
Data Source:
   Vector Map: testbordi in mapset PERMANENT
   Original scale from vector map: 1:1
Data Description:
   generated by v.to.rast
Comments:
   v.to.rast input="testbordi" output="testbordirast" use="val" type="p\
   oint,line,area" layer=1 value=1 rows=4096

Damn! So it was simply a problem with the attribute table. In the
meantime I've solved doing a moving average on the rasterized polygon,
and extracting only the cat values between the inside and the
outside... Not a straightfarword solution :slight_smile:

Thanks Nikos

2009/2/16 Nikos Alexandris <nikos.alexandris@felis.uni-freiburg.de>:

On Mon, 2009-02-16 at 16:00 +0100, Nikos Alexandris wrote:

> > I share my vector, if someone wants to reproduce this problem:
> >
> > http://www.geospatial.it/allegri/bordi.tar.gz
> > EPSG:32632

It works now. No problem.

Cheers, Nikos
---

history

1 v.in.ogr dsn=/home/nik/Desktop/in/bordi.shp out=testbordi
2 d.mon x0
3 g.region vect=testbordi
4 g.region vect=testbordi -pa
5 d.vect testbordi
6 v.info testbordi
7 v.to.rast testbordi out=testbordirast use=val value=1
8 d.rast -o testbordirast
9 r.info testbodirast
10 r.info testbordirast
11 history

# r.info
r.info testbordirast -hgr

min=1
max=1
north=4668313.355348
south=4446909.136474
east=1312106.717266
west=1009114.847644
Data Source:
  Vector Map: testbordi in mapset PERMANENT
  Original scale from vector map: 1:1
Data Description:
  generated by v.to.rast
Comments:
  v.to.rast input="testbordi" output="testbordirast" use="val" type="p\
  oint,line,area" layer=1 value=1 rows=4096