コード例 #1
0
 def test_from_points(self):
     src = np.array(
         [[0.0, 0.0], [200.0, 0.0], [200.0, 100.0], [0.0, 100.0]])
     diff = np.array([10, 20])
     dst = src - diff
     h = homography.from_points(src, dst)
     expected = Homography.translation(-diff[0], -diff[1])
     self.assertEqual(h, expected)
     src = [Point(x, y) for x, y in src]
     dst = [Point(x, y) for x, y in dst]
     h = homography.from_points(src, dst)
     self.assertEqual(h, expected)
コード例 #2
0
def SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR,
                          cornerPointLL, frameCenterLon, frameCenterLat):
    ''' Make Geotranform from pixel to lon lat coordinates '''
    gcps = []

    global gcornerPointUL
    gcornerPointUL = cornerPointUL
    global gcornerPointUR
    gcornerPointUR = cornerPointUR
    global gcornerPointLR
    gcornerPointLR = cornerPointLR
    global gcornerPointLL
    gcornerPointLL = cornerPointLL
    global gframeCenterLat
    gframeCenterLat = frameCenterLat
    global gframeCenterLon
    gframeCenterLon = frameCenterLon

    global geotransform
    geotransform = gdal.GCPsToGeoTransform(gcps)

    src = np.float64(
        np.array([[0.0, 0.0], [xSize, 0.0], [xSize, ySize], [0.0, ySize]]))
    dst = np.float64(
        np.array([cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL]))
    geotransform = from_points(src, dst)

    if geotransform is None:
        qgsu.showUserAndLogMessage(QCoreApplication.translate(
            "QgsFmvUtils", 'Unable to extract a geotransform.'),
                                   onlyLog=True)

    return
コード例 #3
0
def SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR,
                          cornerPointLL, frameCenterLon, frameCenterLat, ele):
    ''' Make Geotranform from pixel to lon lat coordinates '''
    gcps = []

    global gcornerPointUL, gcornerPointUR, gcornerPointLR, gcornerPointLL, gframeCenterLat, gframeCenterLon, geotransform_affine, geotransform

    # TEMP FIX : If have elevation the geotransform is wrong
    if ele:
        del cornerPointUL[-1]
        del cornerPointUR[-1]
        del cornerPointLR[-1]
        del cornerPointLL[-1]

    gcornerPointUL = cornerPointUL
    gcornerPointUR = cornerPointUR
    gcornerPointLR = cornerPointLR
    gcornerPointLL = cornerPointLL

    gframeCenterLat = frameCenterLat
    gframeCenterLon = frameCenterLon

    Height = GetFrameCenter()[2]

    gcp = gdal.GCP(cornerPointUL[1], cornerPointUL[0], Height, 0, 0,
                   "Corner Upper Left", "1")
    gcps.append(gcp)
    gcp = gdal.GCP(cornerPointUR[1], cornerPointUR[0], Height, xSize, 0,
                   "Corner Upper Right", "2")
    gcps.append(gcp)
    gcp = gdal.GCP(cornerPointLR[1], cornerPointLR[0], Height, xSize, ySize,
                   "Corner Lower Right", "3")
    gcps.append(gcp)
    gcp = gdal.GCP(cornerPointLL[1], cornerPointLL[0], Height, 0, ySize,
                   "Corner Lower Left", "4")
    gcps.append(gcp)
    gcp = gdal.GCP(frameCenterLon, frameCenterLat, Height, xSize / 2,
                   ySize / 2, "Center", "5")
    gcps.append(gcp)

    geotransform_affine = gdal.GCPsToGeoTransform(gcps)

    src = np.float64(
        np.array([[0.0, 0.0], [xSize, 0.0], [xSize, ySize], [0.0, ySize]]))
    dst = np.float64(
        np.array([cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL]))

    try:
        geotransform = from_points(src, dst)
    except Exception:
        pass

    if geotransform is None:
        qgsu.showUserAndLogMessage("",
                                   "Unable to extract a geotransform.",
                                   onlyLog=True)

    return
コード例 #4
0
ファイル: QgsFmvUtils.py プロジェクト: Kuppharish/QGISFMV
def SetGCPsToGeoTransform(cornerPointUL, cornerPointUR, cornerPointLR,
                          cornerPointLL, frameCenterLon, frameCenterLat):
    ''' Make Geotranform from pixel to lon lat coordinates '''
    gcps = []

    global gcornerPointUL
    gcornerPointUL = cornerPointUL
    global gcornerPointUR
    gcornerPointUR = cornerPointUR
    global gcornerPointLR
    gcornerPointLR = cornerPointLR
    global gcornerPointLL
    gcornerPointLL = cornerPointLL
    global gframeCenterLat
    gframeCenterLat = frameCenterLat
    global gframeCenterLon
    gframeCenterLon = frameCenterLon
    global geotransform
    global geotransform_affine

    Height = GetFrameCenter()[2]

    gcp = gdal.GCP(cornerPointUL[1], cornerPointUL[0], Height, 0, 0,
                   "Corner Upper Left", "1")
    gcps.append(gcp)
    gcp = gdal.GCP(cornerPointUR[1], cornerPointUR[0], Height, xSize, 0,
                   "Corner Upper Right", "2")
    gcps.append(gcp)
    gcp = gdal.GCP(cornerPointLR[1], cornerPointLR[0], Height, xSize, ySize,
                   "Corner Lower Right", "3")
    gcps.append(gcp)
    gcp = gdal.GCP(cornerPointLL[1], cornerPointLL[0], Height, 0, ySize,
                   "Corner Lower Left", "4")
    gcps.append(gcp)
    gcp = gdal.GCP(frameCenterLon, frameCenterLat, Height, xSize / 2,
                   ySize / 2, "Center", "5")
    gcps.append(gcp)

    geotransform_affine = gdal.GCPsToGeoTransform(gcps)

    src = np.float64(
        np.array([[0.0, 0.0], [xSize, 0.0], [xSize, ySize], [0.0, ySize]]))
    dst = np.float64(
        np.array([cornerPointUL, cornerPointUR, cornerPointLR, cornerPointLL]))
    geotransform = from_points(src, dst)

    if geotransform is None:
        qgsu.showUserAndLogMessage("",
                                   "Unable to extract a geotransform.",
                                   onlyLog=True)

    return