[GRASS-SVN] r37468 - grass/branches/develbranch_6/raster/r.in.gdal
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 25 10:09:51 EDT 2009
Author: hamish
Date: 2009-05-25 10:09:51 -0400 (Mon, 25 May 2009)
New Revision: 37468
Modified:
grass/branches/develbranch_6/raster/r.in.gdal/description.html
grass/branches/develbranch_6/raster/r.in.gdal/main.c
Log:
add flag so that you can force the import of lat/lon imagery which is missing georef, at the cost of preserving map bounds (which were presumably bogus to begin with, so no great loss)
Modified: grass/branches/develbranch_6/raster/r.in.gdal/description.html
===================================================================
--- grass/branches/develbranch_6/raster/r.in.gdal/description.html 2009-05-25 12:42:33 UTC (rev 37467)
+++ grass/branches/develbranch_6/raster/r.in.gdal/description.html 2009-05-25 14:09:51 UTC (rev 37468)
@@ -89,7 +89,6 @@
the source dataset.
<p>
-
If the user wishes to ignore the difference between the apparent coordinate
system of the source data and the current location, they may pass the
<b>-o</b> flag to override the projection check.
@@ -105,7 +104,6 @@
imported with the indicated <b>output</b> name into the PERMANENT mapset.
<p>
-
Support for GCPs: In case the image contains GCPs they are written to a
POINTS file within an imagery group. They can directly be used for
<a href=i.rectify.html>i.rectify</a>. The <b>target</b> option allows to
@@ -119,7 +117,6 @@
reporting everything known about a dataset if the <b>output</b> parameter is not set.
<p>
-
The <em>r.in.gdal</em> comand does support the following features, as long as
the underlying format driver supports it:
@@ -190,10 +187,35 @@
<i>"ERROR: Projection of dataset does not appear to match the current location."</i><br>
You need to create a location whose projection matches the data you
-wish to import. Try using <b>location</b> parameter to create a new location based
-upon the projection information in the file. If desired, you can then re-project
-it to another location with <em>r.proj</em>.
+wish to import. Try using <b>location</b> parameter to create a new
+location based upon the projection information in the file. If desired,
+you can then re-project it to another location with <em>r.proj</em>.
+Alternatively you can override this error by using the <b>-o</b> flag.
+<p>
+<i>"WARNING: G_set_window(): Illegal latitude for North"</i><br>
+
+Latitude/Longitude locations in GRASS can not have regions which exceed
+90° North or South. Non-georeferenced imagery will have coordinates
+based on the images's number of pixels: 0,0 in the bottom left; cols,rows
+in the top right. Typically imagery will be much more than 90 pixels tall
+and so the GIS refuses to import it. If you are sure that the data is
+appropriate for your Lat/Lon location and intentd to reset the map's
+bounds with the <em>r.region</em> module directly after import you may
+use the <b>-l</b> flag to constrain the map coordinates to legal values.
+
+While the resulting bounds and resolution will likely be wrong for your
+map the map's data will be unaltered and safe. After resetting to known
+bounds with <em>r.region</em> you should double check them with
+<em>r.info</em>, paying special attention to the map resolution. In most
+cases you will want to import into the datafile's native projection, or
+into a simple XY location and use the Georectifaction tools
+(<em>i.rectify</em> et al.) to properly project into the target location.
+The <b>-l</b> flag should <i>only</i> be used if you know the projection
+is correct but the internal georeferencing has gotten lost, and you know
+the what the map's bounds and resolution should be beforehand.
+
+
<h2>EXAMPLES</h2>
<h3>GTOPO30 DEM</h3>
@@ -255,6 +277,8 @@
<h2>AUTHOR</h2>
-<a href="http://home.gdal.org/warmerda/">Frank Warmerdam</a> (<a href="mailto:warmerdam AT pobox dot com">email</a>).
+<a href="http://home.gdal.org/warmerda/">Frank Warmerdam</a>
+ (<a href="mailto:warmerdam AT pobox dot com">email</a>).
-<p><i>Last changed: $Date$</i>I
+<p>
+<i>Last changed: $Date$</i>
Modified: grass/branches/develbranch_6/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.in.gdal/main.c 2009-05-25 12:42:33 UTC (rev 37467)
+++ grass/branches/develbranch_6/raster/r.in.gdal/main.c 2009-05-25 14:09:51 UTC (rev 37468)
@@ -68,7 +68,7 @@
{
struct Option *input, *output, *target, *title, *outloc, *band;
} parm;
- struct Flag *flag_o, *flag_e, *flag_k, *flag_f;
+ struct Flag *flag_o, *flag_e, *flag_k, *flag_f, *flag_l;
/* -------------------------------------------------------------------- */
/* Initialize. */
@@ -134,6 +134,11 @@
flag_f->description = _("List supported formats and exit");
flag_f->guisection = _("Print");
+ flag_l = G_define_flag();
+ flag_l->key = 'l';
+ flag_l->description =
+ _("Force Lat/Lon maps to fit into geographic coordinates (90N,S; 180E,W)");
+
flag_k = G_define_flag();
flag_k->key = 'k';
flag_k->description =
@@ -161,6 +166,8 @@
G_fatal_error(_("You have to specify a target location different from output location"));
}
+ if (flag_l->answer && G_projection() != PROJECTION_LL)
+ G_fatal_error(_("The '-l' flag only works in Lat/Lon locations"));
/* -------------------------------------------------------------------- */
/* Fire up the engines. */
@@ -195,13 +202,12 @@
exit(EXIT_SUCCESS);
}
- if (!input) {
+
+ if (!input)
G_fatal_error(_("Required parameter <%s> not set"), parm.input->key);
- }
- if (!output) {
+ if (!output)
G_fatal_error(_("Name for output raster map not specified"));
- }
if (G_legal_filename(output) < 0)
G_fatal_error(_("<%s> is an illegal file name"), output);
@@ -276,6 +282,23 @@
cellhd.depths = 1;
}
+ /* constrain to geographic coords */
+ if (flag_l->answer && G_projection() == PROJECTION_LL) {
+ if (cellhd.north > 90.) cellhd.north = 90.;
+ if (cellhd.south < -90.) cellhd.south = -90.;
+ if (cellhd.east > 360.) cellhd.east = 180.;
+ if (cellhd.west < -180.) cellhd.west = -180.;
+ cellhd.ns_res = (cellhd.north - cellhd.south) / cellhd.rows;
+ cellhd.ew_res = (cellhd.east - cellhd.west) / cellhd.cols;
+ cellhd.ew_res3 = cellhd.ew_res;
+ cellhd.ns_res3 = cellhd.ns_res;
+
+ G_warning(_("Map bounds have been constrained to geographic "
+ "coordinates. You will almost certainly want to check "
+ "map bounds and resolution with r.info and reset them "
+ "with r.region before going any further."));
+ }
+
/* -------------------------------------------------------------------- */
/* Fetch the projection in GRASS form. */
/* -------------------------------------------------------------------- */
More information about the grass-commit
mailing list