[GRASS-user] Determining number of overlapping features per location after import of shape file

Hi

I am importing a vector layer from a shape file as follow, and get the
warning below:

v.in.ogr dsn=/home/rkrug/Documents/Projects/AlienSpread/data/input/ layer=fireHistory output=fireHistory --overwrite

WARNING: 703 areas represent more (overlapping) features, because polygons
         overlap in input layer(s). Such areas are linked to more than 1
         row in attribute table. The number of features for those areas is
         stored as category in layer 2

I am aware of that, and I want to create a raster layer with the
number of features overlapping in each location. As I ultimately need
a raster layer, I thought to use the following, but I get the error
message below:

v.to.rast input=fireHistory layer=2 output=mf use=attr column=category --overwrite

ERROR: Unable to get layer info for vector map

Why is that?

Is there another way of getting the number of overlapping features per cell?

Thanks

Rainer

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

Rainer,

I suggest to try the snap parameters of v.in.ogr first. Maybe the SHAPE
file is full of gaps and slivers (commonly found, even in governmental data).
Small snapping values might cure it. Be careful to not snap, say,
Africa to a triangle :slight_smile:

Markus

On Mon, Jun 23, 2008 at 12:13 PM, Rainer M Krug <r.m.krug@gmail.com> wrote:

Hi

I am importing a vector layer from a shape file as follow, and get the
warning below:

v.in.ogr dsn=/home/rkrug/Documents/Projects/AlienSpread/data/input/ layer=fireHistory output=fireHistory --overwrite

WARNING: 703 areas represent more (overlapping) features, because polygons
overlap in input layer(s). Such areas are linked to more than 1
row in attribute table. The number of features for those areas is
stored as category in layer 2

I am aware of that, and I want to create a raster layer with the
number of features overlapping in each location. As I ultimately need
a raster layer, I thought to use the following, but I get the error
message below:

v.to.rast input=fireHistory layer=2 output=mf use=attr column=category --overwrite

ERROR: Unable to get layer info for vector map

Why is that?

Is there another way of getting the number of overlapping features per cell?

Thanks

Rainer


Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa


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


Open Source Geospatial Foundation
http://www.osgeo.org/
http://www.grassbook.org/

On Mon, Jun 23, 2008 at 9:08 PM, Markus Neteler <neteler@osgeo.org> wrote:

Rainer,

I suggest to try the snap parameters of v.in.ogr first. Maybe the SHAPE
file is full of gaps and slivers (commonly found, even in governmental
data).
*Small* snapping values might cure it. Be careful to not snap, say,
Africa to a triangle :slight_smile:

Markus

Thanks Markus,

but the information is there. If I display the layer and select
layer=2, I see the overlapping areas, and if I click i=on them to get
information (v.what -a map=fires@simulation ...), I get the following
info:

East: 255207.46888
North: 6235456.43154

Map: fireHistory
Mapset: simulation
Type: Centroid
Line: 3202
Layer: 1
Category: 4

Driver: dbf
Database: /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/dbf/
Table: fireHistory
Key column: cat
cat : 4
YEAR : 2005
Layer: 1
Category: 178

Driver: dbf
Database: /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/dbf/
Table: fireHistory
Key column: cat
cat : 178
YEAR : 1993
Layer: 1
Category: 208

Driver: dbf
Database: /home/rkrug/Documents/Projects/AlienSpread/R/../grass/simulation/dbf/
Table: fireHistory
Key column: cat
cat : 208
YEAR : 1995
Layer: 2
Category: 3 <<---

and the one value marked by <<-- is the one which IO want to extract
into a raster or vector map.
Even if I do

v.extract input=fireHistory@simulation output=fires
type=point,line,boundary,area layer=2

it gives me the areas, but no associated attribute table.

On Mon, Jun 23, 2008 at 12:13 PM, Rainer M Krug <r.m.krug@gmail.com> wrote:

Hi

I am importing a vector layer from a shape file as follow, and get the
warning below:

> v.in.ogr dsn=/home/rkrug/Documents/Projects/AlienSpread/data/input/
> layer=fireHistory output=fireHistory --overwrite

WARNING: 703 areas represent more (overlapping) features, because polygons
        overlap in input layer(s). Such areas are linked to more than 1
        row in attribute table. The number of features for those areas is
        stored as category in layer 2

I am aware of that, and I want to create a raster layer with the
number of features overlapping in each location. As I ultimately need
a raster layer, I thought to use the following, but I get the error
message below:

> v.to.rast input=fireHistory layer=2 output=mf use=attr column=category
> --overwrite

ERROR: Unable to get layer info for vector map

Why is that?

Is there another way of getting the number of overlapping features per
cell?

Thanks

Rainer

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Open Source Geospatial Foundation
http://www.osgeo.org/
http://www.grassbook.org/

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

Is there another way of getting the number of overlapping features
per cell?

Hi,

maybe this helps- you can try Radim's example from the vector screenshots page. (see GRASS 6.0 "Overlapping polygons" section)

http://grass.osgeo.org/screenshots/vector.php

Yes, funny place for tutorial material, but it demos some functionality.

Hamish

On Tue, Jun 24, 2008 at 9:57 AM, Hamish <hamish_b@yahoo.com> wrote:

Is there another way of getting the number of overlapping features
per cell?

Hi,

maybe this helps- you can try Radim's example from the vector screenshots page. (see GRASS 6.0 "Overlapping polygons" section)

http://grass.osgeo.org/screenshots/vector.php

Yes, funny place for tutorial material, but it demos some functionality.

Thanks Hamish - I found that one alredy, but it does not work:

OK - her is what I did:

v.category input=fire_p output=fire_c type=centroid option=add --o <<-- option field=2 does not exist any more?

WARNING: Vector map <fire_c> already exists and will be overwritten
Building topology ...
3901 primitives registered
Building areas: 100%
1220 areas built
54 isles built
Attaching islands: 100%
Attaching centroids: 100%
Topology was built.
Number of nodes : 2735
Number of primitives: 3901
Number of points : 0
Number of lines : 0
Number of boundaries: 2746
Number of centroids : 1155
Number of areas : 1220
Number of isles : 54
Number of areas without centroid : 65
[Raster MASK present]

echo "create table fire_c_2 (id int, num int)" | db.execute

v.db.connect map=fire_c driver=dbf layer=2 table=fire_c_2 key=id -o

The table <fire_c_2> is now part of vector map <fire_c> and may be deleted
or overwritten by GRASS modules
[Raster MASK present]

> v.to.db map=fire_c layer=2 option=cat col=id <<-- option col1=
changed to col=
Updating database...
100%
7 categories read from map
0 records selected from table
0 categories read from map exist in selection from table
6 categories read from map don't exist in selection from table
6 records updated/inserted
0 update/insert errors
[Raster MASK present]

> v.to.db map=fire_c layer=2 qlayer=1 option=query column=num
qcolumn="count(*)" type=centroid <<-- option col1= changed to column=
qcol= to qcolumn=
Reading data from the map...
100%
Querying database...
DBMI-DBF driver error:
SQL parser error:
in statement:
SELECT count(*) FROM ...
Error in db_open_select_cursor()

I guess this is a problem with the dbf database? Is there any way of
solving this in dbf?

Rainer

Hamish

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
Biology, UCT), Dipl. Phys. (Germany)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa