Re: [GRASS-user] composite raster maps

2013-11-26 Thread Vincent Bain
OK for the caution Glynn,

for my particular concern I finally re-ran the process from the source
files.

Thank you,
V.



Le mardi 26 novembre 2013 à 19:07 +, Glynn Clements a écrit :
> Markus Metz wrote:
> 
> > > I just realize I've used r.composite for ages without wondering how I
> > > could perform the reverse task. The thing is I ran r.composite on a 3
> > > band geotiff orthoimage, dropped the initial .red, .green and .blue
> > > rasters, and I would need them now in order to run r.out.vtk with the
> > > rgbmaps argument. Dummy...
> > 
> > You can use the # operator of r.mapcalc:
> > 
> > r.mapcalc "map.red = r#map"
> > r.mapcalc "map.green = g#map"
> > r.mapcalc "map.blue = b#map"
> 
> Note that GRASS 7 has the r.rgb script which does just this.
> 
> Also, note that an r.composite+r.rgb round-trip normally loses
> accuracy. By default, the maps generated by r.composite only use 32
> levels for each component (equivalent to a 15-bpp image).
> 
> You can avoid this with "r.composite ... levels=256", but the
> resulting maps will have much larger colour tables (65536 rules rather
> than 1024), which can make certain operations significantly slower.
> 


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

Re: [GRASS-user] i.maxlik can't read signature from i.class

2013-11-26 Thread Cesar Augusto Ramírez Franco
Hello Venka

Thank you for your response

Unfortunately, I did rescale my lsat8 images to 8bit, however, I tested
with North Carolina sample dataset which is Landsat 7 (8bit) and got the
same error, so it must be something else, maybe i.class generating a wrong
signature file?


2013/11/26 Venkatesh Raghavan 

>  Hi Augusto,
>
>
> In GRASS-6.4.3, i.class only works on 8bit images. Since the Landsat 8
> products are
> 12bit data, proper signature files cannot be produced by i.class.
>
> You could try rescaling data to 8bit and see if i.class and i.maxlik works.
>
> Best
>
> Venka
>
> P.S. I hope i.class will be support 12, 16bit images in future.
>
>
>
> On 2013/11/27 0:47, Cesar Augusto Ramírez Franco wrote:
>
> Hello everyone,
>
> I've been trying to do a supervised classification from landsat8 imagery
> using i.class and then i.maxlik, but I'm getting an error when running
> i.maxlik saying it can't read the signature file.
>
> I tested my procedure on the NC sample dataset and I'm getting the same
> error, I'm using Grass 6.4.2 on Debian Wheezy, installed from the debian
> repo. Here's the command set:
>
> #Display RGB enhanced map
> i.landsat.rgb blue=lsat7_2000_10 green=lsat7_2000_20 red=lsat7_2000_30
> d.rgb blue=lsat7_2000_10 green=lsat7_2000_20 red=lsat7_2000_30
> #"Real color" map
> r.composite red=lsat7_2000_30 green=lsat7_2000_20 blue=lsat7_2000_10
> output=lsat7_2000_RGB
> #Group images to process
> i.group group=lsat7_2000_RGB subgroup=lsat7_2000_RGB
> input=lsat7_2000_10,lsat7_2000_20,lsat7_2000_30
> #Unsupervised classification
> i.cluster group=lsat7_2000_RGB subgroup=lsat7_2000_RGB sigfile=clustlsat7
> classes=20 report=rep_clust_lsat7.txt
> i.maxlik group=lsat7_2000_RGB subgroup=lsat7_2000_RGB sigfile=clustlsat7
>  class=lsat7_classes reject=lsat7_classes_rej
> #Supervised classification
> i.class map=lsat7_2000_RGB group=lsat7_2000_RGB subgroup=lsat7_2000_RGB
> outsig=classlsat7
> i.maxlik group=lsat7_2000_RGB subgroup=lsat7_2000_RGB sigfile=classlsat7
> class=lsat7_class_sup
>
> Here I get the error in which i.maxlik can't read the signature file
> created by i.class (classlsat7) but read the one created by i.cluster
> flawlessly
>
> This is what I'm selecting on the i.class monitor, I named it vegetation:
> [image: Imagen integrada 1]
>
> And the contents of the classlsat7 signature file are the following:
>
>
>  ​
>
>
>  #
>
> #vegetation
>
> 166
>
> ​
>
>   Am I doing something wrong or is it some kind of bug?
>
>
>
>
> ___
> grass-user mailing 
> listgrass-user@lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/grass-user
>
>
>
> ___
> grass-user mailing list
> grass-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>



-- 
*César Augusto Ramírez Franco*
Laboratorio de Sistemas Complejos Naturales
Escuela de Geociencias
Facultad de Ciencias
Universidad Nacional de Colombia - Sede Medellín
Teléfono: (57-4) 430 9369 - 301 389 5607
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Dave Roberts

Markus,

> v.to.db map=new_geo layer=2 column=surgeo option=query qlayer=1
> qcolumn=surgeo
>
> In this example, the column surgeo in layer 2 must exist and must be
> of the same type like the column surgeo in layer 1.

the qcolumn actually had a different name, but with that small 
correction this worked like a charm.


Thanks again, Dave

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


Re: [GRASS-user] i.maxlik can't read signature from i.class

2013-11-26 Thread Venkatesh Raghavan

Hi Augusto,


In GRASS-6.4.3, i.class only works on 8bit images. Since the Landsat 8 
products are

12bit data, proper signature files cannot be produced by i.class.

You could try rescaling data to 8bit and see if i.class and i.maxlik works.

Best

Venka

P.S. I hope i.class will be support 12, 16bit images in future.


On 2013/11/27 0:47, Cesar Augusto Ramírez Franco wrote:

Hello everyone,

I've been trying to do a supervised classification from landsat8 imagery
using i.class and then i.maxlik, but I'm getting an error when running
i.maxlik saying it can't read the signature file.

I tested my procedure on the NC sample dataset and I'm getting the same
error, I'm using Grass 6.4.2 on Debian Wheezy, installed from the debian
repo. Here's the command set:

#Display RGB enhanced map
i.landsat.rgb blue=lsat7_2000_10 green=lsat7_2000_20 red=lsat7_2000_30
d.rgb blue=lsat7_2000_10 green=lsat7_2000_20 red=lsat7_2000_30
#"Real color" map
r.composite red=lsat7_2000_30 green=lsat7_2000_20 blue=lsat7_2000_10
output=lsat7_2000_RGB
#Group images to process
i.group group=lsat7_2000_RGB subgroup=lsat7_2000_RGB
input=lsat7_2000_10,lsat7_2000_20,lsat7_2000_30
#Unsupervised classification
i.cluster group=lsat7_2000_RGB subgroup=lsat7_2000_RGB sigfile=clustlsat7
classes=20 report=rep_clust_lsat7.txt
i.maxlik group=lsat7_2000_RGB subgroup=lsat7_2000_RGB sigfile=clustlsat7
  class=lsat7_classes reject=lsat7_classes_rej
#Supervised classification
i.class map=lsat7_2000_RGB group=lsat7_2000_RGB subgroup=lsat7_2000_RGB
outsig=classlsat7
i.maxlik group=lsat7_2000_RGB subgroup=lsat7_2000_RGB sigfile=classlsat7
class=lsat7_class_sup

Here I get the error in which i.maxlik can't read the signature file
created by i.class (classlsat7) but read the one created by i.cluster
flawlessly

This is what I'm selecting on the i.class monitor, I named it vegetation:
[image: Imagen integrada 1]

And the contents of the classlsat7 signature file are the following:




#

#vegetation

166





Am I doing something wrong or is it some kind of bug?



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


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

Re: [GRASS-user] composite raster maps

2013-11-26 Thread Glynn Clements

Markus Metz wrote:

> > I just realize I've used r.composite for ages without wondering how I
> > could perform the reverse task. The thing is I ran r.composite on a 3
> > band geotiff orthoimage, dropped the initial .red, .green and .blue
> > rasters, and I would need them now in order to run r.out.vtk with the
> > rgbmaps argument. Dummy...
> 
> You can use the # operator of r.mapcalc:
> 
> r.mapcalc "map.red = r#map"
> r.mapcalc "map.green = g#map"
> r.mapcalc "map.blue = b#map"

Note that GRASS 7 has the r.rgb script which does just this.

Also, note that an r.composite+r.rgb round-trip normally loses
accuracy. By default, the maps generated by r.composite only use 32
levels for each component (equivalent to a 15-bpp image).

You can avoid this with "r.composite ... levels=256", but the
resulting maps will have much larger colour tables (65536 rules rather
than 1024), which can make certain operations significantly slower.

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


Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Dave Roberts

Markus,

   Thanks a mill!  I'll try that when I get back to that machine.

   I really appreciate you time end expertise.  You're a scholar and a 
gentleman.


Dave

On 11/26/2013 08:48 AM, Markus Metz wrote:

On Tue, Nov 26, 2013 at 4:34 PM, Dave Roberts
  wrote:

I would suggest to run

v.category inp=geo type=centroid out=new_geo op=add layer=2 --o



Thanks Markus!  Now I'm getting somewhere.  v.info shows geo and new_geo in
perfect correspondence for areas, islands, boundaries, etc.

d.what.vect shows new_geo with the original data in layer 1 and the new data
in layer 2.  v.to.db successfully transferred the centroids (coor) and area
to layer 2.  However, I still don't see how to get the surficial geology
column (surgeo) out of layer 1 into layer 2 without a join item.  I know I'm
missing something simple, but v.to.db just seems to allow a restricted set
of values for option.


v.to.db map=new_geo layer=2 column=surgeo option=query qlayer=1 qcolumn=surgeo

In this example, the column surgeo in layer 2 must exist and must be
of the same type like the column surgeo in layer 1.

Markus M



Thanks, Dave

--

David W. Roberts office 406-994-4548
Professor and Head  FAX 406-994-3190
Department of Ecology email drobe...@montana.edu
Montana State University
Bozeman, MT 59717-3460


--

David W. Roberts office 406-994-4548
Professor and Head  FAX 406-994-3190
Department of Ecology email drobe...@montana.edu
Montana State University
Bozeman, MT 59717-3460
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Markus Metz
On Tue, Nov 26, 2013 at 4:34 PM, Dave Roberts
 wrote:
>> I would suggest to run
>>
>> v.category inp=geo type=centroid out=new_geo op=add layer=2 --o
>>
>
> Thanks Markus!  Now I'm getting somewhere.  v.info shows geo and new_geo in
> perfect correspondence for areas, islands, boundaries, etc.
>
> d.what.vect shows new_geo with the original data in layer 1 and the new data
> in layer 2.  v.to.db successfully transferred the centroids (coor) and area
> to layer 2.  However, I still don't see how to get the surficial geology
> column (surgeo) out of layer 1 into layer 2 without a join item.  I know I'm
> missing something simple, but v.to.db just seems to allow a restricted set
> of values for option.

v.to.db map=new_geo layer=2 column=surgeo option=query qlayer=1 qcolumn=surgeo

In this example, the column surgeo in layer 2 must exist and must be
of the same type like the column surgeo in layer 1.

Markus M

>
> Thanks, Dave
>
> --
> 
> David W. Roberts office 406-994-4548
> Professor and Head  FAX 406-994-3190
> Department of Ecology email drobe...@montana.edu
> Montana State University
> Bozeman, MT 59717-3460
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Dave Roberts

> I would suggest to run
>
> v.category inp=geo type=centroid out=new_geo op=add layer=2 --o
>

Thanks Markus!  Now I'm getting somewhere.  v.info shows geo and new_geo 
in perfect correspondence for areas, islands, boundaries, etc.


d.what.vect shows new_geo with the original data in layer 1 and the new 
data in layer 2.  v.to.db successfully transferred the centroids (coor) 
and area to layer 2.  However, I still don't see how to get the 
surficial geology column (surgeo) out of layer 1 into layer 2 without a 
join item.  I know I'm missing something simple, but v.to.db just seems 
to allow a restricted set of values for option.


Thanks, Dave
--

David W. Roberts office 406-994-4548
Professor and Head  FAX 406-994-3190
Department of Ecology email drobe...@montana.edu
Montana State University
Bozeman, MT 59717-3460
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


[GRASS-user] Get sums of raster values based on the categories of an overlay raster

2013-11-26 Thread Johannes Radinger
Hi,

I'd like to calculate the sum of all raster values that belong to a certain
group. This spatially organized group is also indicated by an overlay
raster (same resolution). Finally I want to assign these sums to a new
raster. That might sound slightly complicated but here an example:

Asume following initial raster map A with random values like:

1-2-1-1-3-4-3-4-2-5-2-3

and an overlay raster indicating 3 groups:

1-1-1-1-2-2-2-2-3-3-3-3

the sums for the groups are:
group 1 = 5
group 2 = 14
group 3= 12

so the final raster would be:

5-5-5-5-14-14-14-14-12-12-12-12

How can such a task be achieved in GRASS (7)?
Any ideas?

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

Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Markus Metz
On Tue, Nov 26, 2013 at 2:43 PM, Dave Roberts
 wrote:
> Thanks Markus.  This has me on the right track, but I haven't gotten it all
> to work yet.
>
>
> v.category map=geo type=centroid op=add layer=2
>
> refused to work without a new output map, so

ah, right.

>
> v.category inp=geo  out=new_geo op=add layer=2

you need to add the option type=centroid, see above, otherwise the
results might be unexpected.
>
> produced a new vector map where the cats are unique for each polygon.
>
> doing d.what.vect new_geo shows the old data in layer 1 and the new data in
> layer 2
>
>   Curiously, there are now 3938 polygons (instead of 1082).

That can be a side-effect of not using type=centroid with v.category.
Additionally, boundaries have now also categories, leading to a much
larger attribute table. I would suggest to run

v.category inp=geo type=centroid out=new_geo op=add layer=2 --o

followed by

v.category inp=geo op=report

to see what happened.

HTH,

Markus M


> If I do a
> v.db.connect to a table in Postgres and then v.to.db move over the cat and
> coor data psql shows that the first 2725 records are null (except for cat)
> and the X,Y coordinates start at cat 2726, giving me 1212 polygons with real
> data.
>
>I could maybe delete the first 2726 records and join this new table to
> the one with the stratigraphy data on the X and Y coordinates, but doing
> exact equality on floating point numbers is madness.
>
> Any ideas?
>
> Thanks, Dave
>
>
> On 11/26/2013 02:25 AM, Markus Metz wrote:
>>
>> On Tue, Nov 26, 2013 at 3:39 AM, Dave Roberts
>>  wrote:
>>>
>>> Friends,
>>>
>>>I'm not exactly a newbie, but still yet quite naive in GRASS.  This
>>> seems
>>> like a simple problem, but I suspect unforeseen problems with the simple
>>> solution.
>>>
>>>I have imported a surficial geology map from a shapefile.  There are
>>> 1082
>>> polygons.  Each of the polygons with the same surficial geology (e.g Agn,
>>> Archean gneiss) has the same cat (i.e. there are 29 polygons with cat=3).
>>> I
>>> would like to add several columns to this table (e.g. geologic era and
>>> primary lithology (e.g. granite vs limestone)).
>>>
>>> I normally associate all vector maps with a table in PostgreSQL using
>>> cat
>>> as the primary key (i.e. v.db.connect -o key=cat), but that clearly won't
>>> work here.  I could rename the column 'cat' in the DBF file, and add a
>>> new
>>> column with values 1-1082 as cat.
>>
>>
>> That does not work because the geometries don't get new categories.
>>
>>> If I save that as a new DBF file in a new
>>> shapefile directory, when I re-import with v.in.ogr will it necessarily
>>> get
>>> it right?  I.e, will GRASS associate the vertices the first polygon in
>>> the
>>> shapefile with the first row in the DBF file?  I only ask because
>>> PostgreSQl
>>> (like most DBMSs) does not guarantee the records to be in any specific
>>> order, and perhaps shapefiles don't either?
>>
>>
>> Shapefiles (using DBF) require the records in a specific order. GRASS
>> vectors do not require records to be in a specific order, they link
>> geometries to the appropriate record with the key column.
>>>
>>>
>>>  Is there a simple way to renumber the polygons 1 through 1082 that
>>> maintains integrity and allows me to connect the vector coverage to
>>> PostgreSQL instead of DBF?
>>
>>
>> v.category map=geo type=centroid op=add layer=2
>>
>> That will create a new layer where each area has a unique category.
>> The original layer where several areas share the same category is
>> preserved. You can add a new table to this layer with v.db.addtable
>> layer=2. Then you can transfer attributes from one layer to another
>> with v.to.db.
>>
>> HTH,
>>
>> Markus M
>>
>
> --
> 
> David W. Roberts office 406-994-4548
> Professor and Head  FAX 406-994-3190
> Department of Ecology email drobe...@montana.edu
> Montana State University
> Bozeman, MT 59717-3460
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Dave Roberts
Thanks Markus.  This has me on the right track, but I haven't gotten it 
all to work yet.


v.category map=geo type=centroid op=add layer=2

refused to work without a new output map, so

v.category inp=geo  out=new_geo op=add layer=2

produced a new vector map where the cats are unique for each polygon.

doing d.what.vect new_geo shows the old data in layer 1 and the new data 
in layer 2


  Curiously, there are now 3938 polygons (instead of 1082).  If I do a
v.db.connect to a table in Postgres and then v.to.db move over the cat 
and coor data psql shows that the first 2725 records are null (except 
for cat) and the X,Y coordinates start at cat 2726, giving me 1212 
polygons with real data.


   I could maybe delete the first 2726 records and join this new table 
to the one with the stratigraphy data on the X and Y coordinates, but 
doing exact equality on floating point numbers is madness.


Any ideas?

Thanks, Dave

On 11/26/2013 02:25 AM, Markus Metz wrote:

On Tue, Nov 26, 2013 at 3:39 AM, Dave Roberts
 wrote:

Friends,

   I'm not exactly a newbie, but still yet quite naive in GRASS.  This seems
like a simple problem, but I suspect unforeseen problems with the simple
solution.

   I have imported a surficial geology map from a shapefile.  There are 1082
polygons.  Each of the polygons with the same surficial geology (e.g Agn,
Archean gneiss) has the same cat (i.e. there are 29 polygons with cat=3).  I
would like to add several columns to this table (e.g. geologic era and
primary lithology (e.g. granite vs limestone)).

I normally associate all vector maps with a table in PostgreSQL using cat
as the primary key (i.e. v.db.connect -o key=cat), but that clearly won't
work here.  I could rename the column 'cat' in the DBF file, and add a new
column with values 1-1082 as cat.


That does not work because the geometries don't get new categories.


If I save that as a new DBF file in a new
shapefile directory, when I re-import with v.in.ogr will it necessarily get
it right?  I.e, will GRASS associate the vertices the first polygon in the
shapefile with the first row in the DBF file?  I only ask because PostgreSQl
(like most DBMSs) does not guarantee the records to be in any specific
order, and perhaps shapefiles don't either?


Shapefiles (using DBF) require the records in a specific order. GRASS
vectors do not require records to be in a specific order, they link
geometries to the appropriate record with the key column.


 Is there a simple way to renumber the polygons 1 through 1082 that
maintains integrity and allows me to connect the vector coverage to
PostgreSQL instead of DBF?


v.category map=geo type=centroid op=add layer=2

That will create a new layer where each area has a unique category.
The original layer where several areas share the same category is
preserved. You can add a new table to this layer with v.db.addtable
layer=2. Then you can transfer attributes from one layer to another
with v.to.db.

HTH,

Markus M



--

David W. Roberts office 406-994-4548
Professor and Head  FAX 406-994-3190
Department of Ecology email drobe...@montana.edu
Montana State University
Bozeman, MT 59717-3460
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Markus Metz
On Tue, Nov 26, 2013 at 11:08 AM, Moritz Lennert
 wrote:
> Doesn't v.in.ogr attribute new, unique cat values to every polygon ?

Not if the input feature is a MULTI* feature. All features in a
MULTIPOLYGON, MULTILINE, or MULTIPOINT will get the same category.
That keeps the attribute table small.

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


[GRASS-user] calculate percentage of land use in larger cells

2013-11-26 Thread Moritz Lennert

Hi,

I'm pretty sure that this has been discussed before and even that some 
solution already exists, but I just can't seem to find the right search 
terms to put my hands on it:


I have a raster layer with landcover at 0:00:10 resolution. I would like 
for a select of the landcover classes raster layers at 0:10 resolution 
with the percentage of surface of the respective class in the new pixel.


Currently I'm thinking of the following possible work flow:

- at resolution of landover map, for each class:
- r.mapcalc classX = if(cover=X,1,0)

- at coarser resolution
- r.resamp.stats in=classX out=classX_total method=sum
- r.mapcalc "classX_perc = classX_total / perc"

As an option one could also replace r.resamp.stats with 
r.out.xyz/r.in.out.xyz, but I'm not sure that there would be any 
advantage to that.


My question is: is there some option in an existing module (or addon 
module) that already does something like this ?


Moritz

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


Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Moritz Lennert

On 26/11/13 03:39, Dave Roberts wrote:

Friends,

   I'm not exactly a newbie, but still yet quite naive in GRASS.  This
seems like a simple problem, but I suspect unforeseen problems with the
simple solution.

   I have imported a surficial geology map from a shapefile.  There are
1082 polygons.  Each of the polygons with the same surficial geology
(e.g Agn, Archean gneiss) has the same cat (i.e. there are 29 polygons
with cat=3).  I would like to add several columns to this table (e.g.
geologic era and primary lithology (e.g. granite vs limestone)).

I normally associate all vector maps with a table in PostgreSQL
using cat as the primary key (i.e. v.db.connect -o key=cat), but that
clearly won't work here.  I could rename the column 'cat' in the DBF
file, and add a new column with values 1-1082 as cat.  If I save that as
a new DBF file in a new shapefile directory, when I re-import with
v.in.ogr will it necessarily get it right?  I.e, will GRASS associate
the vertices the first polygon in the shapefile with the first row in
the DBF file?  I only ask because PostgreSQl (like most DBMSs) does not
guarantee the records to be in any specific order, and perhaps
shapefiles don't either?

 Is there a simple way to renumber the polygons 1 through 1082 that
maintains integrity and allows me to connect the vector coverage to
PostgreSQL instead of DBF?


Doesn't v.in.ogr attribute new, unique cat values to every polygon ?

Could you give us the exact command for importing the shapefile ?

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


Re: [GRASS-user] multiple polygons with same cat

2013-11-26 Thread Markus Metz
On Tue, Nov 26, 2013 at 3:39 AM, Dave Roberts
 wrote:
> Friends,
>
>   I'm not exactly a newbie, but still yet quite naive in GRASS.  This seems
> like a simple problem, but I suspect unforeseen problems with the simple
> solution.
>
>   I have imported a surficial geology map from a shapefile.  There are 1082
> polygons.  Each of the polygons with the same surficial geology (e.g Agn,
> Archean gneiss) has the same cat (i.e. there are 29 polygons with cat=3).  I
> would like to add several columns to this table (e.g. geologic era and
> primary lithology (e.g. granite vs limestone)).
>
>I normally associate all vector maps with a table in PostgreSQL using cat
> as the primary key (i.e. v.db.connect -o key=cat), but that clearly won't
> work here.  I could rename the column 'cat' in the DBF file, and add a new
> column with values 1-1082 as cat.

That does not work because the geometries don't get new categories.

> If I save that as a new DBF file in a new
> shapefile directory, when I re-import with v.in.ogr will it necessarily get
> it right?  I.e, will GRASS associate the vertices the first polygon in the
> shapefile with the first row in the DBF file?  I only ask because PostgreSQl
> (like most DBMSs) does not guarantee the records to be in any specific
> order, and perhaps shapefiles don't either?

Shapefiles (using DBF) require the records in a specific order. GRASS
vectors do not require records to be in a specific order, they link
geometries to the appropriate record with the key column.
>
> Is there a simple way to renumber the polygons 1 through 1082 that
> maintains integrity and allows me to connect the vector coverage to
> PostgreSQL instead of DBF?

v.category map=geo type=centroid op=add layer=2

That will create a new layer where each area has a unique category.
The original layer where several areas share the same category is
preserved. You can add a new table to this layer with v.db.addtable
layer=2. Then you can transfer attributes from one layer to another
with v.to.db.

HTH,

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