|
1 | 1 | # python-geosupport |
2 | 2 |
|
3 | | -[](https://ci.appveyor.com/project/ishiland/python-geosupport) [](https://www.python.org/downloads/release/python-2714/) [](https://www.python.org/downloads/release/python-360/) [](https://pypi.python.org/pypi/python-geosupport/) |
| 3 | +[](https://ci.appveyor.com/project/ishiland/python-geosupport) [](https://pypi.python.org/pypi/python-geosupport/) [](https://www.python.org/downloads/release/python-360/) |
4 | 4 |
|
5 | | -Python bindings for NYC Planning's [Geosupport Desktop Edition](https://www1.nyc.gov/site/planning/data-maps/open-data/dwn-gde-home.page). |
6 | | - |
7 | | -## Installation |
8 | | -### Prerequisites |
9 | | - |
10 | | -Install Geosupport Desktop Edition (tested with version 18b): |
11 | | - |
12 | | - * [Geosupport Desktop Edition for Windows (32-bit)](http://www1.nyc.gov/assets/planning/download/zip/data-maps/open-data/gde_18b.zip) |
13 | | - * [Geosupport Desktop Edition for Windows (64-bit)](http://www1.nyc.gov/assets/planning/download/zip/data-maps/open-data/gde64_18b.zip) |
14 | | - * [Geosupport Desktop Edition for Linux](https://www1.nyc.gov/assets/planning/download/zip/data-maps/open-data/gdelx_18b.zip) |
15 | | - |
16 | | -#### Windows |
17 | | -**Important**: Ensure you select the correct Geosupport installation that corresponds to the Python interpreter you are using. Ex., Python 32-bit will only work with Geosupport 32-bit. |
18 | | - |
19 | | -Additionally, you should check that the following environmental variables are set: |
20 | | -* `GEOFILES` = the `fls` directory of your Geosupport installation. (ex. `C:\Program Files (x86)\Geosupport Desktop Edition\fls\`) |
21 | | -* The Geosupport `bin` directory is in the `PATH`. (ex. `C:\Program Files (x86)\Geosupport Desktop Edition\bin`) |
22 | | - |
23 | | -#### Linux |
24 | | -Extract the .zip to a folder of your choice and set the `GEOFILES` and `LD_LIBRARY_PATH` environmental variables of the `fls` and `lib` directories: |
25 | | - |
26 | | -```shell |
27 | | -$ export GEOFILES=/var/geosupport/version-17c/fls/ |
28 | | -$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/var/geosupport/version-17c/lib/ |
29 | | -``` |
30 | 5 |
|
31 | | -### Install python-geosupport |
32 | | - |
33 | | -Install via [pip](https://pip.readthedocs.io/en/latest/quickstart.html): |
34 | | - |
35 | | -```shell |
36 | | -$ pip install python-geosupport |
37 | | -``` |
38 | | - |
39 | | -Or clone this repository and: |
40 | | - |
41 | | -```shell |
42 | | -$ python setup.py install |
43 | | -``` |
44 | | - |
45 | | -## Usage |
| 6 | +Python bindings for NYC Planning's [Geosupport Desktop Edition](https://www1.nyc.gov/site/planning/data-maps/open-data/dwn-gde-home.page). |
46 | 7 |
|
47 | | -### Examples |
| 8 | +### [Read the docs](https://python-geosupport.readthedocs.io/en/latest/) |
48 | 9 |
|
49 | | -#### Basic Usage |
| 10 | +## Quickstart |
50 | 11 |
|
51 | 12 | ```python |
52 | 13 | # Import the library and create a `Geosupport` object. |
@@ -79,143 +40,6 @@ result = g.address(house_number=125, street_name='Worth St', borough_code='Mn') |
79 | 40 | } |
80 | 41 | ``` |
81 | 42 |
|
82 | | -#### Calling Geosupport functions |
83 | | - |
84 | | -python-geosupport is flexible with how you call functions. You can use either |
85 | | -Geosupport function codes or human readable alternate names, and access them |
86 | | -either through python object attribute notation or dictionary item notation: |
87 | | - |
88 | | -```python |
89 | | -# Different ways of calling function 3S which processes street stretches |
90 | | -g.street_stretch(...) |
91 | | -g['street_stretch'](...) |
92 | | -g['3S'](...) |
93 | | -g.call({'function': '3S', ...}) |
94 | | -g.call(function='3S', ...) |
95 | | -``` |
96 | | - |
97 | | -You can pass arguments as a dictionary, keyword arguments. |
98 | | - |
99 | | -```python |
100 | | -# Use a dictionary with short names |
101 | | -g.street_stretch({'borough_code': 'MN', 'on': '1 Av', 'from': '1 st', 'to': '2 st'}) |
102 | | -# Use keyword arguments with short names |
103 | | -g.street_stretch( |
104 | | - borough_code='MN', street_name_1='1 Av', |
105 | | - street_name_2='1 st', street_name_3='9 st' |
106 | | -) |
107 | | -# Use dictionary with full names |
108 | | -g.street_stretch({ |
109 | | - 'Borough Code-1': 'MN', |
110 | | - 'Street Name-1': '1 Av', |
111 | | - 'Street Name-2': '1 st', |
112 | | - 'Street Name-3': '9 st' |
113 | | -}) |
114 | | -``` |
115 | | - |
116 | | -#### Mode |
117 | | - |
118 | | -A number of Geosupport functions support several modes: Exetended, Long, and |
119 | | -TPAD Long. You can set the flags individually as you would with using Geosupport |
120 | | -directly, but python-geosupport makes it easier with the `mode` argument. `mode` |
121 | | -can be one of `regular` (default), `extended`, `long` and `long+tpad`. |
122 | | - |
123 | | -```python |
124 | | -# Call BL (Block and Lot) function in long mode |
125 | | -g.BL(mode='long', ...) |
126 | | -g.BL(mode='long+tpad', ...) # With TPAD |
127 | | - |
128 | | -# Call 3 (Street Segment) function in extended mode |
129 | | -g.street_segment(mode='extended', ...) |
130 | | -``` |
131 | | - |
132 | | -#### Interactive Help |
133 | | - |
134 | | -Full function help can be viewed by calling `g.help()`. |
135 | | - |
136 | | -```python |
137 | | -# View an overview of all the functions available: |
138 | | -g.help() |
139 | | - |
140 | | -# View help for an individual function including a description, inputs, outputs, |
141 | | -# and valid modes. |
142 | | -g.address.help() |
143 | | -g.help('address') |
144 | | - |
145 | | -# View a list of all possible inputs to Geosupport |
146 | | -g.help('input') |
147 | | -``` |
148 | | - |
149 | | -#### Error Handling |
150 | | - |
151 | | -python-geosupport will raise a `GeosupportError` when Geosupport returns an |
152 | | -error code. Sometimes there is more information returned, in which case the |
153 | | -exception will have a `result` dictionary. |
154 | | - |
155 | | -```python |
156 | | -from geosupport import GeosupportError |
157 | | - |
158 | | -try: |
159 | | - g.get_street_code(borough='MN', street='Wort Street') |
160 | | -except GeosupportError as e: |
161 | | - print(e) # 'WORT STREET' NOT RECOGNIZED. THERE ARE 010 SIMILAR NAMES. |
162 | | - print(e.result['List of Street Names']) # List of suggested alternate names |
163 | | -``` |
164 | | - |
165 | | -#### Switching Between Multiple Versions of Geosupport |
166 | | - |
167 | | -:heavy_exclamation_mark: *This feature is Windows only. Linux doesn't support |
168 | | -library path modifications during runtime.* |
169 | | - |
170 | | -If you have multiple versions of geosupport and want to switch between them, |
171 | | -you can either pass the installation path to `Geosupport`: |
172 | | - |
173 | | -```python |
174 | | -g = Geosupport(geosupport_path="C:\\Program Files\\Geosupport 18C") |
175 | | -``` |
176 | | - |
177 | | -or create a `.python-geosupport.cfg` in your home directory that specifies |
178 | | -the names and installation paths of the different versions. |
179 | | - |
180 | | -The `.python-geosupport.cfg` file looks like: |
181 | | - |
182 | | -```txt |
183 | | -[versions] |
184 | | -18b=C:\Program Files\Geosupport Desktop Edition |
185 | | -18c=C:\Program Files\Geosupport 18C |
186 | | -18c_32=C:\Program Files (x86)\Geosupport 18C |
187 | | -``` |
188 | | - |
189 | | -Then you can select the version by name: |
190 | | - |
191 | | -```python |
192 | | -g = Geosupport(geosupport_version="18c") |
193 | | -``` |
194 | | - |
195 | | -## Development |
196 | | - |
197 | | -### Running tests |
198 | | -```shell |
199 | | -$ python setup.py test |
200 | | -``` |
201 | | - |
202 | | -Installing the dev dependencies (`nosetests` and `invoke`) will give you more |
203 | | -control over running tests. Install in develop mode with dev dependencies with: |
204 | | - |
205 | | -```shell |
206 | | -$ pip install -e .[dev] |
207 | | -``` |
208 | | - |
209 | | -And then run tests with: |
210 | | - |
211 | | -```shell |
212 | | -$ invoke test unit |
213 | | -$ invoke test functional |
214 | | -$ invoke test all |
215 | | -``` |
216 | | - |
217 | | - |
218 | | - |
219 | 43 | ## License |
220 | 44 |
|
221 | 45 | This project is licensed under the MIT License - see the [license.txt](license.txt) file for details |
|
0 commit comments