[GRASS-SVN] r33831 - in grass-addons/gipe: . i.latlong
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Oct 12 00:30:25 EDT 2008
Author: ychemin
Date: 2008-10-12 00:30:24 -0400 (Sun, 12 Oct 2008)
New Revision: 33831
Added:
grass-addons/gipe/i.latlong/
grass-addons/gipe/i.latlong/Makefile
grass-addons/gipe/i.latlong/i.latlong.html
grass-addons/gipe/i.latlong/main.c
Removed:
grass-addons/gipe/i.latitude/
grass-addons/gipe/i.longitude/
Modified:
grass-addons/gipe/Makefile.imagery
grass-addons/gipe/gmmenu.tcl
grass-addons/gipe/menudata.py
grass-addons/gipe/readme.gipe
Log:
Merged i.latitude/i.longitude into i.latlong
Modified: grass-addons/gipe/Makefile.imagery
===================================================================
--- grass-addons/gipe/Makefile.imagery 2008-10-12 01:17:36 UTC (rev 33830)
+++ grass-addons/gipe/Makefile.imagery 2008-10-12 04:30:24 UTC (rev 33831)
@@ -35,9 +35,8 @@
i.evapo.senay \
i.evapo.time_integration \
i.evapo.TSA \
- i.latitude \
+ i.latlong \
i.lmf \
- i.longitude \
i.modis.stateqa \
i.sattime \
i.sunhours \
Modified: grass-addons/gipe/gmmenu.tcl
===================================================================
--- grass-addons/gipe/gmmenu.tcl 2008-10-12 01:17:36 UTC (rev 33830)
+++ grass-addons/gipe/gmmenu.tcl 2008-10-12 04:30:24 UTC (rev 33831)
@@ -582,8 +582,7 @@
{command {[G_msg "Water"]} {} "i.water" {} -command {execute i.water }}
{command {[G_msg "Emissivity (generic from NDVI)"]} {} "i.emissivity" {} -command {execute i.emissivity }}
{separator}
- {command {[G_msg "Latitude map"]} {} "i.latitude" {} -command {execute i.latitude }}
- {command {[G_msg "Longitude map"]} {} "i.longitude" {} -command {execute i.longitude }}
+ {command {[G_msg "Lat/long maps"]} {} "i.latlong" {} -command {execute i.latlong }}
{command {[G_msg "Sunshine hours (potential)"]} {} "i.sunhours" {} -command {execute i.sunhours }}
{command {[G_msg "Satellite overpass time"]} {} "i.sattime" {} -command {execute i.sattime }}
{separator}
Added: grass-addons/gipe/i.latlong/Makefile
===================================================================
--- grass-addons/gipe/i.latlong/Makefile (rev 0)
+++ grass-addons/gipe/i.latlong/Makefile 2008-10-12 04:30:24 UTC (rev 33831)
@@ -0,0 +1,15 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.latlong
+
+LIBES = $(GPROJLIB) $(GISLIB)
+DEPENDENCIES = $(GPROJDEP) $(GISDEP)
+EXTRA_INC = $(PROJINC)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+ifneq ($(USE_LARGEFILES),)
+ EXTRA_CFLAGS = -D_FILE_OFFSET_BITS=64
+endif
+
+default: cmd
Added: grass-addons/gipe/i.latlong/i.latlong.html
===================================================================
--- grass-addons/gipe/i.latlong/i.latlong.html (rev 0)
+++ grass-addons/gipe/i.latlong/i.latlong.html 2008-10-12 04:30:24 UTC (rev 33831)
@@ -0,0 +1,26 @@
+<H2>DESCRIPTION</H2>
+
+<EM>i.latlong</EM> creates a latitude (degree decimal) map, or longitude if the -l flag is used, from any map in any projection using PROJ.4 library.
+This is an input to r.sun and i.evapo.potrad.
+<H2>NOTES</H2>
+
+The proj <A HREF="http://www.remotesensing.org/proj/">website</A>.
+
+<H2>TODO</H2>
+Datum corrected reprojection is not implemented.
+
+<H2>SEE ALSO</H2>
+
+<em>
+<A HREF="i.evapo.potrad.html">i.evapo.potrad</A><br>
+<A HREF="r.sun.html">r.sun</A><br>
+</em>
+
+
+<H2>AUTHORS</H2>
+
+Yann Chemin, International Rice Research Institute, The Philippines.<br>
+
+
+<p>
+<i>Last changed: $Date: 2008/10/12 12:25:55 $</i>
Added: grass-addons/gipe/i.latlong/main.c
===================================================================
--- grass-addons/gipe/i.latlong/main.c (rev 0)
+++ grass-addons/gipe/i.latlong/main.c 2008-10-12 04:30:24 UTC (rev 33831)
@@ -0,0 +1,174 @@
+
+/****************************************************************************
+ *
+ * MODULE: i.latlong
+ * AUTHOR(S): Yann Chemin - yann.chemin at gmail.com
+ * PURPOSE: Calculates the longitude of the pixels in the map.
+ *
+ * COPYRIGHT: (C) 2002-2008 by the GRASS Development Team
+ *
+ * This program is free software under the GNU General Public
+ * License (>=v2). Read the file COPYING that comes with GRASS
+ * for details.
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <grass/gis.h>
+#include <grass/gprojects.h>
+#include <grass/glocale.h>
+
+int main(int argc, char *argv[])
+{
+ struct Cell_head cellhd; /*region+header info */
+ char *mapset; /*mapset name */
+ int nrows, ncols;
+ int row, col;
+ int not_ll = 0; /*if proj is not lat/long, it will be 1. */
+ struct GModule *module;
+ struct Option *input1, *output1;
+ struct Flag *flag1;
+ struct History history; /*metadata */
+ struct pj_info iproj;
+ struct pj_info oproj;
+
+ /************************************/
+ char *name; /*input raster name */
+ char *result1; /*output raster name */
+
+ int infd;
+ int outfd1;
+ char *in;
+ int i = 0, j = 0;
+ double xp, yp;
+ double xmin, ymin;
+ double xmax, ymax;
+ double stepx, stepy;
+ double latitude, longitude;
+ void *inrast;
+ DCELL * outrast1;
+ RASTER_MAP_TYPE data_type_output = DCELL_TYPE;
+ RASTER_MAP_TYPE data_type_inrast;
+
+ /************************************/
+ G_gisinit(argv[0]);
+ module = G_define_module();
+ module->keywords = _("longitude, projection");
+ module->description = _("creates a longitude map");
+
+ /* Define the different options */
+ input1 = G_define_standard_option(G_OPT_R_INPUT);
+ input1->description = _("Name of the input map");
+
+ output1 = G_define_standard_option(G_OPT_R_OUTPUT);
+ output1->description = _("Name of the output longitude layer");
+
+ flag1 = G_define_flag();
+ flag1->key = 'l';
+ flag1->description = _("Loongitude output");
+
+ /********************/
+ if (G_parser(argc, argv))
+ exit(EXIT_FAILURE);
+
+ in = input1->answer;
+ result1 = output1->answer;
+
+ /***************************************************/
+ mapset = G_find_cell2(in, "");
+ if (mapset == NULL) {
+ G_fatal_error(_("cell file [%s] not found"), in);
+ }
+ data_type_inrast = G_raster_map_type(in, mapset);
+ if ((infd = G_open_cell_old(in, mapset)) < 0)
+ G_fatal_error(_("Cannot open cell file [%s]"), in);
+ if (G_get_cellhd(in, mapset, &cellhd) < 0)
+ G_fatal_error(_("Cannot read file header of [%s])"), in);
+ inrast = G_allocate_raster_buf(data_type_inrast);
+
+ /***************************************************/
+ stepx = cellhd.ew_res;
+ stepy = cellhd.ns_res;
+ xmin = cellhd.west;
+ xmax = cellhd.east;
+ ymin = cellhd.south;
+ ymax = cellhd.north;
+ nrows = G_window_rows();
+ ncols = G_window_cols();
+
+ /*Shamelessly stolen from r.sun !!!! */
+ /* Set up parameters for projection to lat/long if necessary */
+ if ((G_projection() != PROJECTION_LL))
+ {
+ not_ll = 1;
+ struct Key_Value *in_proj_info, *in_unit_info;
+
+ if ((in_proj_info = G_get_projinfo()) == NULL)
+ G_fatal_error(_("Can't get projection info of current location"));
+ if ((in_unit_info = G_get_projunits()) == NULL)
+ G_fatal_error(_("Can't get projection units of current location"));
+ if (pj_get_kv(&iproj, in_proj_info, in_unit_info) < 0)
+ G_fatal_error(_("Can't get projection key values of current location"));
+ G_free_key_value(in_proj_info);
+ G_free_key_value(in_unit_info);
+
+ /* Set output projection to latlong w/ same ellipsoid */
+ oproj.zone = 0;
+ oproj.meters = 1.;
+ sprintf(oproj.proj, "ll");
+ if ((oproj.pj = pj_latlong_from_proj(iproj.pj)) == NULL)
+ G_fatal_error(_("Unable to set up lat/long projection parameters"));
+ } /* End of stolen from r.sun :P */
+
+ outrast1 = G_allocate_raster_buf(data_type_output);
+
+ if ((outfd1 = G_open_raster_new(result1, data_type_output)) < 0)
+ G_fatal_error(_("Could not open <%s>"), result1);
+
+ for (row = 0; row < nrows; row++)
+ {
+ DCELL d;
+ DCELL d_lon;
+ DCELL d_lat;
+ G_percent(row, nrows, 2);
+
+ if (G_get_raster_row(infd, inrast, row, data_type_inrast) < 0)
+ G_fatal_error(_("Could not read from <%s>"), in);
+
+ for (col = 0; col < ncols; col++)
+ {
+ latitude = ymax - (row * stepy);
+ longitude = xmin + (col * stepx);
+ if (not_ll) {
+ if (pj_do_proj(&longitude, &latitude, &iproj, &oproj) < 0) {
+ G_fatal_error(_("Error in pj_do_proj"));
+ }
+ }
+ else {
+
+ /*Do nothing */
+ }
+ if(flag1->answer)
+ d = longitude;
+ else
+ d = latitude;
+ outrast1[col] = d;
+ }
+ if (G_put_raster_row(outfd1, outrast1, data_type_output) < 0)
+ G_fatal_error(_("Cannot write to output raster file"));
+ }
+ G_free(inrast);
+ G_close_cell(infd);
+ G_free(outrast1);
+ G_close_cell(outfd1);
+
+ G_short_history(result1, "raster", &history);
+ G_command_history(&history);
+ G_write_history(result1, &history);
+
+ exit(EXIT_SUCCESS);
+}
+
+
Modified: grass-addons/gipe/menudata.py
===================================================================
--- grass-addons/gipe/menudata.py 2008-10-12 01:17:36 UTC (rev 33830)
+++ grass-addons/gipe/menudata.py 2008-10-12 04:30:24 UTC (rev 33831)
@@ -1455,14 +1455,10 @@
"self.RunMenuCmd",
"i.emissivity"),
("","","", ""),
- (_("Latitude map"),
- _("Latitude map"),
+ (_("Lat/long maps"),
+ _("Lat/long maps"),
"self.RunMenuCmd",
- "i.latitude"),
- (_("Longitude map"),
- _("Longitude map"),
- "self.RunMenuCmd",
- "i.longitude"),
+ "i.latlong"),
(_("Sunshine hours (potential)"),
_("Sunshine hours (potential)"),
"self.RunMenuCmd",
Modified: grass-addons/gipe/readme.gipe
===================================================================
--- grass-addons/gipe/readme.gipe 2008-10-12 01:17:36 UTC (rev 33830)
+++ grass-addons/gipe/readme.gipe 2008-10-12 04:30:24 UTC (rev 33831)
@@ -17,6 +17,7 @@
20081010: Added i.modis.stateqa for cloud, fire, land/water and other interesting MODIS09A flags.
20081011: Moved r.uslek to main SVN
20081012: Moved r.usler to main SVN
+20081012: Added i.latlong, removed i.latitude and i.longitude
Imagery modules
---------------
@@ -71,8 +72,7 @@
-------------------------------------------------------------------------------------
-----Utilities-----------------------------------------------------------------------
-i.latitude: Calculates latitude by reprojecting without datum transform
-i.longitude: Calculates longitude by reprojecting without datum transform
+i.latlong: Calculates latitude/longitude by reprojecting without datum transform
**i.qc.modis: (Now in Main SVN as i.modis.qc) Converts Terra-MODIS Quality Assessment bits to numeric classes
i.sattime: Calculates the time of satellite overpass
i.sunhours: Calculates potential sunshine hours
More information about the grass-commit
mailing list