# Thread: Generate a grid of latitude values

1. ## Generate a grid of latitude values

I need to convert a 30m elevation grid to a grid that gives values for the cell latitude rather than elevation.

I tried converting the GRID to point, adding x,y data to the points, then converting back to GRID using the y-coordinate as the value, however, the large region I am working with is preventing the processes from completing successfully.

Any advice will certainly be appreciated.

Todd

2. ## Re: Generate a grid of latitude values

What is the area, or how large of an area is it?

3. ## Re: Generate a grid of latitude values

Is the grid in a geographic coordinate system?

If so, just set your output extent and cell size (ArcToolbox environment settings or Spatial Analyst toolbar options) to match your DEM then use \$\$YMAP built in scalar variable in a SOMA/MOMA tool or Raster Calculator expression:

E.g.
C:\workspace\latgrid = \$\$YMAP

Luke

PS: For info...

Built-in GRID scalar variables:
\$\$NROWS: the number of rows in the analysis window
\$\$NCOLS: the number of columns in the analysis window
\$\$CELLSIZE: the current cell size specified in the analysis environment
\$\$WX0: minimum x-map coordinate of the current analysis window
\$\$WY0: minimum y-map coordinate of the current analysis window
\$\$WX1: maximum x-map coordinate of the current analysis window
\$\$WY1: maximum y-map coordinate of the current analysis window
\$\$XMAP: x-map coordinate for the center of the processing cell
\$\$YMAP: y-map coordinate for the center of the processing cell

Built-in GRID constants.
PI: 3.142
E: 2.718 (e)
DEG: 57.296 (Degree to radian conversion)
GAMMA: 0.577
PHI: 1.618

Built-in grids.
\$\$ROWMAP
\$\$COLMAP

4. ## Re: Generate a grid of latitude values

Luke (or anyone else who can help),

I've read your post on this thread, and your thread on the old forums (http://forums.esri.com/Thread.asp?c=...=6#msgid538607), but I'm struggling to get the \$\$xmap scalar variable to work with the SOMA tool. It works in the Raster Calculator, but since I am trying to create a model, I need to use the SOMA tool. At the moment, I am trying

\$\$xmap = (D:\...\Base Data\dem3_4m)

in the "Map Algebra expression" box, and have tried variations including switching the order of variables, spaces and no spaces, no equal sign, etc. I still get an error saying that "\$\$xmap = is not a valid function or operator." I also cannot find where it would be in the "Usage" listing.

I am currently running ArcView 9.3.1 SP 2 with the Spatial Analyst extension, on Windows 7.

Thank you for any ideas you might have!

5. ## Re: Generate a grid of latitude values

Figured it out - needed to set the extent, snap raster, and cell size in the "Model Properties" to make it run. Put "\$\$xmap" in the "Map Algebra expression" text box and it ran fine.

6. ## Re: Generate a grid of latitude values

Dear Sir
I need to create a lattitude grid from the DEM. I have gone through the threads and followed the steps. When I type the statement \$\$YMAP in SOMA window after setting the extent, working directory and cell size by the spatial analyst > options, i get an error message that "Syntax error at locations 0 of expressions \$\$YMAP". I even changed the expression as E:\Ph.D\Data_dump\DEM = \$\$YMAP. How to access these built in functions? Kindly help me sir.
With Thanks

7. ## Re: Generate a grid of latitude values

I have tried this is arcGIS10 raster calculator and it doesn't work!! Any new detailed instructions on how to generate the grid of latitudes?

8. ## Re: Generate a grid of latitude values

I have not tried the raster calculator method.

However, I have had luck using the function "genvecgrid" in the Geospatial Modeling Environment (GME). After generating the vector point grid I added x-y coordinates to the attribute table. Then, created a raster from these points using the y-coordinate field as values. I think I chose a bilinear interpolation technique when doing this.

9. ## Re: Generate a grid of latitude values

Hi,
I have the same Problem as ejjunju (\$\$XMAP or \$\$xmap doesn't work in ArcGIS 10)

I want to create rasters with x-Values and do not have a clue how to Do it with the raster calculatur. I could create point-features, use "Add XY" and then convert it to rasters, but as I have to automatize it it seems to be too complicated.

I also have problems finding documentation/ tutorials on Map Algebra syntax. Does anyone know some sources for this

Greetings
Gerald

10. ## Re: Generate a grid of latitude values

Originally Posted by GeraldJtB
Hi,
I have the same Problem as ejjunju (\$\$XMAP or \$\$xmap doesn't work in ArcGIS 10)
Unfortunately, ESRI removed those grid functions from 10.0. However, there is a Python alternative, see this link .

11. ## Re: Generate a grid of latitude values

Hmm,
Thanks.

Looks like I have to get a little more familiar with Python then.
:-/

Does anyone know Tutorials that make it easier to start with ArcPy?

Greetings
Gerald

12. ## Re: Generate a grid of latitude values

Originally Posted by GeraldJtB
Hmm,
Does anyone know Tutorials that make it easier to start with ArcPy?
For starters, you might want to read "An Introduction to Python and the ArcPy site-package" in the latest issue of ArcUser.

Also, if you want to cast a vote for the reintroduction of the grid functions, go to this link.

13. ## Re: Generate a grid of latitude values

There are several workarounds that use only map algebra. A convenient one is to compute the flow accumulation for a constant map. Use a value of 1 to accumulate left to right and 64 to accumulate bottom to top. This effectively gives you \$\$ColMap and \$\$RowMap (indexing begins at 0). Adding 1/2, multiplying by the cellsize, and adding the origin recreates \$\$XMap and \$\$YMap. It's reasonably fast and not difficult to remember.

As a worked example let the origin be at (-500000, 0) and the cellsize be 10. Then
xmap = (FlowAccumulation(1) + 0.5)*10 - 500000
ymap = (FlowAccumulation(64) + 0.5)*10
Doing this in an unprojected coordinate system of course produces grids of longitude and latitude, respectively. Projecting the latitude grid (ymap) answers the question that started this thread. Note that the original elevation grid is used only to determine the extent, cellsize, and projection of the final grid; of course its values are useless.

14. ## Re: Arc10 workaround to \$\$XMAP and \$\$YMAP

Originally Posted by whuber
There are several workarounds that use only map algebra.

As a worked example let the origin be at (-500000, 0) and the cellsize be 10. Then
xmap = (FlowAccumulation(1) + 0.5)*10 - 500000
ymap = (FlowAccumulation(64) + 0.5)*10
.
Very clever Bill. This deserves its own sticky (if stickies are implemented on this forum).

15. ## Re: Arc10 workaround to \$\$XMAP and \$\$YMAP

Oops... there's a typo, and now it got quoted! The correct formula in the example is
xmap = (FlowAccumulation(1) + 0.5)*10 + 500000
(because one subtracts the coordinates of the origin instead of adding them).

16. ## arcpy map algebra \$\$ROWMAP, \$\$COLMAP

Bill, thank you very much for this!

I worked out a more detailed implementation of your idea here:
\$\$NCOLS + \$\$ROWMAP?

17. ## Re: Generate a grid of latitude values

Well done, Curtis: that's really clear code. Thank you!

18. ## Re: Arc10 workaround to \$\$XMAP and \$\$YMAP

Originally Posted by curtvprice
Bill, thank you very much for this!

I worked out a more detailed implementation of your idea here:
Hi,
I tried to open this link but it did not work. could you please elaborate this. I am struggling to solve this issue as well. Your help will
be highly appreciated.

Cheers

19. ## Re: Arc10 workaround to \$\$XMAP and \$\$YMAP

Don't like it that the post number changed -- I thought those were permanent links!