[GRASS-SVN] r43571 -
grass/branches/releasebranch_6_4/raster/r.in.gdal
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Sep 21 08:19:28 EDT 2010
Author: neteler
Date: 2010-09-21 12:19:28 +0000 (Tue, 21 Sep 2010)
New Revision: 43571
Modified:
grass/branches/releasebranch_6_4/raster/r.in.gdal/description.html
grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c
Log:
backport: 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/releasebranch_6_4/raster/r.in.gdal/description.html
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.in.gdal/description.html 2010-09-21 12:01:44 UTC (rev 43570)
+++ grass/branches/releasebranch_6_4/raster/r.in.gdal/description.html 2010-09-21 12:19:28 UTC (rev 43571)
@@ -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 @@
the size of the input file.
<p>
-
The <em>r.in.gdal</em> command does support the following features, as long as
the underlying format driver supports it:
@@ -193,10 +190,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>
@@ -258,6 +280,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/releasebranch_6_4/raster/r.in.gdal/main.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c 2010-09-21 12:01:44 UTC (rev 43570)
+++ grass/branches/releasebranch_6_4/raster/r.in.gdal/main.c 2010-09-21 12:19:28 UTC (rev 43571)
@@ -68,7 +68,7 @@
{
struct Option *input, *output, *target, *title, *outloc, *band, *memory;
} parm;
- struct Flag *flag_o, *flag_e, *flag_k, *flag_f;
+ struct Flag *flag_o, *flag_e, *flag_k, *flag_f, *flag_l;
/* -------------------------------------------------------------------- */
/* Initialize. */
@@ -140,6 +140,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 =
@@ -167,6 +172,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. */
@@ -203,13 +210,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);
@@ -284,6 +290,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