Lat/Lon to Row/Colmn

조회 수: 7 (최근 30일)
Sharareh Akbarian
Sharareh Akbarian 2019년 12월 3일
답변: Sourav Bairagya 2019년 12월 9일
HI everyone,
I have a geotiff image, and I want to convert lat and long coordinates of several point into pixel coordinate. How can i do it?

답변 (1개)

Sourav Bairagya
Sourav Bairagya 2019년 12월 9일
There are two functions which you can use.
If you have the GeoTIFF file, then “geotiffread”helps to read a georeferenced grayscale, RGB, or multispectral image or data grid from the GeoTIFF file specified by filename into A and creates a spatial referencing object, R.
[A, R] = geotiffread(filename);
If you already have the reference object and corresponding latitudes and longitudes, then you can use “latlon2pix” function.
[row, col] = latlon2pix(R,lat,lon);
It calculates pixel coordinates row, col from latitude-longitude coordinates ‘lat’, ‘lon’. ‘R’ is either a 3-by-2 referencing matrix that transforms intrinsic pixel coordinates to geographic coordinates, or a geographic raster reference object. ‘lat’ and ‘lon’ are vectors or arrays of matching size. The outputs row and col have the same size as ‘lat’ and ‘lon’. ‘lat’ and ‘lon’must be in degrees.
For more information you can follow these links:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by