[GRASSLIST:5537] v.mkgrid extract grid sections

Hi Everyone,

I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids, and all
has been well.

Example image:
http://169.237.35.250/~dylan/temp/v.mkgrid_question.png

However, this morning I tried to extract a single square from the output from
v.mkgrid, and was only able to get either a single centroid (almost correct),
or the entire boundary (not good). Since the boundaries do not have CATs,
there is no way for me to extract a single boundary...

For example, I would like to extract a single grid square out of the entire
grid, so that I can use it to control the region.
(grid square 5 in this figure:
http://169.237.35.250/~dylan/temp/v.mkgrid_question.png)

I have tried v.extract, and v.type with no success... Surely there must be a
way to do this?!

Any ideas?

Thanks!

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
and all has been well.

..

However, this morning I tried to extract a single square from the
output from v.mkgrid, and was only able to get either a single
centroid (almost correct), or the entire boundary (not good). Since
the boundaries do not have CATs, there is no way for me to extract a
single boundary...

..

Any ideas?

what about

  v.category type=boundary option=add

to add category numbers to the boundaries?

Hamish

On Wednesday 26 January 2005 06:09 pm, Hamish wrote:

> I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
> and all has been well.

..

> However, this morning I tried to extract a single square from the
> output from v.mkgrid, and was only able to get either a single
> centroid (almost correct), or the entire boundary (not good). Since
> the boundaries do not have CATs, there is no way for me to extract a
> single boundary...

..

> Any ideas?

what about

  v.category type=boundary option=add

to add category numbers to the boundaries?

Thanks! ... this gives the boundaries CATs... but for some reason, each grid
square is made up of about 8 line segments (3 for top and bottom lines, 1 for
each vertical line)...

My hope is that i can make each grid "cell" into a discreet polygon, that can
be used to set the region -- i.e. so that i can accurately subsample a larger
map.

thanks!

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

Use v.extract type=area

Radim

Dylan Beaudette wrote:

On Wednesday 26 January 2005 06:09 pm, Hamish wrote:

I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
and all has been well.

..

However, this morning I tried to extract a single square from the
output from v.mkgrid, and was only able to get either a single
centroid (almost correct), or the entire boundary (not good). Since
the boundaries do not have CATs, there is no way for me to extract a
single boundary...

..

Any ideas?

what about

v.category type=boundary option=add

to add category numbers to the boundaries?

Thanks! ... this gives the boundaries CATs... but for some reason, each grid square is made up of about 8 line segments (3 for top and bottom lines, 1 for each vertical line)...

My hope is that i can make each grid "cell" into a discreet polygon, that can be used to set the region -- i.e. so that i can accurately subsample a larger map.

thanks!

Radim,

Thanks for the idea... but doing v.extract type=area leaves me with only the
centroids for each grid cell...

is there anyway to convert a set of line segments into a polygon?

thanks!

Dylan

On Thursday 27 January 2005 12:14 am, Radim Blazek wrote:

Use v.extract type=area

Radim

Dylan Beaudette wrote:
> On Wednesday 26 January 2005 06:09 pm, Hamish wrote:
>>>I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
>>>and all has been well.
>>
>>..
>>
>>>However, this morning I tried to extract a single square from the
>>>output from v.mkgrid, and was only able to get either a single
>>>centroid (almost correct), or the entire boundary (not good). Since
>>>the boundaries do not have CATs, there is no way for me to extract a
>>>single boundary...
>>
>>..
>>
>>>Any ideas?
>>
>>what about
>>
>> v.category type=boundary option=add
>>
>>to add category numbers to the boundaries?
>
> Thanks! ... this gives the boundaries CATs... but for some reason, each
> grid square is made up of about 8 line segments (3 for top and bottom
> lines, 1 for each vertical line)...
>
> My hope is that i can make each grid "cell" into a discreet polygon, that
> can be used to set the region -- i.e. so that i can accurately subsample
> a larger map.
>
> thanks!

--
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341

try v.clean ...

Em Qui 27 Jan 2005 16:24, Dylan Beaudette escreveu:

Radim,

Thanks for the idea... but doing v.extract type=area leaves me with only
the centroids for each grid cell...

is there anyway to convert a set of line segments into a polygon?

thanks!

Dylan

On Thursday 27 January 2005 12:14 am, Radim Blazek wrote:
> Use v.extract type=area
>
> Radim
>
> Dylan Beaudette wrote:
> > On Wednesday 26 January 2005 06:09 pm, Hamish wrote:
> >>>I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
> >>>and all has been well.
> >>
> >>..
> >>
> >>>However, this morning I tried to extract a single square from the
> >>>output from v.mkgrid, and was only able to get either a single
> >>>centroid (almost correct), or the entire boundary (not good). Since
> >>>the boundaries do not have CATs, there is no way for me to extract a
> >>>single boundary...
> >>
> >>..
> >>
> >>>Any ideas?
> >>
> >>what about
> >>
> >> v.category type=boundary option=add
> >>
> >>to add category numbers to the boundaries?
> >
> > Thanks! ... this gives the boundaries CATs... but for some reason, each
> > grid square is made up of about 8 line segments (3 for top and bottom
> > lines, 1 for each vertical line)...
> >
> > My hope is that i can make each grid "cell" into a discreet polygon,
> > that can be used to set the region -- i.e. so that i can accurately
> > subsample a larger map.
> >
> > thanks!

For me it works.
v.mkgrid map=pok grid=3,2 position=region
v.extract input=pok output=pok2 type=area list=4
...
Number of boundaries: 8
Number of centroids : 1
...

Radim

Dylan Beaudette wrote:

Radim,

Thanks for the idea... but doing v.extract type=area leaves me with only the centroids for each grid cell...

is there anyway to convert a set of line segments into a polygon?

thanks!

Dylan

On Thursday 27 January 2005 12:14 am, Radim Blazek wrote:

Use v.extract type=area

Radim

Dylan Beaudette wrote:

On Wednesday 26 January 2005 06:09 pm, Hamish wrote:

I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
and all has been well.

..

However, this morning I tried to extract a single square from the
output from v.mkgrid, and was only able to get either a single
centroid (almost correct), or the entire boundary (not good). Since
the boundaries do not have CATs, there is no way for me to extract a
single boundary...

..

Any ideas?

what about

v.category type=boundary option=add

to add category numbers to the boundaries?

Thanks! ... this gives the boundaries CATs... but for some reason, each
grid square is made up of about 8 line segments (3 for top and bottom
lines, 1 for each vertical line)...

My hope is that i can make each grid "cell" into a discreet polygon, that
can be used to set the region -- i.e. so that i can accurately subsample
a larger map.

thanks!

hi ,
what i have to do to reproject a raster that is in a different projection to current location´s projection?
i have to quit the location an then import this raster in another location whith the desired projection?
thanks
samuel

Radim Blazek blazek@itc.it wrote:

For me it works.
v.mkgrid map=pok grid=3,2 position=region
v.extract input=pok output=pok2 type=area list=4

Number of boundaries: 8
Number of centroids : 1

Radim

Dylan Beaudette wrote:

Radim,

Thanks for the idea… but doing v.extract type=area leaves me with only the
centroids for each grid cell…

is there anyway to convert a set of line segments into a polygon?

thanks!

Dylan

On Thursday 27 January 2005 12:14 am, Radim Blazek wrote:

Use v.extract type=area

Radim

Dylan Beaudette wrote:

On Wednesday 26 January 2005 06:09 pm, Hamish wrote:

I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
and all has been well.

However, this morning I tried to extract a single square from the
output from v.mkgrid, and was only able to get either a single
centroid (almost correct), or the entire boundary (not good). Since
the boundaries do not have CATs, there is no way for me to extract a
single boundary…

Any ideas?

what about

v.category type=boundary option=add

to add category numbers to the boundaries?

Thanks! … this gives the boundaries CATs… but for some reason, each
grid square! is made up of about 8 line segments (3 for top and bottom
lines, 1 for each vertical line)…

My hope is that i can make each grid “cell” into a discreet polygon, that
can be used to set the region – i.e. so that i can accurately subsample
a larger map.

thanks!


Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador do Yahoo! agora.

Samuel,
If you have imported your raster into location 1, then exit that location. Open up location 2 (your desired projection) and set your region to match the incoming raster with g.region w= e= s= n=
Following this, use r.proj in location 2 to bring in your raster from location 1. This is different only if location 1 is an XY location (without projection info). If so, write back and let us know, or look at the mail archives.

G'luck
-Ian

On Jan 31, 2005, at 8:02 AM, samuel cavalcante wrote:

hi ,
what i have to do to reproject a raster that is in a different projection to current location´s projection?
i have to quit the location an then import this raster in another location whith the desired projection?
thanks
samuel

Radim Blazek <blazek@itc.it> wrote:
For me it works.
v.mkgrid map=pok grid=3,2 position=region
v.extract input=pok output=pok2 type=area list=4
...
Number of boundaries: 8
Number of centroids : 1
...

Radim

Dylan Beaudette wrote:
> Radim,
>
> Thanks for the idea... but doing v.extract type=area leaves me with only the
> centroids for each grid cell...
>
> is there anyway to convert a set of line segments into a polygon?
>
> thanks!
>
> Dylan
>
> On Thursday 27 January 2005 12:14 am, Radim Blazek wrote:
>
>>Use v.extract type=area
>>
>>Radim
>>
>>Dylan Beaudette wrote:
>>
>>>On Wednesday 26 January 2005 06:09 pm, Hamish wrote:
>>>
>>>>>I have used v.mkgrid (GRASS6-CVS) in the past to make vector grids,
>>>>>and all has been well.
>>>>
>>>>..
>>>>
>>>>>However, this morning I tried to extract a single square from the
>>>>>output from v.mkgrid, and was only able to get either a single
>>>>>centroid (almost correct), or the entire boundary (not good). Since
>>>>>the boundaries do not have CATs, there is no way for me to extract a
>>>>>single boundary...
>>>>
>>>>..
>>>>
>>>>>Any ideas?
>>>>
>>>>what about
>>>>
>>>> v.category type=boundary option=add
>>>>
>>>>to add category numbers to the boundaries?
>>>
>>>Thanks! ... this gives the boundaries CATs... but for some reason, each
>>>grid square is made up of about 8 line segments (3 for top and bottom
>>>lines, 1 for each vertical line)...
>>>
>>>My hope is that i can make each grid "cell" into a discreet polygon, that
>>>can be used to set the region -- i.e. so that i can accurately subsample
>>>a larger map.
>>>
>>>thanks!
>
&gtt;

Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador do Yahoo! agora.

I've an ETOP30 subproduct with "lambert azimutal equal
area" projection which a get in "location 1", the file
WIND generate has the following information:

proj: 4
zone: 1
north: 4384500
south: -3999500
east: 4639500
west: -4462500
cols: 9102
rows: 8384

When a try to change of projection (to lat-lon) in
"location 2" setting my region to match the incoming
raster with g.region w=-137.8 e=-63.2 s=10 n=80 with
the following information in the WIND file:
proj: 3
zone: 1
north: 80
south: 10
east: -63.2
west: -137.8
cols: 9102
rows: 8384
e-w resol: 0.008196
n-s resol: 0.00834924

i get the following error:
r.proj in=altura_00 location=grasspru2
mapset=PERMANENT dbase=/home/miguel/GRASS/ out=kk00

Input Projection Parameters: +proj=laea +a=6378137
+rf=298.257223563 +no_defs +nadgrids=conus
Input Unit Factor: 1

Output Projection Parameters: +proj=latlong +a=6378137
+rf=298.257223563 +no_defs +nadgrids=conus

Output Unit Factor: 1
ERROR: Input map is outside current region

How i can do the change in projection correctly??
The PROJ_INFO in location 1 has
name: laea
datum: WGS84
nadgrids: conus
proj: laea
ellps: WGS84
a: 6370997.
es: 0.0067686580
f: 294.9786982000
zone: 1

and in the location 2 has
name: ltln
datum: WGS84
nadgrids: conus
proj: ll
ellps: WGS84
a: 6378206.4000000004
es: 0.0067686580
f: 294.9786982000
zone: 1

I'm working in the version 6.0 beta1.

=====
LCA Miguel A. Altamirano del C.
"Los Mexicanos llevamos la fiesta en la garganta"

Tel. 01(232)32 45208

La belleza de la meteorología radica en saber
pronosticarla y no simplemente en estudiarla
      (Miguel A. Altamirano 28-5-00)

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

Miguel,
I am not sure what the problem is, but I think this solution (hack) may work until you find the real problem. In location 2, set your region to the size of the northwestern hemisphere with g.region n=90 s=0 e=0 w=-180 res=00:30:00

You want a really high resolution so that this initial projection goes fast. Once this is done, use r.proj to bring in your file. It should show up as a few pixels. Zoom into an area just outside of these pixels with d.zoom. Erase the file with g.remove rast=your_map. Set your region resolution to something more appropriate with g.region res=00:00:03 (or whatever) and then use r.proj again. Your map should come in fine.

G'luck
-Ian

On Jan 31, 2005, at 3:21 PM, Miguel A. Altamirano del C wrote:

I've an ETOP30 subproduct with "lambert azimutal equal
area" projection which a get in "location 1", the file
WIND generate has the following information:

proj: 4
zone: 1
north: 4384500
south: -3999500
east: 4639500
west: -4462500
cols: 9102
rows: 8384

When a try to change of projection (to lat-lon) in
"location 2" setting my region to match the incoming
raster with g.region w=-137.8 e=-63.2 s=10 n=80 with
the following information in the WIND file:
proj: 3
zone: 1
north: 80
south: 10
east: -63.2
west: -137.8
cols: 9102
rows: 8384
e-w resol: 0.008196
n-s resol: 0.00834924

i get the following error:
r.proj in=altura_00 location=grasspru2
mapset=PERMANENT dbase=/home/miguel/GRASS/ out=kk00

Input Projection Parameters: +proj=laea +a=6378137
+rf=298.257223563 +no_defs +nadgrids=conus
Input Unit Factor: 1

Output Projection Parameters: +proj=latlong +a=6378137
+rf=298.257223563 +no_defs +nadgrids=conus

Output Unit Factor: 1
ERROR: Input map is outside current region

How i can do the change in projection correctly??
The PROJ_INFO in location 1 has
name: laea
datum: WGS84
nadgrids: conus
proj: laea
ellps: WGS84
a: 6370997.
es: 0.0067686580
f: 294.9786982000
zone: 1

and in the location 2 has
name: ltln
datum: WGS84
nadgrids: conus
proj: ll
ellps: WGS84
a: 6378206.4000000004
es: 0.0067686580
f: 294.9786982000
zone: 1

I'm working in the version 6.0 beta1.

=====
LCA Miguel A. Altamirano del C.
"Los Mexicanos llevamos la fiesta en la garganta"

Tel. 01(232)32 45208

La belleza de la meteorología radica en saber
pronosticarla y no simplemente en estudiarla
      (Miguel A. Altamirano 28-5-00)

_________________________________________________________
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

I've an ETOP30 subproduct with "lambert azimutal equal
area" projection which a get in "location 1"

..

When a try to change of projection (to lat-lon) in
"location 2" setting my region to match the incoming
raster with g.region w=-137.8 e=-63.2 s=10 n=80

..

i get the following error:
r.proj in=altura_00 location=grasspru2

..

ERROR: Input map is outside current region

How i can do the change in projection correctly??

In the "from" (lambert) location run:
g.region rast=etop30 (or whatever map)
g.region -l

That will give you the lat/lon coordinates of the original map.
Use the greater extent of those settings (maybe a little bigger)
as the region settings in the "to" (lat-lon) location.
You can do a little math to figure out the correct resolution on the
lat/lon side (meters/(1852.*60)) (or just match rows/cols +10% or so?)
???

Hamish

Ian,
well, it worked but i have still a question about…
how i set the resolution of the new location to fit the original raster resolution? the way of describe the resolution in the process of creating a new location is quite different of that displayed when i run g.region or r.info (both in the original location)…
thanks in advance
samuel

Ian MacMillan ian_macmillan@umail.ucsb.edu wrote:

Samuel,
If you have imported your raster into location 1, then exit that
location. Open up location 2 (your desired projection) and set your
region to match the incoming raster with g.region w= e= s= n=
Following this, use r.proj in location 2 to bring in your raster from
location 1. This is different only if location 1 is an XY location
(without projection info). If so, write back and let us know, or look
at the mail archives.

G’luck
-Ian

On Jan 31, 2005, at 8:02 AM, samuel cavalcante wrote:

hi ,
what i have to do to reproject a raster that is in a different
projection to current location´s projection?
i have to quit the location an then import this raster in another
location whith the desired projection?
thanks
samuel

Radim Blazek


Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador do Yahoo! agora.

Samuel, I think I know your problem. You might not know your new region coordinates, especialy if say you are going from a lat long to a mercator projection. I wish there was a simple flag in r.proj to account for this, but for a variety of reasons (see archives if you're interested) it can't happen.

Workaround hack:
In location 1, set your region to the raster with
g.region rast=yourmap

Make a vector that conforms to this region with
v.mkgrid map=newvect grid=1,1 position=region

Exit location 1, open location 2 run v.proj for your new region vector
Your region does NOT need to be set to run v.proj, only for r.proj.

Change your region to match the vector with
g.region vect=newvect

Now that your region is set (you will still need to figure out the correct resolution on your own), you can run r.proj.

G'luck
-Ian

On Feb 2, 2005, at 11:02 AM, samuel cavalcante wrote:

Ian,
well, it worked but i have still a question about..
how i set the resolution of the new location to fit the original raster resolution? the way of describe the resolution in the process of creating a new location is quite different of that displayed when i run g.region or r.info (both in the original location)...
thanks in advance
samuel

Ian MacMillan <ian_macmillan@umail.ucsb.edu> wrote:
Samuel,
If you have imported your raster into location 1, then exit that
location. Open up location 2 (your desired projection) and set your
region to match the incoming raster with g.region w= e= s= n=
Following this, use r.proj in location 2 to bring in your raster from
location 1. This is different only if location 1 is an XY location
(without projection info). If so, write back and let us know, or look
at the mail archives.

G'luck
-Ian

On Jan 31, 2005, at 8:02 AM, samuel cavalcante wrote:

> hi ,
> what i have to do to reproject a raster that is in a different
> projection to current location´s projection?
> i have to quit the location an then import this raster in another
> location whith the desired projection?
> thanks
> samuel
>
> Radim Blazek wrote:
> For me it works.
> v.mkgrid map=pok grid=3,2 position=region
> v.extract input=pok output=pok2 type=area list=4
> ...
> Number of boundaries: 8
> Number of centroids : 1
> ...
>
> Radim
>
> Dylan Beaudette wrote:
> > Radim,
> >
> > Thanks for the idea... but doing v.extract type=area leaves me with
> only the
> > centroids for each grid cell...
> >
> > is there anyway to convert a set of line segments into a polygon?
> >
> > thanks!
> >
> > Dylan
> >
> > On Thursday 27 January 2005 12:14 am, Radim Blazek wrote:
> >
> >>Use v.extract type=area
> >>
> >>Radim
> >>
> >>Dylan Beaudette wrote:
> >>
> >>>On Wednesday 26 January 2005 06:09 pm, Hamish wrote:
> >>>
> >>>>>I have used v.mkgrid (GRASS6-CVS) in the past to make vector
> grids,
> >>>>>and all has been well.
> >>>>
> >>>>..
> >>>>
> >>>>>However, this morning I tried to extract a single square from the
> >>>>>output from v.mkgrid, and was only able to get either a single
> >>>>>centroid (almost correct), or the entire boundary (not good).
> Since
> >>>>>the boundaries do not have CATs, there is no way for me to
> extract a
> >>>>>single boundary...
> >>>>
> >>>>..
> >>>>
> >>>>>Any ideas?
> >>>>
> >>>>what about
> >>>>
> >>>> v.category type=boundary option=add
> >>>>
> >>>>to add category numbers to the boundaries?
> >>>
> >>>Thanks! ... this gives the boundaries CATs... but for some reason,
> each
> >>>grid square is made up of about 8 line segments (3 for top and
> bottom
> >>>lines, 1 for each vertical line)...
> >>>
> >>>My hope is that i can make each grid "cell" into a discreet
> polygon, that
> >>>can be used to set the region -- i.e. so that i can accurately
> subsample
> >>>a larger map.
> >>>
> >>>thanks!
> >
> >t;
>
> Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador
> do Yahoo! agora.

Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador do Yahoo! agora.