0

I am looking for the rasterio function that does forward transformation from geodetic coordinate system to image coordinate system based on RPC. Can anyone help me within this context?

  • Can you please add more details? You can use `OGRSpatialReference` to convert between different CRS. What do you mean by "image coordinate system" pixels? – cosmarc Nov 07 '19 at 08:24
  • It means that we need to convert a coordinate in WGS84 to image coordinate system (like x and y pixel number) based on RPC (that is embedded in the satellite imagery). “gdaltransform” can do this, but it is an exe file and convert one pixel at time, while I need to pass an array of coordinates. – Ghasem Abdi Nov 08 '19 at 09:09
  • Do you want to do it in C++ or in Python? This might be a useful topic: https://gis.stackexchange.com/questions/245472/convert-latitude-longitude-pair-to-pixels-in-geotiff – cosmarc Nov 08 '19 at 20:31

1 Answers1

0

rasterio currently doesn't support using RPCs to transform from world coordinates to image coordinates, like GDAL does. See the discussion on this topic here: https://github.com/mapbox/rasterio/issues/410

However, I can recommend a python library that implements a vectorized transform to/from world/image coordinates: https://github.com/cmla/rpcm

The README of this library only shows the command-line usage of the tool, but you can call it directly in python:

import numpy as np
from rpcm import rpc_from_geotiff

rpc = rpc_from_geotiff("path_to_your_file.tiff")

lon = np.array([..., ...])
lat = np.array([..., ...])
x, y = rpc.projection(lon, lat)
guampi
  • 306
  • 1
  • 8