Skip to content

Commit

Permalink
Fix docs so that the home page refers to index
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenpawley committed Jun 1, 2024
1 parent 65993e0 commit 85ce5f0
Show file tree
Hide file tree
Showing 22 changed files with 94 additions and 219 deletions.
2 changes: 1 addition & 1 deletion _freeze/docs/geoprocessing/execute-results/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"hash": "5f253fe0d4b07a283614d077bb8a5e51",
"result": {
"engine": "jupyter",
"markdown": "---\ntitle: Raster Geoprocessing\nformat:\n html:\n code-fold: false\n toc: true\n---\n\nPyspatialml includes common geoprocessing methods that collectively operate on\nstacks of raster datasets, such as cropping, reprojecting, masking etc. Most\nof these methods are simple wrappers around underlying rasterio functions, but\napplied to stacks of raster datasets.\n\n## Handling of Temporary Files\n\nAll of the geoprocessing methods have a `file_path` parameter to specify a file\npath to save the results of th geoprocessing operation. However, pyspatialml is\ndesigned for quick an interactive analyses on raster datasets, and if a file\npath is not specified then the results are saved to a temporary file location\nand a new Raster object is returned with the geoprocessing results.\n\nFor datasets that will easily fit into memory, all geoprocessing methods also\nhave an `in_memory` parameter. If `in_memory=True` is set, then the results\nwill be created using Rasterio's in-memory files and stored in RAM. This has\nperformance advantages, at the expense of memory expenditure.\n\n## Cropping\n\nAll layers within a Raster can be cropped to a new extent using the\n`Raster.crop` method.\n\n::: {#ea62e8fb .cell execution_count=1}\n``` {.python .cell-code}\nimport geopandas as gpd\nimport matplotlib.pyplot as plt\nfrom pyspatialml import Raster\nfrom pyspatialml.datasets import nc\n\npredictors = [nc.band1, nc.band2, nc.band3, nc.band4, nc.band5, nc.band7]\ntraining_py = gpd.read_file(nc.polygons)\n\nstack = Raster(predictors)\n\nstack.plot()\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![](geoprocessing_files/figure-html/cell-2-output-1.png){width=604 height=372}\n:::\n:::\n\n\n::: {#27da6008 .cell execution_count=2}\n``` {.python .cell-code}\n# crop to new extent (xmin, ymin, xmax, ymax)\ncrop_bounds = training_py.loc[0, \"geometry\"].bounds\nstack_cropped = stack.crop(crop_bounds)\n\nstack_cropped.plot()\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![](geoprocessing_files/figure-html/cell-3-output-1.png){width=604 height=370}\n:::\n:::\n\n\n## Masking\n\nIn comparison to cropping, masking can be used to set pixels that occur outside\nof masking geometries to NaN, and optionally can also crop a Raster.\n\n::: {#62aa311f .cell execution_count=3}\n``` {.python .cell-code}\nimport geopandas as gpd\nimport pyspatialml.datasets.nc as nc\nfrom pyspatialml import Raster\n\ntraining_py = gpd.read_file(nc.polygons)\nmask_py = training_py.iloc[0:1, :]\n\npredictors = [nc.band1, nc.band2, nc.band3, nc.band4, nc.band5, nc.band7]\nstack = Raster(predictors)\n\n# mask a Raster\nmasked_object = stack.mask(mask_py)\n```\n:::\n\n\n## Intersecting Layers\n\nThe `Raster.intersect` method computes the geometric intersection of the\nRasterLayers with the Raster object. This will cause nodata values in any of\nthe rasters to be propagated through all of the output rasters.\n\n::: {#95547375 .cell execution_count=4}\n``` {.python .cell-code}\nimport pyspatialml.datasets.nc as nc\nfrom pyspatialml import Raster\n\npredictors = [nc.band1, nc.band2, nc.band3, nc.band4, nc.band5, nc.band7]\nstack = Raster(predictors)\n\nresult = stack.intersect()\n```\n:::\n\n\nThe intersect method is memory-safe, i.e. the intersection occurs during\nwindowed reading and writing of the Raster. The size and dimensions of the\nwindows can be changed using the `Raster.block_shapes` property.\n\n## Reprojecting\n\nReprojecting a raster using the `Raster.to_crs` method.\n\n::: {#7f381ff1 .cell execution_count=5}\n``` {.python .cell-code}\nstack_prj = stack.to_crs(crs={\"init\": \"EPSG:4326\"})\n```\n:::\n\n\nOther parameters that can be passed and their defaults are\nresampling=\"nearest\", file_path=None, driver=\"GTiff\", nodata=None, n_jobs=1,\nwarp_mem_lim=0, progress=False, and other kwargs that are passed to the raster\nformat drivers.\n\n## Resampling\n\nThe `Raster.aggregate` method is used to resample a raster to a different\nresolution using the decimated reading approach in the rasterio library.\n\n::: {#ea8062fa .cell execution_count=6}\n``` {.python .cell-code}\nstack.aggregate(out_shape=(50, 50), resampling=\"nearest\", driver=\"GTiff\")\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRaster Object Containing 6 Layers\n attribute values\n0 names [lsat7_2000_10, lsat7_2000_20, lsat7_2000_30, ...\n1 files [/var/folders/_m/kbp8r1612yj1xl6ndb2y8vpm0000g...\n2 rows 50\n3 cols 50\n4 res (278.73, 252.51)\n5 nodatavals [-3.4028234663852886e+38, -3.4028234663852886e...\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=6}\n```\n\n```\n:::\n:::\n\n\n## Computation\n\nApply user-supplied function to a Raster object.\n\n::: {#7bb1d342 .cell execution_count=7}\n``` {.python .cell-code}\ndef myfun(x):\n return x + 1\n\nstack.apply(myfun)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRaster Object Containing 6 Layers\n attribute values\n0 names [tmpsdyk3x5h_1, tmpsdyk3x5h_2, tmpsdyk3x5h_3, ...\n1 files [/var/folders/_m/kbp8r1612yj1xl6ndb2y8vpm0000g...\n2 rows 443\n3 cols 489\n4 res (28.5, 28.5)\n5 nodatavals [-3.4028234663852886e+38, -3.4028234663852886e...\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=7}\n```\n\n```\n:::\n:::\n\n\nWhere `function` is a user-defined python that takes an numpy array as a\nsingle argument, and can return either a 2d array that represents a single\nraster dataset, such as NDVI, or can operate on a number of layers and can\nreturn a raster with multiple layers in a 3d array in (layer, row, col)\norder.\n\nThe apply function is memory-safe, i.e. it applies the function to windows\nof the raster data that are read sequentially or in parallel\n(with n_jobs != 1). The size and dimensions of the windows can be changed\nusing the `Raster.block_shapes` property.\n\n## Raster Algebra\n\nRasterLayer objects also support basic raster math operations using python's\nmagic methods, which supports all of the usual math operators. Calculations\non RasterLayers occur in memory using Rasterio's in-memory files, thus they\nare not memory safe. For applying computations and algebra to large raster\ndatasets in windows, use `Raster.apply()`.\n\n::: {#ecdd3638 .cell execution_count=8}\n``` {.python .cell-code}\na = stack.iloc[0] + stack.iloc[1]\nb = stack.iloc[0] - stack.iloc[1]\n\nndvi = (stack.iloc[3] - stack.iloc[2]) / (stack.iloc[3] + stack.iloc[2])\n```\n:::\n\n\nArithmetic operations on RasterLayer's will return another RasterLayer. The\nresult can be coerced into a Raster object using:\n\n::: {#801a16a6 .cell execution_count=9}\n``` {.python .cell-code}\nndvi = Raster((stack.iloc[3] - stack.iloc[2]) / (stack.iloc[3] + stack.iloc[2]))\n```\n:::\n\n\nArithmetic operations are only supported on RasterLayer objects and\nnot in a parent Raster object directly.\n\n",
"markdown": "---\ntitle: Raster Geoprocessing\nformat:\n html:\n code-fold: false\n toc: true\n---\n\nPyspatialml includes common geoprocessing methods that collectively operate on\nstacks of raster datasets, such as cropping, reprojecting, masking etc. Most\nof these methods are simple wrappers around underlying rasterio functions, but\napplied to stacks of raster datasets.\n\n## Handling of Temporary Files\n\nAll of the geoprocessing methods have a `file_path` parameter to specify a file\npath to save the results of th geoprocessing operation. However, pyspatialml is\ndesigned for quick an interactive analyses on raster datasets, and if a file\npath is not specified then the results are saved to a temporary file location\nand a new Raster object is returned with the geoprocessing results.\n\nFor datasets that will easily fit into memory, all geoprocessing methods also\nhave an `in_memory` parameter. If `in_memory=True` is set, then the results\nwill be created using Rasterio's in-memory files and stored in RAM. This has\nperformance advantages, at the expense of memory expenditure.\n\n## Cropping\n\nAll layers within a Raster can be cropped to a new extent using the\n`Raster.crop` method.\n\n::: {#70f3733f .cell execution_count=1}\n``` {.python .cell-code}\nimport geopandas as gpd\nimport matplotlib.pyplot as plt\nfrom pyspatialml import Raster\nfrom pyspatialml.datasets import nc\n\npredictors = [nc.band1, nc.band2, nc.band3, nc.band4, nc.band5, nc.band7]\ntraining_py = gpd.read_file(nc.polygons)\n\nstack = Raster(predictors)\n\nstack.plot()\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![](geoprocessing_files/figure-html/cell-2-output-1.png){width=604 height=372}\n:::\n:::\n\n\n::: {#d43b4f2d .cell execution_count=2}\n``` {.python .cell-code}\n# crop to new extent (xmin, ymin, xmax, ymax)\ncrop_bounds = training_py.loc[0, \"geometry\"].bounds\nstack_cropped = stack.crop(crop_bounds)\n\nstack_cropped.plot()\nplt.show()\n```\n\n::: {.cell-output .cell-output-display}\n![](geoprocessing_files/figure-html/cell-3-output-1.png){width=604 height=370}\n:::\n:::\n\n\n## Masking\n\nIn comparison to cropping, masking can be used to set pixels that occur outside\nof masking geometries to NaN, and optionally can also crop a Raster.\n\n::: {#33fabaa0 .cell execution_count=3}\n``` {.python .cell-code}\nimport geopandas as gpd\nimport pyspatialml.datasets.nc as nc\nfrom pyspatialml import Raster\n\ntraining_py = gpd.read_file(nc.polygons)\nmask_py = training_py.iloc[0:1, :]\n\npredictors = [nc.band1, nc.band2, nc.band3, nc.band4, nc.band5, nc.band7]\nstack = Raster(predictors)\n\n# mask a Raster\nmasked_object = stack.mask(mask_py)\n```\n:::\n\n\n## Intersecting Layers\n\nThe `Raster.intersect` method computes the geometric intersection of the\nRasterLayers with the Raster object. This will cause nodata values in any of\nthe rasters to be propagated through all of the output rasters.\n\n::: {#d7a7ebe7 .cell execution_count=4}\n``` {.python .cell-code}\nimport pyspatialml.datasets.nc as nc\nfrom pyspatialml import Raster\n\npredictors = [nc.band1, nc.band2, nc.band3, nc.band4, nc.band5, nc.band7]\nstack = Raster(predictors)\n\nresult = stack.intersect()\n```\n:::\n\n\nThe intersect method is memory-safe, i.e. the intersection occurs during\nwindowed reading and writing of the Raster. The size and dimensions of the\nwindows can be changed using the `Raster.block_shapes` property.\n\n## Reprojecting\n\nReprojecting a raster using the `Raster.to_crs` method.\n\n::: {#8f71eb11 .cell execution_count=5}\n``` {.python .cell-code}\nstack_prj = stack.to_crs(crs={\"init\": \"EPSG:4326\"})\n```\n:::\n\n\nOther parameters that can be passed and their defaults are\nresampling=\"nearest\", file_path=None, driver=\"GTiff\", nodata=None, n_jobs=1,\nwarp_mem_lim=0, progress=False, and other kwargs that are passed to the raster\nformat drivers.\n\n## Resampling\n\nThe `Raster.aggregate` method is used to resample a raster to a different\nresolution using the decimated reading approach in the rasterio library.\n\n::: {#1452d771 .cell execution_count=6}\n``` {.python .cell-code}\nstack.aggregate(out_shape=(50, 50), resampling=\"nearest\", driver=\"GTiff\")\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRaster Object Containing 6 Layers\n attribute values\n0 names [lsat7_2000_10, lsat7_2000_20, lsat7_2000_30, ...\n1 files [/var/folders/_m/kbp8r1612yj1xl6ndb2y8vpm0000g...\n2 rows 50\n3 cols 50\n4 res (278.73, 252.51)\n5 nodatavals [-3.4028234663852886e+38, -3.4028234663852886e...\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=6}\n```\n\n```\n:::\n:::\n\n\n## Computation\n\nApply user-supplied function to a Raster object.\n\n::: {#ac19dac5 .cell execution_count=7}\n``` {.python .cell-code}\ndef myfun(x):\n return x + 1\n\nstack.apply(myfun)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nRaster Object Containing 6 Layers\n attribute values\n0 names [tmp0n2yd7no_1, tmp0n2yd7no_2, tmp0n2yd7no_3, ...\n1 files [/var/folders/_m/kbp8r1612yj1xl6ndb2y8vpm0000g...\n2 rows 443\n3 cols 489\n4 res (28.5, 28.5)\n5 nodatavals [-3.4028234663852886e+38, -3.4028234663852886e...\n```\n:::\n\n::: {.cell-output .cell-output-display execution_count=7}\n```\n\n```\n:::\n:::\n\n\nWhere `function` is a user-defined python that takes an numpy array as a\nsingle argument, and can return either a 2d array that represents a single\nraster dataset, such as NDVI, or can operate on a number of layers and can\nreturn a raster with multiple layers in a 3d array in (layer, row, col)\norder.\n\nThe apply function is memory-safe, i.e. it applies the function to windows\nof the raster data that are read sequentially or in parallel\n(with n_jobs != 1). The size and dimensions of the windows can be changed\nusing the `Raster.block_shapes` property.\n\n## Raster Algebra\n\nRasterLayer objects also support basic raster math operations using python's\nmagic methods, which supports all of the usual math operators. Calculations\non RasterLayers occur in memory using Rasterio's in-memory files, thus they\nare not memory safe. For applying computations and algebra to large raster\ndatasets in windows, use `Raster.apply()`.\n\n::: {#a90b8434 .cell execution_count=8}\n``` {.python .cell-code}\na = stack.iloc[0] + stack.iloc[1]\nb = stack.iloc[0] - stack.iloc[1]\n\nndvi = (stack.iloc[3] - stack.iloc[2]) / (stack.iloc[3] + stack.iloc[2])\n```\n:::\n\n\nArithmetic operations on RasterLayer's will return another RasterLayer. The\nresult can be coerced into a Raster object using:\n\n::: {#0ce834ce .cell execution_count=9}\n``` {.python .cell-code}\nndvi = Raster((stack.iloc[3] - stack.iloc[2]) / (stack.iloc[3] + stack.iloc[2]))\n```\n:::\n\n\nArithmetic operations are only supported on RasterLayer objects and\nnot in a parent Raster object directly.\n\n",
"supporting": [
"geoprocessing_files"
],
Expand Down
12 changes: 0 additions & 12 deletions _freeze/docs/index/execute-results/html.json

This file was deleted.

2 changes: 1 addition & 1 deletion _freeze/docs/installation/execute-results/html.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"hash": "65228f7d1a193c5cace2c9a9607b0799",
"result": {
"engine": "jupyter",
"markdown": "---\ntitle: Installation\nformat:\n html:\n code-fold: false\n---\n\nPyspatialml is available on PyPI and can be installed in the usual manner with:\n\n::: {#c5a4b2b4 .cell execution_count=1}\n``` {.python .cell-code}\npip install Pyspatialml\n```\n:::\n\n\nThe development version, which is more up-to-date with changes to the package\nespecially during these earlier stages of development, can be installed\ndirectly via:\n\n::: {#3b8af2ce .cell execution_count=2}\n``` {.python .cell-code}\npip install git+https://github.com/stevenpawley/Pyspatialml\n```\n:::\n\n\n",
"markdown": "---\ntitle: Installation\nformat:\n html:\n code-fold: false\n---\n\nPyspatialml is available on PyPI and can be installed in the usual manner with:\n\n::: {#bb02f017 .cell execution_count=1}\n``` {.python .cell-code}\npip install Pyspatialml\n```\n:::\n\n\nThe development version, which is more up-to-date with changes to the package\nespecially during these earlier stages of development, can be installed\ndirectly via:\n\n::: {#66ac18c4 .cell execution_count=2}\n``` {.python .cell-code}\npip install git+https://github.com/stevenpawley/Pyspatialml\n```\n:::\n\n\n",
"supporting": [
"installation_files"
],
Expand Down
2 changes: 1 addition & 1 deletion _freeze/docs/landcover/execute-results/html.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 85ce5f0

Please sign in to comment.