Thursday, 19 October 2017

fit point with raster data figure out those points belong to, and add column and row to represent it in ArcGIS 10.2.2


I have an X-Y point data file, with which has latitude and longitude. I'd like to be fit it with the raster data, then add column and row data on the X-Y point data file. first i created the attribute table of raster data by using spatial analyst> Int, but the attribute table does not fit my data, one record of data represents many of raster value.



and there are two pics for reference. enter image description here enter image description here



Answer



In ArcGis you can use point sampling using the spatial analyst tool Sample which creates a table showing the values for each point. Add the fields required, attribute join the table from the sample and use field calculator to copy the value from the joined data.


To do this in QGIS (if you don't have the spatial analyst license) you can use the point sampling plugin.


To find the row and column of raster that the point falls within you need to know the origin and cell size (get these from ArcCatalog)


Raster Properties showing cell size and origin


For the Column the field calculation (in python syntax) is:


Int((!shape.extent.XMin! - OriginX) / XCellSize)

for the Row:



Int(Abs((OriginY - !shape.extent.YMin!) / YCellSize))

As generally rasters have an origin from the top left. The extent of a point is 0 wide and 0 tall so XMin is the same as XMax and likewise with YMin and YMax.


enter image description here


From this image you can see how the point relates to the raster. Rasters (almost always) have their origin in the top left, the top is row 0 and the left is column 0. As this raster is in the southern hemisphere the Y coordinate is negative, this does not affect the results as both Ys' are negative.


To record the coordinate in image space you need to reduce by the origin of the raster so the X and Y are relative to the origin of the raster then just divide by the cell size (rounding down) to find out which cell the point falls in.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...