Create a raster of latitude

150
3
Jump to solution
08-15-2022 05:18 PM
Jaslam
by
New Contributor II

Hi

Can anyone suggest the best way to create a grid from a large DEM (30M, Columns_and_Rows -208667, 88412  ) where the cell value is simply its latitude?

 

 

Raster to Point -> Calculate Geometry approach requiring a significant amount of time 

https://support.esri.com/en/technical-article/000018247 . Looking for the best alternative option

 

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

The one I created was for the world.

You simply need to specify the latitude range that you want with the increment that you want and repeat it for the number of longitude increments that you need.  Specifying the lower left corner would correspond to the minimum of the latitude range as noted above.

Note that your cell size should be denoted in the units of the data, which is decimal degrees, not meters.  you need to project the resultant raster if you want a planar raster.  Your spatial reference should be something like an ellipsoidal wgs84 or similar


... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

It might bail due to the size, but you can use numpy, then arcpy's NumPyArrayToRaster to convert it to a raster.

 

# -- make some latitude values, then repeat
# example is for 10 degree increments to test

lat = np.arange(90., -100., -10.)  # make a row of latitudes
lat2 = lat.reshape([lat.shape[0], -1])  # rotate it to a column
np.repeat(lat2, 37, 1)
gr = np.repeat(lat2, 37, 1)
# -- results
lat2 
array([[ 90.00],
       [ 80.00],
       [ 70.00],
       [ 60.00],
       [ 50.00],
       [ 40.00],
       [ 30.00],
       [ 20.00],
       [ 10.00],
       [  0.00],
       [-10.00],
       [-20.00],
       [-30.00],
       [-40.00],
       [-50.00],
       [-60.00],
       [-70.00],
       [-80.00],
       [-90.00]])

gr
array([[ 90.00,  90.00,  90.00, ...,  90.00,  90.00,  90.00],
       [ 80.00,  80.00,  80.00, ...,  80.00,  80.00,  80.00],
       [ 70.00,  70.00,  70.00, ...,  70.00,  70.00,  70.00],
       ...,
       [-70.00, -70.00, -70.00, ..., -70.00, -70.00, -70.00],
       [-80.00, -80.00, -80.00, ..., -80.00, -80.00, -80.00],
       [-90.00, -90.00, -90.00, ..., -90.00, -90.00, -90.00]])

gr.shape  # -- rows and columns, 90 to -90 and -180 to 180
(19, 37)

... sort of retired...
Jaslam
by
New Contributor II

Thank @DanPatterson 

it works! But I have an issue: the created raster is in South Africa, but I need it in the United States😅

I added a couple of codes to yours....

such as

1. arcpy.env.outputCoordinateSystem=arcpy.SpatialReference('NAD 1983')

2. corner=arcpy.Point(40., 26.)

    myRaster=arcpy.NumPyArrayToRaster(gr,corner,x_cell_size=30)

but it does not work! How can I create rasters on a specific location using the above approach?

 

Thanks Much

Jaslam

 

 

 

 

0 Kudos
DanPatterson
MVP Esteemed Contributor

The one I created was for the world.

You simply need to specify the latitude range that you want with the increment that you want and repeat it for the number of longitude increments that you need.  Specifying the lower left corner would correspond to the minimum of the latitude range as noted above.

Note that your cell size should be denoted in the units of the data, which is decimal degrees, not meters.  you need to project the resultant raster if you want a planar raster.  Your spatial reference should be something like an ellipsoidal wgs84 or similar


... sort of retired...