[GRASSLIST:7564] Synergy between Grass/Python/GMT

I've been working on a script to convert GRASS rasters directly into
GMT plots in a single command. So far it converts the raster to GMT
format, copies over the colormap and builds a simple graticule and
scale bar. Works well.

In the process of building this script, however, I discovered there is
some great synergy possible between IPython (the interactive python
shell) and GRASS. Here is how it works:

1) Launch ipython from within your grass shell
2) import a simple class designed to work with rasters
3) BINGO! you've got full control of command line grass + full
interactive Python abilities.

The class I wrote for grass rasters contains a bunch of instance
variables that hold basic info about the raster (resolution, bounding
box, etc.) and some methods to ease interaction with Python, like a
get_value(X, Y) method.

There are some really powerful things you can do with this that cannot
be done with any other GIS. Very cool!

David

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

Hello David,

On Fri, 15 Jul 2005 16:27:18 -0700 David Finlayson
<david.p.finlayson@gmail.com> wrote:

I've been working on a script to convert GRASS rasters directly into
GMT plots in a single command. So far it converts the raster to GMT
format, copies over the colormap and builds a simple graticule and
scale bar. Works well.

In the process of building this script, however, I discovered there is
some great synergy possible between IPython (the interactive python
shell) and GRASS. Here is how it works:

1) Launch ipython from within your grass shell
2) import a simple class designed to work with rasters
3) BINGO! you've got full control of command line grass + full
interactive Python abilities.

The class I wrote for grass rasters contains a bunch of instance
variables that hold basic info about the raster (resolution, bounding
box, etc.) and some methods to ease interaction with Python, like a
get_value(X, Y) method.

Would you like to share the python class which you wrote for
raster-maps?
It would be nice having the class in CVS to make it possible for others
too?

Thanks for your comment

  Stephan

--
       ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::

GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

I'd be happy to share it, but frankly it's pretty crude. I'd be
embarrassed to foist this off as a good example of either Grass or
Python (though maybe it is a good example of how flexible this
combination is, even for light-weight programmers). The class simply
wraps an interface around a few standard GRASS commands and captures
the results (r.region for example). My dream is to write a real Python
interface to the Grass programming interface, but that project is on
hold until I finish my PhD.

Is there a good place on the wiki for sharing scripts? When I get this
GMT thing polished up I think it will be quite useful for folks who
use GMT.

David

On 7/15/05, Stephan Holl <holl@gdf-hannover.de> wrote:

Hello David,

On Fri, 15 Jul 2005 16:27:18 -0700 David Finlayson
<david.p.finlayson@gmail.com> wrote:

> I've been working on a script to convert GRASS rasters directly into
> GMT plots in a single command. So far it converts the raster to GMT
> format, copies over the colormap and builds a simple graticule and
> scale bar. Works well.
>
> In the process of building this script, however, I discovered there is
> some great synergy possible between IPython (the interactive python
> shell) and GRASS. Here is how it works:
>
> 1) Launch ipython from within your grass shell
> 2) import a simple class designed to work with rasters
> 3) BINGO! you've got full control of command line grass + full
> interactive Python abilities.
>
> The class I wrote for grass rasters contains a bunch of instance
> variables that hold basic info about the raster (resolution, bounding
> box, etc.) and some methods to ease interaction with Python, like a
> get_value(X, Y) method.

Would you like to share the python class which you wrote for
raster-maps?
It would be nice having the class in CVS to make it possible for others
too?

Thanks for your comment

        Stephan

--
       ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::

GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

David,

I am extremely interested in any possible ways to streamline the GRASS-GMT workflow.

I have started documenting a BASH shell version of the process, but a python interface might be able to provide a tremendous amount of flexibility compared to BASH.

The website where this is documented is currently down (power outage while I was out in the field...), but I will try and have it back up in a couple hours. Please let me know about any future plans with this--

Cheers,

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

On Jul 15, 2005, at 10:39 PM, David Finlayson wrote:

I'd be happy to share it, but frankly it's pretty crude. I'd be
embarrassed to foist this off as a good example of either Grass or
Python (though maybe it is a good example of how flexible this
combination is, even for light-weight programmers). The class simply
wraps an interface around a few standard GRASS commands and captures
the results (r.region for example). My dream is to write a real Python
interface to the Grass programming interface, but that project is on
hold until I finish my PhD.

Is there a good place on the wiki for sharing scripts? When I get this
GMT thing polished up I think it will be quite useful for folks who
use GMT.

David

On 7/15/05, Stephan Holl <holl@gdf-hannover.de> wrote:

Hello David,

On Fri, 15 Jul 2005 16:27:18 -0700 David Finlayson
<david.p.finlayson@gmail.com> wrote:

I've been working on a script to convert GRASS rasters directly into
GMT plots in a single command. So far it converts the raster to GMT
format, copies over the colormap and builds a simple graticule and
scale bar. Works well.

In the process of building this script, however, I discovered there is
some great synergy possible between IPython (the interactive python
shell) and GRASS. Here is how it works:

1) Launch ipython from within your grass shell
2) import a simple class designed to work with rasters
3) BINGO! you've got full control of command line grass + full
interactive Python abilities.

The class I wrote for grass rasters contains a bunch of instance
variables that hold basic info about the raster (resolution, bounding
box, etc.) and some methods to ease interaction with Python, like a
get_value(X, Y) method.

Would you like to share the python class which you wrote for
raster-maps?
It would be nice having the class in CVS to make it possible for others
too?

Thanks for your comment

        Stephan

--
       ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::

GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

I have posted my GRASS -> GMT script on my web site (r.out.gmt.py):

http://students.washington.edu/dfinlays/scripts/

If anyone finds this useful, please send me suggestions. I will keep
working on it until it isn't such a hack.

Currently, it converts a raster, its colormap and optionally an
intensity raster (such as shaded relief) to GMT format. It then builds
a skeleton GMT plotting file that includes the raster (optionally
shaded with the intensity grid), a graticule and map decorations with
all of the tedious scale calculations already performed.

You need to edit the results to get it to look right, but the time
savings (for me) is probably close to an hour a plot over doing the
same steps manually.

David

On 7/16/05, Dylan Beaudette <dylan@iici.no-ip.org> wrote:

David,

I am extremely interested in any possible ways to streamline the
GRASS-GMT workflow.

I have started documenting a BASH shell version of the process, but a
python interface might be able to provide a tremendous amount of
flexibility compared to BASH.

The website where this is documented is currently down (power outage
while I was out in the field...), but I will try and have it back up in
a couple hours. Please let me know about any future plans with this--

Cheers,

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

On Jul 15, 2005, at 10:39 PM, David Finlayson wrote:

> I'd be happy to share it, but frankly it's pretty crude. I'd be
> embarrassed to foist this off as a good example of either Grass or
> Python (though maybe it is a good example of how flexible this
> combination is, even for light-weight programmers). The class simply
> wraps an interface around a few standard GRASS commands and captures
> the results (r.region for example). My dream is to write a real Python
> interface to the Grass programming interface, but that project is on
> hold until I finish my PhD.
>
> Is there a good place on the wiki for sharing scripts? When I get this
> GMT thing polished up I think it will be quite useful for folks who
> use GMT.
>
> David
>
>
> On 7/15/05, Stephan Holl <holl@gdf-hannover.de> wrote:
>> Hello David,
>>
>> On Fri, 15 Jul 2005 16:27:18 -0700 David Finlayson
>> <david.p.finlayson@gmail.com> wrote:
>>
>>> I've been working on a script to convert GRASS rasters directly into
>>> GMT plots in a single command. So far it converts the raster to GMT
>>> format, copies over the colormap and builds a simple graticule and
>>> scale bar. Works well.
>>>
>>> In the process of building this script, however, I discovered there
>>> is
>>> some great synergy possible between IPython (the interactive python
>>> shell) and GRASS. Here is how it works:
>>>
>>> 1) Launch ipython from within your grass shell
>>> 2) import a simple class designed to work with rasters
>>> 3) BINGO! you've got full control of command line grass + full
>>> interactive Python abilities.
>>>
>>> The class I wrote for grass rasters contains a bunch of instance
>>> variables that hold basic info about the raster (resolution, bounding
>>> box, etc.) and some methods to ease interaction with Python, like a
>>> get_value(X, Y) method.
>>
>> Would you like to share the python class which you wrote for
>> raster-maps?
>> It would be nice having the class in CVS to make it possible for
>> others
>> too?
>>
>> Thanks for your comment
>>
>> Stephan
>>
>> --
>> ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::
>>
>> GDF Hannover - Solutions for spatial data analysis and remote sensing
>> Hannover Office - Mengendamm 16d - D-30177 Hannover
>> Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
>> Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508
>>
>
>
> --
> David Finlayson
> Marine Geology & Geophysics
> School of Oceanography
> Box 357940
> University of Washington
> Seattle, WA 98195-7940
> USA
>
> Office: Marine Sciences Building, Room 112
> Phone: (206) 616-9407
> Web: http://students.washington.edu/dfinlays
>
>
>

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

David,

As I alluded to last message, here is the link to the BASH GRASS--GMT framework that I have put together to help with my map making:

http://169.237.35.250/~dylan/grass_user_group/

with a sample map :

http://169.237.35.250/~dylan/grass_user_group/map1.html

...however I am looking forward to checking out your python code... BASH is a little crufty..

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

On Jul 17, 2005, at 2:17 PM, David Finlayson wrote:

I have posted my GRASS -> GMT script on my web site (r.out.gmt.py):

http://students.washington.edu/dfinlays/scripts/

If anyone finds this useful, please send me suggestions. I will keep
working on it until it isn't such a hack.

Currently, it converts a raster, its colormap and optionally an
intensity raster (such as shaded relief) to GMT format. It then builds
a skeleton GMT plotting file that includes the raster (optionally
shaded with the intensity grid), a graticule and map decorations with
all of the tedious scale calculations already performed.

You need to edit the results to get it to look right, but the time
savings (for me) is probably close to an hour a plot over doing the
same steps manually.

David

On 7/16/05, Dylan Beaudette <dylan@iici.no-ip.org> wrote:

David,

I am extremely interested in any possible ways to streamline the
GRASS-GMT workflow.

I have started documenting a BASH shell version of the process, but a
python interface might be able to provide a tremendous amount of
flexibility compared to BASH.

The website where this is documented is currently down (power outage
while I was out in the field...), but I will try and have it back up in
a couple hours. Please let me know about any future plans with this--

Cheers,

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

On Jul 15, 2005, at 10:39 PM, David Finlayson wrote:

I'd be happy to share it, but frankly it's pretty crude. I'd be
embarrassed to foist this off as a good example of either Grass or
Python (though maybe it is a good example of how flexible this
combination is, even for light-weight programmers). The class simply
wraps an interface around a few standard GRASS commands and captures
the results (r.region for example). My dream is to write a real Python
interface to the Grass programming interface, but that project is on
hold until I finish my PhD.

Is there a good place on the wiki for sharing scripts? When I get this
GMT thing polished up I think it will be quite useful for folks who
use GMT.

David

On 7/15/05, Stephan Holl <holl@gdf-hannover.de> wrote:

Hello David,

On Fri, 15 Jul 2005 16:27:18 -0700 David Finlayson
<david.p.finlayson@gmail.com> wrote:

I've been working on a script to convert GRASS rasters directly into
GMT plots in a single command. So far it converts the raster to GMT
format, copies over the colormap and builds a simple graticule and
scale bar. Works well.

In the process of building this script, however, I discovered there
is
some great synergy possible between IPython (the interactive python
shell) and GRASS. Here is how it works:

1) Launch ipython from within your grass shell
2) import a simple class designed to work with rasters
3) BINGO! you've got full control of command line grass + full
interactive Python abilities.

The class I wrote for grass rasters contains a bunch of instance
variables that hold basic info about the raster (resolution, bounding
box, etc.) and some methods to ease interaction with Python, like a
get_value(X, Y) method.

Would you like to share the python class which you wrote for
raster-maps?
It would be nice having the class in CVS to make it possible for
others
too?

Thanks for your comment

        Stephan

--
       ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::

GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

Nice web site. You've obviously thought about this for a while now.

Maybe we can work on this together to get it polished up for general
consumption?

David

On 7/17/05, Dylan Beaudette <dylan@iici.no-ip.org> wrote:

David,

As I alluded to last message, here is the link to the BASH GRASS--GMT
framework that I have put together to help with my map making:

http://169.237.35.250/~dylan/grass_user_group/

with a sample map :

http://169.237.35.250/~dylan/grass_user_group/map1.html

...however I am looking forward to checking out your python code...
BASH is a little crufty..

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

On Jul 17, 2005, at 2:17 PM, David Finlayson wrote:

> I have posted my GRASS -> GMT script on my web site (r.out.gmt.py):
>
> http://students.washington.edu/dfinlays/scripts/
>
> If anyone finds this useful, please send me suggestions. I will keep
> working on it until it isn't such a hack.
>
> Currently, it converts a raster, its colormap and optionally an
> intensity raster (such as shaded relief) to GMT format. It then builds
> a skeleton GMT plotting file that includes the raster (optionally
> shaded with the intensity grid), a graticule and map decorations with
> all of the tedious scale calculations already performed.
>
> You need to edit the results to get it to look right, but the time
> savings (for me) is probably close to an hour a plot over doing the
> same steps manually.
>
> David
>
>
>
>
> On 7/16/05, Dylan Beaudette <dylan@iici.no-ip.org> wrote:
>> David,
>>
>> I am extremely interested in any possible ways to streamline the
>> GRASS-GMT workflow.
>>
>> I have started documenting a BASH shell version of the process, but a
>> python interface might be able to provide a tremendous amount of
>> flexibility compared to BASH.
>>
>> The website where this is documented is currently down (power outage
>> while I was out in the field...), but I will try and have it back up
>> in
>> a couple hours. Please let me know about any future plans with this--
>>
>> Cheers,
>>
>> --
>> Dylan Beaudette
>> Soils and Biogeochemistry Graduate Group
>> University of California at Davis
>> 530.754.7341
>>
>>
>>
>> On Jul 15, 2005, at 10:39 PM, David Finlayson wrote:
>>
>>> I'd be happy to share it, but frankly it's pretty crude. I'd be
>>> embarrassed to foist this off as a good example of either Grass or
>>> Python (though maybe it is a good example of how flexible this
>>> combination is, even for light-weight programmers). The class simply
>>> wraps an interface around a few standard GRASS commands and captures
>>> the results (r.region for example). My dream is to write a real
>>> Python
>>> interface to the Grass programming interface, but that project is on
>>> hold until I finish my PhD.
>>>
>>> Is there a good place on the wiki for sharing scripts? When I get
>>> this
>>> GMT thing polished up I think it will be quite useful for folks who
>>> use GMT.
>>>
>>> David
>>>
>>>
>>> On 7/15/05, Stephan Holl <holl@gdf-hannover.de> wrote:
>>>> Hello David,
>>>>
>>>> On Fri, 15 Jul 2005 16:27:18 -0700 David Finlayson
>>>> <david.p.finlayson@gmail.com> wrote:
>>>>
>>>>> I've been working on a script to convert GRASS rasters directly
>>>>> into
>>>>> GMT plots in a single command. So far it converts the raster to GMT
>>>>> format, copies over the colormap and builds a simple graticule and
>>>>> scale bar. Works well.
>>>>>
>>>>> In the process of building this script, however, I discovered there
>>>>> is
>>>>> some great synergy possible between IPython (the interactive python
>>>>> shell) and GRASS. Here is how it works:
>>>>>
>>>>> 1) Launch ipython from within your grass shell
>>>>> 2) import a simple class designed to work with rasters
>>>>> 3) BINGO! you've got full control of command line grass + full
>>>>> interactive Python abilities.
>>>>>
>>>>> The class I wrote for grass rasters contains a bunch of instance
>>>>> variables that hold basic info about the raster (resolution,
>>>>> bounding
>>>>> box, etc.) and some methods to ease interaction with Python, like a
>>>>> get_value(X, Y) method.
>>>>
>>>> Would you like to share the python class which you wrote for
>>>> raster-maps?
>>>> It would be nice having the class in CVS to make it possible for
>>>> others
>>>> too?
>>>>
>>>> Thanks for your comment
>>>>
>>>> Stephan
>>>>
>>>> --
>>>> ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::
>>>>
>>>> GDF Hannover - Solutions for spatial data analysis and remote
>>>> sensing
>>>> Hannover Office - Mengendamm 16d - D-30177
>>>> Hannover
>>>> Internet: www.gdf-hannover.de - Email:
>>>> holl@gdf-hannover.de
>>>> Phone : ++49-(0)511.39088507 - Fax:
>>>> ++49-(0)511.39088508
>>>>
>>>
>>>
>>> --
>>> David Finlayson
>>> Marine Geology & Geophysics
>>> School of Oceanography
>>> Box 357940
>>> University of Washington
>>> Seattle, WA 98195-7940
>>> USA
>>>
>>> Office: Marine Sciences Building, Room 112
>>> Phone: (206) 616-9407
>>> Web: http://students.washington.edu/dfinlays
>>>
>>>
>>>
>>
>>
>
>
> --
> David Finlayson
> Marine Geology & Geophysics
> School of Oceanography
> Box 357940
> University of Washington
> Seattle, WA 98195-7940
> USA
>
> Office: Marine Sciences Building, Room 112
> Phone: (206) 616-9407
> Web: http://students.washington.edu/dfinlays
>
>

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

Hello David, Dylan

On Sun, 17 Jul 2005 14:17:10 -0700 David Finlayson
<david.p.finlayson@gmail.com> wrote:

I have posted my GRASS -> GMT script on my web site (r.out.gmt.py):

http://students.washington.edu/dfinlays/scripts/

If anyone finds this useful, please send me suggestions. I will keep
working on it until it isn't such a hack.

Cool! Thanks for sharing it.

If you think it has a useful state, I would like to see it in the
WIKI-Add-on-section at

http://grass.gdf-hannover.de/twiki/bin/view/GRASS/GrassAddOns

[...]

best

  Stephan

--
       ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::

GDF Hannover - Solutions for spatial data analysis and remote sensing
Hannover Office - Mengendamm 16d - D-30177 Hannover
Internet: www.gdf-hannover.de - Email: holl@gdf-hannover.de
Phone : ++49-(0)511.39088507 - Fax: ++49-(0)511.39088508

Is there a good place on the wiki for sharing scripts? When I get this
GMT thing polished up I think it will be quite useful for folks who
use GMT.

The AddOns page:

http://grass.gdf-hannover.de/twiki/bin/view/GRASS/GrassAddOns

Please add copyright and license information so that others may know how
they can use your script. If your website will one day disappear, it
would be nice to upload the script to the Wiki at some point ("Attach
file") instead of just adding a link. We can't rely on the Wayback
Machine's ablility to survive future lawsuits.

Hamish

ps - Stephan: I again get a read error when I try to edit that wiki page.
?

I am wondering if it makes more sense to break up the program into
separate scripts?

1) Convert the color table from grass to gmt (g.out.colortable format=gmt)
2) Converting the raster (r.out.gmt)
3) Suggest output for -R and -J (maybe keep this in GMT land)

I just don't like the spaghetti code I was writing.

David

On 7/18/05, Dylan Beaudette <debeaudette@ucdavis.edu> wrote:

David,

Thanks for the reply. The lack of good hard copy output from GRASS has
driven me to do some hackish things in order to get GMT to produce my
maps.... I would be more than happy to collaborate on getting a working
GRASS-GMT framework (python seems like the best glue language as you
have demonstrated!) . I am excited about trying your script, as it
solves the color pallette problem that I had been facing for a while. I
am also working on a v.out.gmt script to convert GRASS vector data and
attributes into GMT format. Currently the only way to get GRASS vector
data into GMT is to convert to shapefile, and then convert the geometry
to GMT format.

Cheers!

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

On Jul 17, 2005, at 10:19 PM, David Finlayson wrote:

> Nice web site. You've obviously thought about this for a while now.
>
> Maybe we can work on this together to get it polished up for general
> consumption?
>
> David
>
>
> On 7/17/05, Dylan Beaudette <dylan@iici.no-ip.org> wrote:
>> David,
>>
>> As I alluded to last message, here is the link to the BASH GRASS--GMT
>> framework that I have put together to help with my map making:
>>
>> http://169.237.35.250/~dylan/grass_user_group/
>>
>> with a sample map :
>>
>> http://169.237.35.250/~dylan/grass_user_group/map1.html
>>
>> ...however I am looking forward to checking out your python code...
>> BASH is a little crufty..
>>
>> --
>> Dylan Beaudette
>> Soils and Biogeochemistry Graduate Group
>> University of California at Davis
>> 530.754.7341
>>
>>
>>
>> On Jul 17, 2005, at 2:17 PM, David Finlayson wrote:
>>
>>> I have posted my GRASS -> GMT script on my web site (r.out.gmt.py):
>>>
>>> http://students.washington.edu/dfinlays/scripts/
>>>
>>> If anyone finds this useful, please send me suggestions. I will keep
>>> working on it until it isn't such a hack.
>>>
>>> Currently, it converts a raster, its colormap and optionally an
>>> intensity raster (such as shaded relief) to GMT format. It then
>>> builds
>>> a skeleton GMT plotting file that includes the raster (optionally
>>> shaded with the intensity grid), a graticule and map decorations with
>>> all of the tedious scale calculations already performed.
>>>
>>> You need to edit the results to get it to look right, but the time
>>> savings (for me) is probably close to an hour a plot over doing the
>>> same steps manually.
>>>
>>> David
>>>
>>>
>>>
>>>
>>> On 7/16/05, Dylan Beaudette <dylan@iici.no-ip.org> wrote:
>>>> David,
>>>>
>>>> I am extremely interested in any possible ways to streamline the
>>>> GRASS-GMT workflow.
>>>>
>>>> I have started documenting a BASH shell version of the process, but
>>>> a
>>>> python interface might be able to provide a tremendous amount of
>>>> flexibility compared to BASH.
>>>>
>>>> The website where this is documented is currently down (power outage
>>>> while I was out in the field...), but I will try and have it back up
>>>> in
>>>> a couple hours. Please let me know about any future plans with
>>>> this--
>>>>
>>>> Cheers,
>>>>
>>>> --
>>>> Dylan Beaudette
>>>> Soils and Biogeochemistry Graduate Group
>>>> University of California at Davis
>>>> 530.754.7341
>>>>
>>>>
>>>>
>>>> On Jul 15, 2005, at 10:39 PM, David Finlayson wrote:
>>>>
>>>>> I'd be happy to share it, but frankly it's pretty crude. I'd be
>>>>> embarrassed to foist this off as a good example of either Grass or
>>>>> Python (though maybe it is a good example of how flexible this
>>>>> combination is, even for light-weight programmers). The class
>>>>> simply
>>>>> wraps an interface around a few standard GRASS commands and
>>>>> captures
>>>>> the results (r.region for example). My dream is to write a real
>>>>> Python
>>>>> interface to the Grass programming interface, but that project is
>>>>> on
>>>>> hold until I finish my PhD.
>>>>>
>>>>> Is there a good place on the wiki for sharing scripts? When I get
>>>>> this
>>>>> GMT thing polished up I think it will be quite useful for folks who
>>>>> use GMT.
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>> On 7/15/05, Stephan Holl <holl@gdf-hannover.de> wrote:
>>>>>> Hello David,
>>>>>>
>>>>>> On Fri, 15 Jul 2005 16:27:18 -0700 David Finlayson
>>>>>> <david.p.finlayson@gmail.com> wrote:
>>>>>>
>>>>>>> I've been working on a script to convert GRASS rasters directly
>>>>>>> into
>>>>>>> GMT plots in a single command. So far it converts the raster to
>>>>>>> GMT
>>>>>>> format, copies over the colormap and builds a simple graticule
>>>>>>> and
>>>>>>> scale bar. Works well.
>>>>>>>
>>>>>>> In the process of building this script, however, I discovered
>>>>>>> there
>>>>>>> is
>>>>>>> some great synergy possible between IPython (the interactive
>>>>>>> python
>>>>>>> shell) and GRASS. Here is how it works:
>>>>>>>
>>>>>>> 1) Launch ipython from within your grass shell
>>>>>>> 2) import a simple class designed to work with rasters
>>>>>>> 3) BINGO! you've got full control of command line grass + full
>>>>>>> interactive Python abilities.
>>>>>>>
>>>>>>> The class I wrote for grass rasters contains a bunch of instance
>>>>>>> variables that hold basic info about the raster (resolution,
>>>>>>> bounding
>>>>>>> box, etc.) and some methods to ease interaction with Python,
>>>>>>> like a
>>>>>>> get_value(X, Y) method.
>>>>>>
>>>>>> Would you like to share the python class which you wrote for
>>>>>> raster-maps?
>>>>>> It would be nice having the class in CVS to make it possible for
>>>>>> others
>>>>>> too?
>>>>>>
>>>>>> Thanks for your comment
>>>>>>
>>>>>> Stephan
>>>>>>
>>>>>> --
>>>>>> ::ACHTUNG:: Neue Adresse und Telefonnummer ::ACHTUNG::
>>>>>>
>>>>>> GDF Hannover - Solutions for spatial data analysis and remote
>>>>>> sensing
>>>>>> Hannover Office - Mengendamm 16d - D-30177
>>>>>> Hannover
>>>>>> Internet: www.gdf-hannover.de - Email:
>>>>>> holl@gdf-hannover.de
>>>>>> Phone : ++49-(0)511.39088507 - Fax:
>>>>>> ++49-(0)511.39088508
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> David Finlayson
>>>>> Marine Geology & Geophysics
>>>>> School of Oceanography
>>>>> Box 357940
>>>>> University of Washington
>>>>> Seattle, WA 98195-7940
>>>>> USA
>>>>>
>>>>> Office: Marine Sciences Building, Room 112
>>>>> Phone: (206) 616-9407
>>>>> Web: http://students.washington.edu/dfinlays
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> David Finlayson
>>> Marine Geology & Geophysics
>>> School of Oceanography
>>> Box 357940
>>> University of Washington
>>> Seattle, WA 98195-7940
>>> USA
>>>
>>> Office: Marine Sciences Building, Room 112
>>> Phone: (206) 616-9407
>>> Web: http://students.washington.edu/dfinlays
>>>
>>>
>>
>>
>
>
> --
> David Finlayson
> Marine Geology & Geophysics
> School of Oceanography
> Box 357940
> University of Washington
> Seattle, WA 98195-7940
> USA
>
> Office: Marine Sciences Building, Room 112
> Phone: (206) 616-9407
> Web: http://students.washington.edu/dfinlays
>
>

--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA 98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays

On Mon, 18 Jul 2005, David Finlayson wrote:

I am wondering if it makes more sense to break up the program into
separate scripts?

1) Convert the color table from grass to gmt (g.out.colortable format=gmt)
2) Converting the raster (r.out.gmt)
3) Suggest output for -R and -J (maybe keep this in GMT land)

(Background)

I have a written a shell script which I use to generate a GMT version of a
QGIS project. I can create a view of various PostGIS layers in QGIS, set
line/polygon/point colors and polygon fills. The script parses a QGIS
project file, identifies the map extent & PostGIS layers, extracts the
relevant features, converts to GMT vector format & writes a script to plot
the files using the QGIS region & colors.... Pretty basic, lots of things
it doesn't do, but the resulting GMT files & script make generating a GMT
plot from an on screen view very easy. (The Postgis to GMT conversion is
via a perl script someone else (with much better programming skills)
wrote)

(comments)

I think a modular, generalised approach will offer more to users than a
monolithic approach, so the idea of several specific functions to export
raster & vector data for GMT is great.

Is there any way such capability could be added to gdal/ogr instead of
being GRASS specific? I know GDAL has some GMT support now, so
things like geotiff <-> gridfile can be done, but color pallete
support within GDAL would be tidier. Also adding GMT vector format
to ogr would be a much more versatile approach than a GRASS specific
function, and would also work with GRASS as well.

I just don't like the spaghetti code I was writing.

I'm more a fan of functionality than elegance, so I'll happily leech off
any contributions in this area :slight_smile:

On 7/18/05, Dylan Beaudette <debeaudette@ucdavis.edu> wrote:
> David,
>
> Thanks for the reply. The lack of good hard copy output from GRASS has
> driven me to do some hackish things in order to get GMT to produce my
> maps.... I would be more than happy to collaborate on getting a working
> GRASS-GMT framework (python seems like the best glue language as you
> have demonstrated!) . I am excited about trying your script, as it
> solves the color pallette problem that I had been facing for a while. I
> am also working on a v.out.gmt script to convert GRASS vector data and
> attributes into GMT format. Currently the only way to get GRASS vector
> data into GMT is to convert to shapefile, and then convert the geometry
> to GMT format.

Are you interested in a copy of the PostGIS -> GMT perl script I mentioned
above? It's small enough to post, but isn't strictly a GRASS function. I'm
also interested in how you turn shapefiles into GMT (and vice versa). My C
coding isn't up to much more than spelling the name of the language, so I
haven't done much with shapelib, or Ben's gmt version that I never got
working properly... (but I guess these are more GMT list questions than
GRASS...)

Anyway, I'm very interested in these capabilities, and also the ability to
invoke GMT to plot data from R. I believe the PostGIS/QGIS/GRASS/GMT/R
suite could be the most powerful analytical GIS suite available, so any
work to enhance the interoperability of these packages is fantastic!

Thanks,

  Brent Wood