Ejemplo n.º 1
0
    ht_map_ids = dict()

    # caching map ids
    for line in open(ht_src):
        tokens = line.strip().split("\t")
        if len(tokens) > 1:
            ht = tokens[0]
            ht_map_ids[ht] = list(set(tokens[1].split(", ")))

    # caching centroids
    m_centroids = cache_centroids(md_src)
    q_centroids = cache_centroids(qd_src)

    # preparing other stuff
    session = Session()
    output = list()
    wkt_output = list()

    for ht_id in sorted(ht_map_ids.keys()):
        #for ht_id in ['2310']:
        ht_name = session.query(HabitatType).filter(
            HabitatType.type_id == ht_id).one().shortname

        print "Working on %s (%s)..." % (ht_id, ht_name)
        maxent_ht_name = " ".join((ht_id, ht_name)).lower().replace(" ", "_")

        all_map_ids = ht_map_ids[ht_id]
        # retrieving all mtb tiles where current habitat type is present
        m_ids = [map_id for map_id in all_map_ids if map_id.endswith('0')]
        # retrieving all quadrant tiles where current habitat type is present