浏览代码

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) (merge from devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@37469 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 16 年之前
父节点
当前提交
46e6e3fc87
共有 2 个文件被更改,包括 61 次插入9 次删除
  1. 26 1
      raster/r.in.gdal/main.c
  2. 35 8
      raster/r.in.gdal/r.in.gdal.html

+ 26 - 1
raster/r.in.gdal/main.c

@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
     {
     {
 	struct Option *input, *output, *target, *title, *outloc, *band;
 	struct Option *input, *output, *target, *title, *outloc, *band;
     } parm;
     } parm;
-    struct Flag *flag_o, *flag_e, *flag_k, *flag_f;
+    struct Flag *flag_o, *flag_e, *flag_k, *flag_f, *flag_l;
 
 
     /* -------------------------------------------------------------------- */
     /* -------------------------------------------------------------------- */
     /*      Initialize.                                                     */
     /*      Initialize.                                                     */
@@ -134,6 +134,11 @@ int main(int argc, char *argv[])
     flag_f->description = _("List supported formats and exit");
     flag_f->description = _("List supported formats and exit");
     flag_f->guisection = _("Print");
     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 = G_define_flag();
     flag_k->key = 'k';
     flag_k->key = 'k';
     flag_k->description =
     flag_k->description =
@@ -161,6 +166,8 @@ int main(int argc, char *argv[])
 	G_fatal_error(_("You have to specify a target location different from output location"));
 	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.                                            */
     /*      Fire up the engines.                                            */
@@ -195,6 +202,7 @@ int main(int argc, char *argv[])
 	exit(EXIT_SUCCESS);
 	exit(EXIT_SUCCESS);
     }
     }
 
 
+
     if (!input)
     if (!input)
 	G_fatal_error(_("Required parameter <%s> not set"), parm.input->key);
 	G_fatal_error(_("Required parameter <%s> not set"), parm.input->key);
 
 
@@ -270,6 +278,23 @@ int main(int argc, char *argv[])
 	cellhd.depths = 1;
 	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.                             */
     /*      Fetch the projection in GRASS form.                             */
     /* -------------------------------------------------------------------- */
     /* -------------------------------------------------------------------- */

+ 35 - 8
raster/r.in.gdal/r.in.gdal.html

@@ -89,7 +89,6 @@ match current location</tt>) and then report the PROJ_INFO parameters of
 the source dataset.
 the source dataset.
 
 
 <p>
 <p>
-
 If the user wishes to ignore the difference between the apparent coordinate
 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 
 system of the source data and the current location, they may pass the 
 <b>-o</b> flag to override the projection check. 
 <b>-o</b> flag to override the projection check. 
@@ -105,7 +104,6 @@ created (with only a PERMANENT mapset), and the raster will have been
 imported with the indicated <b>output</b> name into the PERMANENT mapset.
 imported with the indicated <b>output</b> name into the PERMANENT mapset.
 
 
 <p>
 <p>
-
 Support for GCPs: In case the image contains GCPs they are written to a
 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 
 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
 <a href=i.rectify.html>i.rectify</a>. The <b>target</b> option allows to
@@ -119,7 +117,6 @@ Planned improvements to <em>r.in.gdal</em> in the future include support for
 reporting everything known about a dataset if the <b>output</b> parameter is not set.
 reporting everything known about a dataset if the <b>output</b> parameter is not set.
 
 
 <p>
 <p>
-
 The <em>r.in.gdal</em> comand does support the following features, as long as 
 The <em>r.in.gdal</em> comand does support the following features, as long as 
 the underlying format driver supports it:
 the underlying format driver supports it:
 
 
@@ -190,9 +187,34 @@ gdalwarp rotated.tif northup.tif
 <i>"ERROR: Projection of dataset does not appear to match the current location."</i><br>
 <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
 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&deg; 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>
 <h2>EXAMPLES</h2>
 
 
@@ -240,6 +262,7 @@ r.in.gdal HDF4_EOS:EOS_GRID:"MOD15A2.A2003153.h18v04.004.2003171141042.hdf":MOD_
 # ... likewise for other HDF bands in the file.
 # ... likewise for other HDF bands in the file.
 </pre></div>
 </pre></div>
 
 
+
 <h2>SEE ALSO</h2>
 <h2>SEE ALSO</h2>
 <em>
 <em>
 <a href="r.colors.html">r.colors</a>,
 <a href="r.colors.html">r.colors</a>,
@@ -249,12 +272,16 @@ r.in.gdal HDF4_EOS:EOS_GRID:"MOD15A2.A2003153.h18v04.004.2003171141042.hdf":MOD_
 <a href="r.null.html">r.null</a>
 <a href="r.null.html">r.null</a>
 </em>
 </em>
 
 
+
 <h2>REFERENCES</h2>
 <h2>REFERENCES</h2>
 
 
 GDAL Pages: <a href="http://www.gdal.org">http://www.gdal.org/</a><br>
 GDAL Pages: <a href="http://www.gdal.org">http://www.gdal.org/</a><br>
 
 
+
 <h2>AUTHOR</h2>
 <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>