예제 #1
0
    def get_dataframe(self, provincia):
        science.lock.acquire()
        try:
            if science.last_dataframe is None or science.last_dataframe[0] != provincia:
                df = sigpac.get_dataframe(sigpac.all_zipcodes(starting_with=provincia),
                                          data_dir=cfg.data_dir,
                                          tmp_dir=cfg.tmp_dir,
                                          force_download=False,
                                          with_bbox_center=True)
                science.last_dataframe = (provincia, df)

            return science.last_dataframe[1]
        finally:
            science.lock.release()
예제 #2
0
import osc.importer.sigpac as sigpac
import matplotlib.pyplot as plt
import seaborn as sns
import os
import osc.config as config
import pandas as pd

# store = pd.HDFStore(os.path.join(config.data_dir, 'SIGPAC', 'dataframes.h5'))

# ['05', '09', '24', '34', '37', '40', '42', '47', '49']

for codigo_provincia in ['34', '40', '42', '47', '49', '24']:
    print 'Starting with zipcode ' + codigo_provincia

    df = sigpac.get_dataframe(
        sigpac.all_zipcodes(starting_with=codigo_provincia),
        force_download=False,
        with_bbox_center=True)

    xmin = df['x_bbox_center'].min() - 10000
    xmax = df['x_bbox_center'].max() + 20000
    ymin = df['y_bbox_center'].min() - 10000
    ymax = df['y_bbox_center'].max() + 10000
    aspect = (xmax - xmin) / (ymax - ymin)

    # Plot the whole map
    print 'Plotting all uses'
    g = sns.lmplot(x='x_bbox_center',
                   y='y_bbox_center',
                   hue='USO_SIGPAC',
                   fit_reg=False,
예제 #3
0
    if module == 'inforiego':
        for y in sys.argv[2:]:
            year = str(y)

            print 'Importing ' + year

            inforiego.save2elasticsearch(years=[year],
                                         data_dir=data_dir,
                                         encoding=encoding,
                                         tmp_dir=tmp_dir)
    if module == 'inforiego_daily':
        years = sys.argv[2:]

        inforiego.insert_all_stations_inforiego_daily(years=years)

    elif module == 'SIGPAC':
        for zc in sys.argv[2:]:
            zip_code = str(zc)

            print 'Importing ' + zip_code

            sigpac.save2elasticsearch(zip_codes=sigpac.all_zipcodes(
                starting_with=zip_code))
    elif module == 'GOOGLE':
        for prov in sys.argv[2:]:
            provincia = int(prov)

            print 'Importing ' + prov

            sigpac.add_altitude_info(provincia)
예제 #4
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 04 17:16:53 2016

@author: jlafuente
"""
import os

from osc.importer import sigpac

data_dir = os.path.join(os.getenv('OSC_HOME', '../data'), 'data')
tmp_dir = os.path.join(os.getenv('OSC_HOME', '../tmp'), 'tmp')

print "Writing all CSV Files. data_dir = " + data_dir + ' tmp_dir = ' + tmp_dir

sigpac.write_csv(sigpac.all_zipcodes(),
                 data_dir=data_dir,
                 tmp_dir=tmp_dir,
                 force_download=False)

print "I'm done!!!"
예제 #5
0
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 04 17:16:53 2016

@author: jlafuente
"""
import os

from osc.importer import sigpac

data_dir = os.path.join(os.getenv('OSC_HOME', '../data'), 'data')
tmp_dir = os.path.join(os.getenv('OSC_HOME', '../tmp'), 'tmp')

print "Downloading SIGPAC shapefiles. data_dir = " + data_dir + ' tmp_dir = ' + tmp_dir

sigpac.download_shapefiles(sigpac.all_zipcodes(),
                           data_dir=data_dir,
                           tmp_dir=tmp_dir,
                           force_download=False)

print "I'm done!!!"