Skip to content

Commit

Permalink
DOC: Add getting started page (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Oct 12, 2020
1 parent 67789e0 commit ec2dd37
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 20 deletions.
42 changes: 42 additions & 0 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Getting Started
================

`geocube` combines the interfaces of:

- `geopandas <https://github.com/geopandas/geopandas>`__
- `xarray <https://github.com/pydata/xarray>`__
- `rioxarray <https://github.com/corteva/rioxarrau>`__

and is powered by `GDAL <https://github.com/osgeo/gdal>`__ using:

- `rasterio <https://github.com/mapbox/rasterio>`__
- `fiona <https://github.com/toblerity/fiona>`__


When getting started, the API documentation to start reading would be :func:`geocube.api.core.make_geocube`.

The simplest example would be to rasterize a single column:

.. code-block:: python
from geocube.api.core import make_geocube
out_grid = make_geocube(
vector_data="path_to_file.gpkg",
measurements=["column_name"].
resolution=(-0.0001, 0.0001),
)
out_grid["column_name"].rio.to_raster("my_rasterized_column.tif")
You can also rasterize a `GeoDataFrame <https://geopandas.readthedocs.io/en/latest/docs/user_guide/data_structures.html#geodataframe>`__
directly in the `vector_data` argument. This enables you to `load in subsets of data <https://geopandas.readthedocs.io/en/latest/docs/user_guide/io.html#reading-subsets-of-the-data>`__
or perform various operations before rasterization.

Once finished, you can write to anything supported by `rasterio <https://github.com/mapbox/rasterio>`__
using `rioxarray`'s `rio.to_raster() <https://corteva.github.io/rioxarray/stable/examples/convert_to_raster.html>`__ method.
You can also write to a netCDF file using `xarray`'s `to_netcdf() <http://xarray.pydata.org/en/stable/generated/xarray.Dataset.to_netcdf.html>`__.

However, life is only this simple when your data is perfectly clean, geospatially unique, and numeric.
The good news is that geocube supports a variety of use cases and custom rasterization functions if your dataset
does not meet these criteria (see: :ref:`usage_examples`).
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ GitHub: http://github.com/corteva/geocube

readme
installation
getting_started
examples/examples
modules
contributing
Expand Down
36 changes: 16 additions & 20 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,37 @@ Stable release
Use pip to install from `PyPI <https://pypi.org/project/geocube/>`__:


Step 1: Install python GDAL version associated with your GDAL version.
Install from pip:

Here is a Linux example with GDAL installed in your system:
.. code-block:: bash
.. code-block:: bash
pip install geocube
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip install GDAL~=$(gdal-config --version | awk -F'[.]' '{print $1"."$2}').0
Step 2: Install from pip:
Use `conda <https://conda.io/en/latest/>`__ with the `conda-forge <https://conda-forge.org/>`__ channel:

.. code-block:: bash
.. code-block:: bash
pip install geocube
conda install -c conda-forge geocube
2. Use `conda <https://conda.io/en/latest/>`__ with the `conda-forge <https://conda-forge.org/>`__ channel:

.. code-block:: bash
From source
-----------

conda install -c conda-forge geocube
The source for geocube can be installed from the `GitHub repo`_.

.. code-block:: bash
From source
-----------
python -m pip install git+git://github.com/corteva/geocube.git#egg=geocube
The source for geocube can be downloaded from the `GitHub repo`_.
.. code-block:: console
To install for local development:

$ git clone git@github.com:corteva/geocube.git
.. code-block:: bash
$ cd geocube
$ python setup.py install
git clone git@github.com:corteva/geocube.git
cd geocube
python -m pip install -e .[dev]
.. _GitHub repo: https://github.com/corteva/geocube

0 comments on commit ec2dd37

Please sign in to comment.