>>> import numpy as np >>> a = [[1,2,3],[4,5,6],[7,8,9]] >>> b = np.array(a) >>> b array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> b.shape (3, 3) >>>
I would like to use arcpy.NumPyArrayToRaster to import a numpy array and use in arcGIS10 as a raster.
This function works fine except I did not enter the lower left corner (in map units) and the x and y cell size, therefore my image was upside down!
Is there a simple command I can run in python on my numpy array to find out what the lower left corner is??
thanks
corner = arcpy.Point(xllcorner, yllcorner) myRaster = arcpy.NumpyArrayToRaster(myArray, corner, cellSizeX, cellSizeY)
flipped_array = numpy.flip_ud(myArray).
Thanks for the feedback, especially the point/corner idea.
I eventually found lower left corner (print LONmin() LATmin() for netcdf file) and cell size (simply by printing all the lats and lons in python and then minusing one from the other, not the prettiest method but it gave me what I needed)
but I seem to still be producing an upside down raster!
I have tried numpy.flipud and from the documentation this appears to be the best method but the results are strange lines.
Maybe to solve this problem I need to go back to the original array?
Is there some way I should write my array to a file that will make it easier to import into arcmap as a raster?
I am currently using
savetxt("myfile.txt", myarray)
any feedback will be greatly appreciated.
myArrayFlipped = np.array(np.flipud(myArray))