[GRASS-user] ascii files to import

Greetings everyone,

I was just handed a 26,000 row by 100 column excel file which contains lat long coordinates of individual site locations. I need to project it onto a rater image (already in a grass utm location).

Two ideas come to mind... one is to read it into a grass lat long location with v.in.ascii and then reproject onto the utm location, the other is to read it into postgis and convert the lat long columns to meters, then import the postgis layer. Any suggestions as to advantages or disadvantages to either approach?

How do most of you handle these situations?

Best Regards,

Kirk

Kirk R. Wythers, Research Fellow
Dept. of Forest Resources
University of Minnesota
1530 Cleveland Ave N
Saint Paul, MN 55108
tel: 612.625.2261
email: kwythers@umn.edu

Kirk Wythers wrote:

Greetings everyone,

I was just handed a 26,000 row by 100 column excel file which contains
lat long coordinates of individual site locations. I need to project it
onto a rater image (already in a grass utm location).

Two ideas come to mind... one is to read it into a grass lat long
location with v.in.ascii and then reproject onto the utm location, the
other is to read it into postgis and convert the lat long columns to
meters, then import the postgis layer. Any suggestions as to advantages
or disadvantages to either approach?

FYI, you can also use cs2cs to reproject coordinates stored in a text
file directly. Look at GRASS m.proj for inspiration [1]. Then
v.in.ascii, v.to.rast.

[1]http://freegis.org/cgi-bin/viewcvs.cgi/grass6/scripts/m.proj/m.proj?rev=1.6&content-type=text/vnd.viewcvs-markup

Maciek

Kirk,

Your method #1 is straightforward and should go fast. Do you need all 100
columns?

A 3rd way is to make sure that the file has a column to serve as a
"category/cat" field (integer), save it as a dbf file from Excel and use
v.in.db to create the points. This has the advantage that you can name the
fields more easily. You would then need to reproject it into UTM.

I'd be a little nervous about trying to convert from latlon to UTM within a
database. GRASS has routines specially designed to do accurate reprojection.

Michael

On 7/30/07 1:59 PM, "Kirk Wythers" <kwythers@umn.edu> wrote:

Greetings everyone,

I was just handed a 26,000 row by 100 column excel file which
contains lat long coordinates of individual site locations. I need to
project it onto a rater image (already in a grass utm location).

Two ideas come to mind... one is to read it into a grass lat long
location with v.in.ascii and then reproject onto the utm location,
the other is to read it into postgis and convert the lat long columns
to meters, then import the postgis layer. Any suggestions as to
advantages or disadvantages to either approach?

How do most of you handle these situations?

Best Regards,

Kirk

Kirk R. Wythers, Research Fellow
Dept. of Forest Resources
University of Minnesota
1530 Cleveland Ave N
Saint Paul, MN 55108
tel: 612.625.2261
email: kwythers@umn.edu

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

On Jul 31, 2007, at 9:47 AM, Michael Barton wrote:

Kirk,

Your method #1 is straightforward and should go fast. Do you need all 100
columns?

Thanks Michael. Yes, I am afraid that I need all 100, if only because I am not sure that I won’t someday!

A 3rd way is to make sure that the file has a column to serve as a
“category/cat” field (integer), save it as a dbf file from Excel and use
v.in.db to create the points. This has the advantage that you can name the
fields more easily. You would then need to reproject it into UTM.

With this approach how would reproject to UTM? I assume you have read the dbf file into a lat lon location. Right? However, then I would need to move the data from the lat lon location to the UTM location.

I’d be a little nervous about trying to convert from latlon to UTM within a
database. GRASS has routines specially designed to do accurate reprojection.

This actually works pretty well using the PostGIS extensions on PostgrSQL (you can use db.connect to point grass to a pg database rather than the default dbf). There is a very useful tutorial written by Regina Obe´

http://www.bostongis.com/?content_name=postgis_tut03#30

Michael

On 7/30/07 1:59 PM, “Kirk Wythers” <kwythers@umn.edu> wrote:


Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

On Tue, Jul 31, 2007 at 10:34:11AM -0500, Kirk Wythers wrote:

   This actually works pretty well using the PostGIS extensions on PostgrSQL
   (you can use db.connect to point grass to a pg database rather than the
   default dbf). There is a very useful tutorial written by Regina Obe'
   [1]http://www.bostongis.com/?content_name=postgis_tut03#30

What about
- using db.connect to point grass to a pg database
- db.in.ogr

?

http://grass.itc.it/gdp/html_grass63/db.in.ogr.html
db.in.ogr imports attribute tables in various formats as supported by the OGR driver on the local system (DBF, CSV, PostgreSQL, SQLite, MySQL, ODBC, etc.).

Markus

Kirk,

On 7/31/07 8:34 AM, “Kirk Wythers” kwythers@umn.edu wrote:

On Jul 31, 2007, at 9:47 AM, Michael Barton wrote:

Kirk,

Your method #1 is straightforward and should go fast. Do you need all 100
columns?

Thanks Michael. Yes, I am afraid that I need all 100, if only because I am not sure that I won’t someday!

A 3rd way is to make sure that the file has a column to serve as a
“category/cat” field (integer), save it as a dbf file from Excel and use
v.in.db to create the points. This has the advantage that you can name the
fields more easily. You would then need to reproject it into UTM.

With this approach how would reproject to UTM? I assume you have read the dbf file into a lat lon location. Right? However, then I would need to move the data from the lat lon location to the UTM location.

Use v.proj. This would be the case with any GRASS method.

Start in latlon location, import points, switch to utm location (g.mapset or just exit and restart in utm location), reproject using v.proj.

I’d be a little nervous about trying to convert from latlon to UTM within a
database. GRASS has routines specially designed to do accurate reprojection.

This actually works pretty well using the PostGIS extensions on PostgrSQL (you can use db.connect to point grass to a pg database rather than the default dbf). There is a very useful tutorial written by Regina Obe´

http://www.bostongis.com/?content_name=postgis_tut03#30

I took a brief look at the tutorial. I may have missed it, but didn’t see anything about where you would set the datum, ellipsoid, and zone for the UTM projection you want. The tutorial only mentions WGS84. These settings can make a significant difference. e.g., here in Arizona, the difference between using NAD27 and NAD83 can be over 200m, and can put a point on the wrong side of a road or canyon. If you have set up your UTM location correctly, GRASS and v.proj will take this kind of important information into account when setting new point coordinates.

Michael


Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Kirk Wythers wrote:

With this approach how would reproject to UTM? I assume you have read
the dbf file into a lat lon location. Right? However, then I would
need to move the data from the lat lon location to the UTM location.

In order of increasing rawness:

v.proj, m.proj, cs2cs

Hamish