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

  • Hi Julia, we would really need to know what software you're using. Nov 26 '14 at 1:19
  • it is ArcGIS 10.2.2. Nov 26 '14 at 1:21

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.

  • I already have the coordinates value for each point, what i wanna know is that image the raster data is a mesh, and i want to find out each point belongs to which mesh by column and row expression which is like the first pic i uploaded. Nov 26 '14 at 1:35
  • Oh, so it's not the values of the cells but the cell itself. That's just simple maths based on the origin and cell size. I'll update the answer with that. Nov 26 '14 at 1:36
  • The raster I have has a cell size of 1 metre. In order to use this method the points and raster must have the same spatial reference (units). For geographic points your cell size should be tiny (much less than 1) and origin should be less than 180. Nov 26 '14 at 4:59
  • i was wondering the first step for sample tool, i need input the raster data and then what type pf data should i input, the pink point data which i showed it as the second pic, or others. and the cell size of my data is 0.114282246, the origin top is 46.3817777196, the left is 127.904360148. and I think i might not totally understand your answer. but thanks you so much! Nov 26 '14 at 5:57
  • The sample tool gets the Value of the raster at each point and puts it into a table, to calculate the row & column just use the 2nd part of the answer. The Cell Size and Origin look right for geographic data (but it is a very coarse raster) just put the numbers into the formulas and you will get the row and column. Nov 26 '14 at 21:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.