Exemple #1
0
    def GroupSet(self, group, subgroup):
        kwargs = {}
        if subgroup:
            kwargs['subgroup'] = subgroup

        res = RunCommand('i.group',
                         flags = 'g',
                         group = group,
                         read = True, **kwargs).strip()

        if res.split('\n')[0]:
            bands = res.split('\n')
            self.scatt_mgr.SetBands(bands)
Exemple #2
0
    def GetGroupBands(self, group, subgroup):
        """Get list of raster bands which are in the soubgroup of group with both having same name."""

        kwargs = {}
        if subgroup:
            kwargs["subgroup"] = subgroup

        res = RunCommand("i.group", flags="g", group=group, read=True, **kwargs).strip()
        bands = None
        if res.split("\n")[0]:
            bands = res.split("\n")

        return bands
Exemple #3
0
def ReprojectCoordinates(coord, projOut, projIn=None, flags=''):
    """Reproject coordinates

    :param coord: coordinates given as tuple
    :param projOut: output projection
    :param projIn: input projection (use location projection settings)

    :return: reprojected coordinates (returned as tuple)
    """
    coors = RunCommand('m.proj',
                       flags=flags,
                       input='-',
                       proj_in=projIn,
                       proj_out=projOut,
                       sep=';',
                       stdin='%f;%f' % (coord[0], coord[1]),
                       read=True)
    if coors:
        coors = coors.split(';')
        e = coors[0]
        n = coors[1]
        try:
            proj = projOut.split(' ')[0].split('=')[1]
        except IndexError:
            proj = ''
        if proj in ('ll', 'latlong', 'longlat') and 'd' not in flags:
            return (proj, (e, n))
        else:
            try:
                return (proj, (float(e), float(n)))
            except ValueError:
                return (None, None)

    return (None, None)
Exemple #4
0
def ReprojectCoordinates(coord, projOut, projIn=None, flags=''):
    """Reproject coordinates

    :param coord: coordinates given as tuple
    :param projOut: output projection
    :param projIn: input projection (use location projection settings)

    :return: reprojected coordinates (returned as tuple)
    """
    coors = RunCommand('m.proj',
                       flags=flags,
                       input='-',
                       proj_in=projIn,
                       proj_out=projOut,
                       sep=';',
                       stdin='%f;%f' % (coord[0], coord[1]),
                       read=True)
    if coors:
        coors = coors.split(';')
        e = coors[0]
        n = coors[1]
        try:
            proj = projOut.split(' ')[0].split('=')[1]
        except IndexError:
            proj = ''
        if proj in ('ll', 'latlong', 'longlat') and 'd' not in flags:
            return (proj, (e, n))
        else:
            try:
                return (proj, (float(e), float(n)))
            except ValueError:
                return (None, None)

    return (None, None)
Exemple #5
0
    def GetGroupBands(self, group, subgroup):
        """Get list of raster bands which are in the soubgroup of group with both having same name."""

        kwargs = {}
        if subgroup:
            kwargs['subgroup'] = subgroup

        res = RunCommand('i.group',
                         flags='g',
                         group=group,
                         read = True, **kwargs).strip()
        bands = None
        if res.split('\n')[0]:
            bands = res.split('\n')
            
        return bands
Exemple #6
0
def ReprojectCoordinates(coord, projOut, projIn=None, flags=''):
    """!Reproject coordinates

    @param coord coordinates given as tuple
    @param projOut output projection
    @param projIn input projection (use location projection settings)

    @return reprojected coordinates (returned as tuple)
    """
    if not projIn:
        projIn = RunCommand('g.proj', flags='jf', read=True)
    coors = RunCommand('m.proj',
                       flags=flags,
                       proj_in=projIn,
                       proj_out=projOut,
                       stdin='%f|%f' % (coord[0], coord[1]),
                       read=True)
    if coors:
        coors = coors.split('\t')
        e = coors[0]
        n = coors[1].split(' ')[0].strip()
        try:
            proj = projOut.split(' ')[0].split('=')[1]
        except IndexError:
            proj = ''
        if proj in ('ll', 'latlong', 'longlat') and 'd' not in flags:
            return (proj, (e, n))
        else:
            try:
                return (proj, (float(e), float(n)))
            except ValueError:
                return (None, None)

    return (None, None)
Exemple #7
0
    def getEPSG(self):
        epsg = RunCommand(
            prog='g.proj',
            flags='g',
            read=True,
            parse=parse_key_val,
        ).get('srid')
        if epsg and 'EPSG' in epsg:
            return epsg.split(':')[1]

        return self.wkt2standards(
            RunCommand(prog='g.proj', flags='wf', read=True), )
Exemple #8
0
    def getEPSG(self):
        epsg = RunCommand(
            prog="g.proj",
            flags="g",
            read=True,
            parse=parse_key_val,
        ).get("srid")
        if epsg and "EPSG" in epsg:
            return epsg.split(":")[1]

        return self.wkt2standards(
            RunCommand(prog="g.proj", flags="wf", read=True),
        )
Exemple #9
0
def ReprojectCoordinates(coord, projOut, projIn=None, flags=""):
    """Reproject coordinates

    :param coord: coordinates given as tuple
    :param projOut: output projection
    :param projIn: input projection (use location projection settings)

    :return: reprojected coordinates (returned as tuple)
    """
    coors = RunCommand(
        "m.proj",
        flags=flags,
        input="-",
        proj_in=projIn,
        proj_out=projOut,
        sep=";",
        stdin="%f;%f" % (coord[0], coord[1]),
        read=True,
    )
    if coors:
        coors = coors.split(";")
        e = coors[0]
        n = coors[1]
        try:
            proj = projOut.split(" ")[0].split("=")[1]
        except IndexError:
            proj = ""
        if proj in ("ll", "latlong", "longlat") and "d" not in flags:
            return (proj, (e, n))
        else:
            try:
                return (proj, (float(e), float(n)))
            except ValueError:
                return (None, None)

    return (None, None)
Exemple #10
0
def ReprojectCoordinates(coord, projOut, projIn = None, flags = ''):
    """!Reproject coordinates

    @param coord coordinates given as tuple
    @param projOut output projection
    @param projIn input projection (use location projection settings)

    @return reprojected coordinates (returned as tuple)
    """
    if not projIn:
        projIn = RunCommand('g.proj',
                            flags = 'jf',
                            read = True)
    coors = RunCommand('m.proj',
                       flags = flags,
                       proj_in = projIn,
                       proj_out = projOut,
                       stdin = '%f|%f' % (coord[0], coord[1]),
                       read = True)
    if coors:
        coors = coors.split('\t')
        e = coors[0]
        n = coors[1].split(' ')[0].strip()
        try:
            proj = projOut.split(' ')[0].split('=')[1]
        except IndexError:
            proj = ''
        if proj in ('ll', 'latlong', 'longlat') and 'd' not in flags:
            return (proj, (e, n))
        else:
            try:
                return (proj, (float(e), float(n)))
            except ValueError:
                return (None, None)
    
    return (None, None)