فهرست منبع

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;
     } 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 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
 	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,6 +202,7 @@ int main(int argc, char *argv[])
 	exit(EXIT_SUCCESS);
     }
 
+
     if (!input)
 	G_fatal_error(_("Required parameter <%s> not set"), parm.input->key);
 
@@ -270,6 +278,23 @@ int main(int argc, char *argv[])
 	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.                             */
     /* -------------------------------------------------------------------- */

+ 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.
 
 <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 @@ created (with only a PERMANENT mapset), and the raster will have been
 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 @@ 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.
 
 <p>
-
 The <em>r.in.gdal</em> comand does support the following features, as long as 
 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>
 
 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>
 
@@ -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.
 </pre></div>
 
+
 <h2>SEE ALSO</h2>
 <em>
 <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>
 </em>
 
+
 <h2>REFERENCES</h2>
 
 GDAL Pages: <a href="http://www.gdal.org">http://www.gdal.org/</a><br>
 
+
 <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>