Generate a grid of latitude values

10151
19
04-30-2010 07:18 AM
ToddMcDonnell
Emerging Contributor
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
0 Kudos
19 Replies
GJtB
by
Emerging Contributor
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
0 Kudos
MannyGimond
Regular Contributor
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.
0 Kudos
MannyGimond
Regular Contributor
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[INDENT]xmap = (FlowAccumulation(1) + 0.5)*10 - 500000
ymap = (FlowAccumulation(64) + 0.5)*10
[/INDENT].


Very clever Bill. This deserves its own sticky (if stickies are implemented on this forum).
0 Kudos
curtvprice
MVP Esteemed Contributor

Bill, thank you very  much for this!

I worked out a more detailed implementation of your idea here:
$$NCOLS + $$ROWMAP in ArcGIS 10 Python map algebra

0 Kudos
RakhshanRoohi
Emerging Contributor
Bill, thank you very  much for this!

I worked out a more detailed implementation of your idea here:
[post]166151[/post]


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
0 Kudos
curtvprice
MVP Esteemed Contributor
I fixed the link above.

Don't like it that the post number changed -- I thought those were permanent links!
0 Kudos
FrankHanssen
Regular Contributor
Taking out the $$YMAP and $$XMAP was really a big mistake!!!! Why spend a lot of energy on python scripting instead of using these excellent and easy to use commands??? Please put them back!
0 Kudos
FrankHanssen
Regular Contributor
Oops... there's a typo, and now it got quoted!  The correct formula in the example is
[INDENT]xmap = (FlowAccumulation(1) + 0.5)*10 + 500000
[/INDENT](because one subtracts the coordinates of the origin instead of adding them).


Bill, I am stucked here and anoid that $$XMAP and $$YMAP are removed from 10.1.

I have tried to implement your tip in my raster calculator whitout success. What is wrong? I would like to avoid Python...

xmap = (FlowAccumulation(1) + 0.5)*10 + 500000
ymap = (FlowAccumulation(64) + 0.5)*10
0 Kudos
curtvprice
MVP Esteemed Contributor
0 Kudos
LuizVianna
Regular Contributor

This worked for me, for southern hemisphere (negative lat and lon). It is necessary to set the environmental options before running the script.

import numpy as np
import arcpy
from arcpy.sa import *  
from arcpy import env as E

#Create variables from environment
latmin = E.extent.YMin
latmax = E.extent.YMax
lonmin = E.extent.XMin
lonmax = E.extent.XMax
cellsize = float(E.cellSize)
lowerleft = arcpy.Point(lonmin, latmin)

#Generating inverse meshgrid for latitude grid
lat1 = np.arange(float(-latmax), float(-latmin), float(cellsize))
lon1 = np.arange(float(-lonmax), float(-lonmin), float(cellsize))
lon1, lat1 = np.meshgrid(lon1, lat1)

lat = arcpy.NumPyArrayToRaster(-lat1, lowerleft, float(cellsize), float(cellsize))

#Generating meshgrid for longitude grid
lat2 = np.arange(float(latmin), float(latmax), float(cellsize))
lon2 = np.arange(float(lonmin), float(lonmax), float(cellsize))
lon2, lat2 = np.meshgrid(lon2, lat2)

lon = arcpy.NumPyArrayToRaster(lon2, lowerleft, float(cellsize), float(cellsize))‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos