Ejemplo n.º 1
0
"""

from sqlalchemy import and_
from db.common import Session
from db.n2k import *

if __name__ == '__main__':

    tgt = r"D:\work\ms.monina\wp4\florkart_2012_occurrences_eunis_characteristic_species_n2k_areas_germany_all.txt"
    tgt = r"z:\bla.txt"
    output = list()

    session = Session()
    
    # retrieving all habitat types
    habitat_types = session.query(HabitatType).all()
    habitat_types = session.query(HabitatType).filter(HabitatType.type_id == '2310').all()
    
    for ht in habitat_types[:]:
        habitat_type = ht.type_id
    
        # retrieving all sites with the current habitat type
        sites_with_habitat_type = session.query(SitesHabitatTypes).filter(
            SitesHabitatTypes.type_id == habitat_type).all()
        
        # bailing out if no sites were found
        if not len(sites_with_habitat_type):
            continue

        print "Working on habitat type %s (%s)..." % (habitat_type, ht.shortname)
    
Ejemplo n.º 2
0
        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
        q_ids = [map_id for map_id in all_map_ids if not map_id.endswith('0')]
        # generalizing quadrant ids to corresponding mtb ids, i.e. 25101 -> 25100
        mq_ids = set([map_id[:-1] + '0' for map_id in q_ids])
        # calculating intersection between mtb ids and mtb/quadrant ids
        mq_intersect = [map_id for map_id in m_ids if map_id in mq_ids]

        print "\t+ Typical species present in %d map tiles overall (%d quadrant tiles, %d mtb tile(s))" % (
Ejemplo n.º 3
0
        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
        q_ids = [map_id for map_id in all_map_ids if not map_id.endswith('0')]
        # generalizing quadrant ids to corresponding mtb ids, i.e. 25101 -> 25100
        mq_ids = set([map_id[:-1] + '0' for map_id in q_ids])
        # calculating intersection between mtb ids and mtb/quadrant ids
        mq_intersect = [map_id for map_id in m_ids if map_id in mq_ids]

        print "\t+ Typical species present in %d map tiles overall (%d quadrant tiles, %d mtb tile(s))" % (len(all_map_ids), len(q_ids), len(m_ids))
Ejemplo n.º 4
0
"""

from sqlalchemy import and_
from db.common import Session
from db.n2k import *

if __name__ == '__main__':

    tgt = r"D:\work\ms.monina\wp4\florkart_2012_occurrences_eunis_characteristic_species_n2k_areas_germany_all.txt"
    tgt = r"z:\bla.txt"
    output = list()

    session = Session()

    # retrieving all habitat types
    habitat_types = session.query(HabitatType).all()
    habitat_types = session.query(HabitatType).filter(
        HabitatType.type_id == '2310').all()

    for ht in habitat_types[:]:
        habitat_type = ht.type_id

        # retrieving all sites with the current habitat type
        sites_with_habitat_type = session.query(SitesHabitatTypes).filter(
            SitesHabitatTypes.type_id == habitat_type).all()

        # bailing out if no sites were found
        if not len(sites_with_habitat_type):
            continue

        print "Working on habitat type %s (%s)..." % (habitat_type,