How to install GeoPlot

install  공식  가이드는 다음의 링크에서 확인가능하며  여기서는 debian에서  conda 없이 install 하는 방법 중심으로 작성하였습니다.

http://www.residentmar.io/geoplot/installing.html

# Use of a virtualenv is strongly encouraged.
$ mkdir my_project
$ cd my_project
$ virtualenv venv

$ source venv/bin/activate

# Easy installs that shouldn’t cause any problems.
(venv) $ pip install matplotlib seaborn

# … install proj4 and GEOS using brew, apt-get, etc. …
$ sudo apt-get install libgeos-dev
$ sudo apt-get install python2.7-dev libxml2-dev libxslt1-dev zlib1g-dev
$ pip install numpy

# Install shapely with the no-binary option.
# See https://github.com/Toblerity/Shapely/issues/435
# MACOS지원하려 source code 에서 빌드해야 한다.
# pip install shapely –no-binary shapely
$ pip install shapely

# Install the rest.

$ pip install geopandas
# fiona/_transform.cpp:441:22: fatal error: cpl_conv.h: No such file or directory
$ sudo apt-get install libgdal-dev
$ export CPLUS_INCLUDE_PATH=/usr/include/gdal
$ export C_INCLUDE_PATH=/usr/include/gdal
$ pip install GDAL

# cartopy
# x86_64-linux-gnu-gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory
$ sudo apt-get install build-essential
$ pip install cartopy

# finally geoplot
$ pip install geoplot

 

# 이제  예제를  실행시켜보자
# No module named figures, https://github.com/Toblerity/Shapely/issues/149
$ git clone https://github.com/Toblerity/Shapely
$ cd Shapely/docs/code
$ python polygon.py

screenshot-from-2017-02-14-01-14-17

Happy Coding~:)

Posted in geo, python | Tagged , | Leave a comment

[Book]Python 201

Python 201

Posted in python | Leave a comment

custom form 생성하기

in order to apply attributes to a custom form you have to change form.custom.begin before.

The following code should work:
#view html
{{extend ‘layout.html’}}
{{
# add class to form
form[‘_class’] = “form-horizontal”
# change form.custom.begin
form.custom.begin = XML(“<%s %s>” % (form.tag, form._xml()[0]))
}}{{=form.custom.begin}}
your content form
{{=form.custom.end}}
Moreover, if do you want a form with bootstrap layout you could simply add formstyle=’bootstrap” to the form via auth.settings.formstyle argument http://web2py.com/books/default/chapter/29/09?search=auth#Settings-and-messages avoiding to customize manually the html of the form.
 def login():
auth.settings.formstyle = ‘bootstrap’
form = auth.login()
return dict(form=form)
and in the view
{{=form}}

 

—–

 

In this group there are several discussions on this subject (i.e. https://groups.google.com/d/msg/web2py/gLTthVDhqFM/dWldB9xGavgJ)

Search for messages containing the word ‘_xml’
We are replacing the original form.custom.begin value with a new one within which is the ‘_class’ attribute
From web2py code documentation in gluon/html.py (class DIV):
DIV class has a tag variable that is the tag name
FORM is a subclass of DIV and updates it
therefore, if form is an istance of FORM, form.tag will be = ‘form’
_xml() is a helper for xml generation. Returns separately in a tuple:
– the component attributes
– the generated xml of the inner components
Component attributes start with an underscore (‘_’) and
do not have a False or None value. The underscore is removed.
A value of True is replaced with the attribute name.
Therefore form._xml()[0] returns the component attributes like ‘_action’, ‘_class’
by using XML you can prevent escaping
so,
XML(“<%s %s>” % (form.tag, form._xml()[0]))
returns
‘<form action=””>’

Il giorno martedì 20 novembre 2012 23:37:17 UTC+1, Daniele ha scritto:
https://groups.google.com/d/msg/web2py/DyspJUl_IMM/njKjq9mEb_0J

Posted in python, web2py | Leave a comment

PDF파일을 첨부파일로 다운로그 하기

 

pdf.output(name=request.folder+’/static/temp.pdf’)

    response.headers[‘Content-Disposition’] = ‘attachment; filename=abc.pdf’# to force download as attachment
# replace abc with whatever pdf name you want the user to see.
    response.headers[‘Content-Type’]=’application/pdf’
    return response.stream(open(request.folder+’/static/temp.pdf’,’rb’),chunk_size=4096)
Posted in python, web2py | Leave a comment

Database에 파일 저장하는 방법

https://groups.google.com/d/msg/web2py/8AoudcgECfY/IMOcW7zovoIJ

2012-11-19

in model

db.define_table(‘attachments’,
        Field(‘attachment’, ‘upload’, uploadfield=’payload’),
        Field(‘filename’, length=512),
        Field(‘Description’, ‘text’),
        Field(‘payload’, ‘blob’),
        migrate=init_migrate,
        )
in controller
att_id = db2.attachments.insert(
                    attachment = db2.attachments.attachment.store(…),
                    payload = stream.read(),
                    filename = fname,
                    Description = r.attachments.attachment_brief_description,
                    )
Posted in Uncategorized | Tagged , , , , | Leave a comment

User accessed site without logging in

User accessed site without logging in

로긴한적없는 유저가 다른유저로 로긴되어 있는 현상 발생

알고봤더니 uWSGI의 async버그로 발생한 문제,

uWSGI의 ipv6 address 처리 오류

forum: https://groups.google.com/d/msg/web2py/Tt8Rmp5UlCE/_p2gRxoviioJ

client ipaddress의 validation추가

git: https://github.com/web2py/web2py/commit/5a16a35ef2fa759eefdd20e67d2d41103dc48b10

Posted in python, web2py | Leave a comment

web2py 2.0 rc – lazy table

https://groups.google.com/d/topic/web2py/YNfreBJ2LYo/discussion

Posted in Uncategorized | Leave a comment