Skip to content

Commit

Permalink
Merge pull request #475 from jbouffard/docs/more-fixes
Browse files Browse the repository at this point in the history
More Formatting Fixes for the Docs
  • Loading branch information
Jacob Bouffard committed Aug 15, 2017
2 parents a3d0975 + 4fc7b2c commit 58cc3e1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
38 changes: 19 additions & 19 deletions docs/guides/core-concepts.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

.. code:: ipython3
.. code:: python3
import datetime
import numpy as np
Expand Down Expand Up @@ -27,7 +27,7 @@ have the ``no_data_value`` of the raster.
**Note**: All rasters in GeoPySpark are represented as having multiple
bands, even if the original raster just contained one.

.. code:: ipython3
.. code:: python3
arr = np.array([[[0, 0, 0, 0],
[1, 1, 1, 1],
Expand All @@ -36,7 +36,7 @@ bands, even if the original raster just contained one.
# The resulting Tile will set -10 as the no_data_value for the raster
gps.Tile.from_numpy_array(numpy_array=arr, no_data_value=-10)
.. code:: ipython3
.. code:: python3
# The resulting Tile will have no no_data_value
gps.Tile.from_numpy_array(numpy_array=arr)
Expand All @@ -53,7 +53,7 @@ box*.
**Note**: The values within the ``Extent`` must be ``float``\ s and not
``double``\ s.

.. code:: ipython3
.. code:: python3
extent = gps.Extent(0.0, 0.0, 10.0, 10.0)
extent
Expand All @@ -65,13 +65,13 @@ ProjectedExtent
in addition to its CRS. Either the EPSG code or a proj4 string can be
used to indicate the CRS of the ``ProjectedExtent``.

.. code:: ipython3
.. code:: python3
# Using an EPSG code
gps.ProjectedExtent(extent=extent, epsg=3857)
.. code:: ipython3
.. code:: python3
# Using a Proj4 String
Expand All @@ -86,7 +86,7 @@ the area on Earth the raster represents, its CRS, and the time the data
was represents. This point of time, called ``instant``, is an instance
of ``datetime.datetime``.

.. code:: ipython3
.. code:: python3
time = datetime.datetime.now()
gps.TemporalProjectedExtent(extent=extent, instant=time, epsg=3857)
Expand All @@ -100,7 +100,7 @@ detail how many columns and rows the grid itself has, respectively.
While ``tileCols`` and ``tileRows`` tell how many columns and rows each
individual raster has.

.. code:: ipython3
.. code:: python3
# Describes a layer where there are four rasters in a 2x2 grid. Each raster has 256 cols and rows.
Expand All @@ -113,7 +113,7 @@ LayoutDefinition
``LayoutDefinition`` describes both how the rasters are orginized in a
layer as well as the area covered by the grid.

.. code:: ipython3
.. code:: python3
layout_definition = gps.LayoutDefinition(extent=extent, tileLayout=tile_layout)
layout_definition
Expand All @@ -138,17 +138,17 @@ of the cells within the rasters.
Rather, it is best used for layers where operations and analysis will be
performed.**

.. code:: ipython3
.. code:: python3
# Creates a LocalLayout where each tile within the grid will be 256x256 pixels.
gps.LocalLayout()
.. code:: ipython3
.. code:: python3
# Creates a LocalLayout where each tile within the grid will be 512x512 pixels.
gps.LocalLayout(tile_size=512)
.. code:: ipython3
.. code:: python3
# Creates a LocalLayout where each tile within the grid will be 256x512 pixels.
gps.LocalLayout(tile_cols=256, tile_rows=512)
Expand All @@ -165,12 +165,12 @@ original raster.
**Note**: This layout strategy **should be used when the resulting layer
is to be dispalyed in a TMS server.**

.. code:: ipython3
.. code:: python3
# Creates a GobalLayout instance with the default values
gps.GlobalLayout()
.. code:: ipython3
.. code:: python3
# Creates a GlobalLayout instance for a zoom of 12
gps.GlobalLayout(zoom=12)
Expand All @@ -190,7 +190,7 @@ represented by a pair of coordinates, ``col`` and ``row``, respectively.
As its name and attributes suggest, ``SpatialKey`` deals solely with
spatial data.

.. code:: ipython3
.. code:: python3
gps.SpatialKey(col=0, row=0)
Expand All @@ -205,7 +205,7 @@ as well as a z value that represents a point in time called,
is also an instance of ``datetime.datetime``. Thus, ``SpaceTimeKey``\ s
deal with spatial-temporal data.

.. code:: ipython3
.. code:: python3
gps.SpaceTimeKey(col=0, row=0, instant=time)
Expand All @@ -218,7 +218,7 @@ either be a ``SpatialKey`` or a ``SpaceTimeKey`` depending on the type
of data within the layer. The ``minKey`` is the left, uppermost cell in
the grid and the ``maxKey`` is the right, bottommost cell.

.. code:: ipython3
.. code:: python3
# Creating a Bounds from SpatialKeys
Expand All @@ -228,7 +228,7 @@ the grid and the ``maxKey`` is the right, bottommost cell.
bounds = gps.Bounds(min_spatial_key, max_spatial_key)
bounds
.. code:: ipython3
.. code:: python3
# Creating a Bounds from SpaceTimeKeys
Expand All @@ -250,7 +250,7 @@ easier means. For ``RasterLayer``, one call the method,
``collect_metadata()`` and ``TiledRasterLayer`` has the attribute,
``layer_metadata``.

.. code:: ipython3
.. code:: python3
# Creates Metadata for a layer with rasters that have a cell type of int16 with the previously defined
# bounds, crs, extent, and layout definition.
Expand Down
16 changes: 8 additions & 8 deletions docs/tutorials/ingesting-an-image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contains elevation data on the east coast of Sri Lanka.
methods shown in this tutorial. However, this could not be done in this
instance due to permission requirements needed to access the file.

.. code:: ipython3
.. code:: python3
!curl -o /tmp/cropped.tif https://s3.amazonaws.com/geopyspark-test/example-files/cropped.tif
Expand All @@ -40,7 +40,7 @@ The Code

With our file downloaded we can begin the ingest.

.. code:: ipython3
.. code:: python3
import geopyspark as gps
Expand All @@ -62,7 +62,7 @@ set a certain way in order for GeoPySpark to work. Thus,
parameters without having to worry about setting the other, required
fields.

.. code:: ipython3
.. code:: python3
conf = gps.geopyspark_conf(master="local[*]", appName="ingest-example")
pysc = SparkContext(conf=conf)
Expand All @@ -74,7 +74,7 @@ After the creation of ``pysc``, we can now read in the data. For this
example, we will be reading in a single GeoTiff that contains spatial
data. Hence, why we set the ``layer_type`` to ``LayerType.SPATIAL``.

.. code:: ipython3
.. code:: python3
raster_layer = gps.geotiff.get(layer_type=gps.LayerType.SPATIAL, uri="file:///tmp/cropped.tif")
Expand All @@ -92,7 +92,7 @@ show it in on a map at some point. Therefore, we have to make sure that
the tiles within the layer are in the right projection. We can do this
by setting the ``target_crs`` parameter.

.. code:: ipython3
.. code:: python3
tiled_raster_layer = raster_layer.tile_to_layout(gps.GlobalLayout(), target_crs=3857)
tiled_raster_layer
Expand All @@ -104,12 +104,12 @@ Now it's time to pyramid! With our reprojected data, we will create an
instance of ``Pyramid`` that contains 12 ``TiledRasterLayer``\ s. Each
one having it's own ``zoom_level`` from 11 to 0.

.. code:: ipython3
.. code:: python3
pyramided_layer = tiled_raster_layer.pyramid()
pyramided_layer.max_zoom
.. code:: ipython3
.. code:: python3
pyramided_layer.levels
Expand All @@ -120,7 +120,7 @@ To save all of the ``TiledRasterLayer``\ s within ``pyramid_layer``, we
just have to loop through values of ``pyramid_layer.level`` and write
each layer locally.

.. code:: ipython3
.. code:: python3
for tiled_layer in pyramided_layer.levels.values():
gps.write(uri="file:///tmp/ingested-image", layer_name="ingested-image", tiled_raster_layer=tiled_layer)
20 changes: 10 additions & 10 deletions docs/tutorials/reading-in-sentinel-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ For more information on the way the data is stored on S3, please see
this
`link <http://sentinel-pds.s3-website.eu-central-1.amazonaws.com/>`__.

.. code:: ipython3
.. code:: python3
!curl -o /tmp/B01.jp2 http://sentinel-s2-l1c.s3.amazonaws.com/tiles/32/T/NM/2017/1/4/0/B01.jp2
!curl -o /tmp/B09.jp2 http://sentinel-s2-l1c.s3.amazonaws.com/tiles/32/T/NM/2017/1/4/0/B09.jp2
Expand All @@ -49,15 +49,15 @@ The Code

Now that we have the files, we can begin to read them into GeoPySpark.

.. code:: ipython3
.. code:: python3
import rasterio
import geopyspark as gps
import numpy as np
from pyspark import SparkContext
.. code:: ipython3
.. code:: python3
conf = gps.geopyspark_conf(master="local[*]", appName="sentinel-ingest-example")
pysc = SparkContext(conf=conf)
Expand All @@ -70,7 +70,7 @@ Once they are read in, we will then combine the three seperate numpy
arrays into one. This combined array represents a single, multiband
raster.

.. code:: ipython3
.. code:: python3
jp2s = ["/tmp/B01.jp2", "/tmp/B09.jp2", "/tmp/B10.jp2"]
arrs = []
Expand All @@ -89,7 +89,7 @@ With our raster data in hand, we can how begin the creation of a Python
``RDD``. Please see the `core concepts <core-concepts.ipynb>`__ guide
for more information on what the following instances represent.

.. code:: ipython3
.. code:: python3
# Create an Extent instance from rasterio's bounds
extent = gps.Extent(*f.bounds)
Expand All @@ -104,23 +104,23 @@ way rasterio formats the projection of the read in rasters is not
compatible with how GeoPySpark expects the ``CRS`` to be in. Thus, we
had to do a bit of extra work to get it into the correct state

.. code:: ipython3
.. code:: python3
# Projection information from the rasterio file
f.crs.to_dict()
.. code:: ipython3
.. code:: python3
# The projection information formatted to work with GeoPySpark
int(f.crs.to_dict()['init'][5:])
.. code:: ipython3
.. code:: python3
# We can create a Tile instance from our multiband, raster array and the nodata value from rasterio
tile = gps.Tile.from_numpy_array(numpy_array=data, no_data_value=f.nodata)
tile
.. code:: ipython3
.. code:: python3
# Now that we have our ProjectedExtent and Tile, we can create our RDD from them
rdd = pysc.parallelize([(projected_extent, tile)])
Expand All @@ -132,7 +132,7 @@ Creating the Layer
From the ``RDD``, we can now create a ``RasterLayer`` using the
``from_numpy_rdd`` method.

.. code:: ipython3
.. code:: python3
# While there is a time component to the data, this was ignored for this tutorial and instead the focus is just
# on the spatial information. Thus, we have a LayerType of SPATIAL.
Expand Down

0 comments on commit 58cc3e1

Please sign in to comment.