u""" ... Put description here ... """ 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
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
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 q_ids = [map_id for map_id in all_map_ids if not map_id.endswith('0')]
# Creation Date: 2012/06/29 12:09:02 u""" ... Put description here ... """ 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):