Skip to content

Commit

Permalink
updated usage section in README
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bierbower authored and Will Bierbower committed Apr 6, 2015
1 parent 10246c9 commit 52c24c1
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,45 @@ The Raster Class
datatype = gdal.GDT_Float64
nodata_val = -9999.0
# initialize raster
raster = Raster.from_array(array, affine, proj, datatype, nodata_val)
raster = Raster.from_file('path/to/geotiff')
raster.uri # equals '/path/to/geotiff'
raster.get_band(1) # returns 2d numpy array
raster.get_bands() # returns 3d numpy array
raster.get_band(1) # returns 2d numpy masked array
raster.get_bands() # returns 3d numpy masked array
raster.get_nodata() # returns nodata value
raster.shape() # returns 2-tuple (rows, cols)
# Operations
raster3 = raster1.align(raster2)
raster3 = raster1.align_to(raster2)
assert(raster3.is_aligned(raster2))
raster4 = raster3 * raster2
raster4 = raster3 / raster2
raster4 = raster3 + raster2
raster4 = raster3 - raster2
raster4 = raster3 ** raster2
raster4 = raster3 == raster2
raster4 = raster3 * 4.5
raster4 = raster3 / 4.5
raster4 = raster3 + 4.5
raster4 = raster3 - 4.5
raster4 = raster3 ** 4.5
raster4 = raster3.clip('/path/to/aoi_shapefile')
raster4 = raster3.reproject(600613)
reclass_table = {
1: 2,
2: 1
}
raster4 = raster3.reclass(reclass_table)
del test_raster # cleans up temporary file on object deletion or program exit
raster.save_raster('/path/to/dst.tif')
del raster # cleans up temporary file on object deletion or program exit
The RasterFactory Class
Expand All @@ -96,6 +124,28 @@ The RasterFactory Class
test_raster_2 = factory.alternating(0, 1)
test_raster_3 = factory.random()
test_raster_4 = factory.horizontal_ramp(1, 10) # interpolated from 1 to 10 across columns
test_raster_5 = factory.vertical_ramp(1, 10) # interpolated from 1 to 10 across rows
The Vector Class

.. code:: python
from shapely.geometry import *
# set arguments
shapely_object = Polygon([(0, 0), (0, 1), (1, 1)])
proj = 4326
# initialize vector
vector = Vector.from_shapely(shapely_object, proj)
vector = Vector.from_file('/path/to/shapefile')
shapely_object = vector.get_geometry()
vector.save_vector('/path/to/dst.shp')
del vector
Tests
-----
Expand Down

0 comments on commit 52c24c1

Please sign in to comment.