Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.

Commit 29118e9

Browse files
committed
Merge branch 'release/0.2.0'
2 parents bd28bc6 + 48ff819 commit 29118e9

20 files changed

+1907
-236
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,5 @@ ENV/
9696

9797
# mkdocs documentation
9898
/site
99+
/.idea/
100+
/raster-foundry-python-client.iml

CHANGELOG.rst

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
0.2.0
2+
-----
3+
4+
- Make imports in api.py relative (#20)
5+
- Improve scene search and spec cleanup (#18)
6+
- Support local file uploads (#15)
7+
- Add scenes post body parameters to spec (#13)
8+
- Include token with api request (#12)
9+
- Fix install for Mac OS (#9)
10+
- Add convenience methods for exports and visualization to projects (#4)
11+
- Add leaflet support to project model (#2)
12+
113
0.1.0
214
-----
315

MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ include LICENSE.txt
33
include CHANGELOG.rst
44

55
recursive-include tests *
6+
recursive-include examples *.ipynb
7+
recursive-include scripts *

examples/Projects.ipynb

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Interacting with projects"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {},
14+
"outputs": [],
15+
"source": [
16+
"from rasterfoundry.api import API\n",
17+
"refresh_token = '<your refresh token>'\n",
18+
"api = API(refresh_token=refresh_token)"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"## List projects\n",
26+
"\n",
27+
"If you have access to any projects, `api.projects` will return them as a list."
28+
]
29+
},
30+
{
31+
"cell_type": "code",
32+
"execution_count": null,
33+
"metadata": {},
34+
"outputs": [],
35+
"source": [
36+
"projects = api.projects\n",
37+
"projects"
38+
]
39+
},
40+
{
41+
"cell_type": "markdown",
42+
"metadata": {},
43+
"source": [
44+
"## Display a project\n",
45+
"\n",
46+
"You can choose one of your projects with ingested scenes and add it to a leaflet map\n",
47+
"in the browser."
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {
54+
"collapsed": true
55+
},
56+
"outputs": [],
57+
"source": [
58+
"# Change the index in projects[3] to a value within your list of projects\n",
59+
"project1 = projects[3]\n",
60+
"m = project1.get_map()\n",
61+
"project1.add_to(m)\n",
62+
"m"
63+
]
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"## Compare two projects\n",
70+
"\n",
71+
"If you have two projects with ingested scenes and in the same area, you can compare them with a slider."
72+
]
73+
},
74+
{
75+
"cell_type": "code",
76+
"execution_count": null,
77+
"metadata": {
78+
"collapsed": true
79+
},
80+
"outputs": [],
81+
"source": [
82+
"# Change the index in projects[4] to a value within your list of projects\n",
83+
"project2 = projects[4]\n",
84+
"m2 = project2.get_map()\n",
85+
"project1.compare(project2, m2)\n",
86+
"m2"
87+
]
88+
},
89+
{
90+
"cell_type": "markdown",
91+
"metadata": {},
92+
"source": [
93+
"# Project export"
94+
]
95+
},
96+
{
97+
"cell_type": "markdown",
98+
"metadata": {},
99+
"source": [
100+
"## Export as PNG"
101+
]
102+
},
103+
{
104+
"cell_type": "code",
105+
"execution_count": null,
106+
"metadata": {
107+
"collapsed": true,
108+
"scrolled": true
109+
},
110+
"outputs": [],
111+
"source": [
112+
"from IPython.display import Image\n",
113+
"project = api.projects[3]\n",
114+
"bbox = '-121.726057,37.278423,-121.231672,37.377250'\n",
115+
"Image(project.png(bbox))"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": null,
121+
"metadata": {
122+
"collapsed": true
123+
},
124+
"outputs": [],
125+
"source": [
126+
"Image(project.png(bbox, zoom=15))"
127+
]
128+
},
129+
{
130+
"cell_type": "markdown",
131+
"metadata": {},
132+
"source": [
133+
"## Export as GeoTIFF"
134+
]
135+
},
136+
{
137+
"cell_type": "markdown",
138+
"metadata": {},
139+
"source": [
140+
"### Display in the notebook\n",
141+
"\n",
142+
"Note: this example requires\n",
143+
"[`numpy`](http://www.numpy.org/),\n",
144+
"[`matplotlib`](http://matplotlib.org/), and a fairly recent version of\n",
145+
"[`rasterio`](https://mapbox.github.io/rasterio/).\n",
146+
"\n",
147+
"If you don't have them, you can run the cell at the bottom of this notebook,\n",
148+
"provided your pip installation directory is writable."
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": null,
154+
"metadata": {},
155+
"outputs": [],
156+
"source": [
157+
"from rasterio.io import MemoryFile\n",
158+
"import matplotlib.pyplot as plt\n",
159+
"project = api.projects[3]\n",
160+
"bbox = '-121.726057,37.278423,-121.231672,37.377250'\n",
161+
"data = project.geotiff(bbox, zoom=17)\n",
162+
"\n",
163+
"with MemoryFile(data) as memfile:\n",
164+
" with memfile.open() as dataset:\n",
165+
" plt.imshow(dataset.read(1), cmap='RdBu')\n",
166+
" \n",
167+
"plt.show()"
168+
]
169+
},
170+
{
171+
"cell_type": "markdown",
172+
"metadata": {},
173+
"source": [
174+
"### Save as a file"
175+
]
176+
},
177+
{
178+
"cell_type": "code",
179+
"execution_count": null,
180+
"metadata": {},
181+
"outputs": [],
182+
"source": [
183+
"project = api.projects[3]\n",
184+
"bbox = '-121.726057,37.278423,-121.231672,37.377250'\n",
185+
"data = project.geotiff(bbox, zoom=17)\n",
186+
"with open('sample.tiff', 'wb') as outf:\n",
187+
" outf.write(data)"
188+
]
189+
},
190+
{
191+
"cell_type": "markdown",
192+
"metadata": {},
193+
"source": [
194+
"# Installs"
195+
]
196+
},
197+
{
198+
"cell_type": "code",
199+
"execution_count": null,
200+
"metadata": {
201+
"collapsed": true
202+
},
203+
"outputs": [],
204+
"source": [
205+
"%%bash\n",
206+
"pip install numpy matplotlib rasterio==1.0a8"
207+
]
208+
}
209+
],
210+
"metadata": {
211+
"kernelspec": {
212+
"display_name": "Python 2",
213+
"language": "python",
214+
"name": "python2"
215+
},
216+
"language_info": {
217+
"codemirror_mode": {
218+
"name": "ipython",
219+
"version": 2
220+
},
221+
"file_extension": ".py",
222+
"mimetype": "text/x-python",
223+
"name": "python",
224+
"nbconvert_exporter": "python",
225+
"pygments_lexer": "ipython2",
226+
"version": "2.7.12"
227+
}
228+
},
229+
"nbformat": 4,
230+
"nbformat_minor": 2
231+
}

0 commit comments

Comments
 (0)