Creating an NDVI image is easy by adapting a query that Manifold writes for you using the Edit Query button. I posted some notes on that here, but that commentary is buried in a thread under a different name. Here is a generic query that creates an NDVI raster from a four band image where the fourth band is near Infrared, like the NAIP images. To use it, change the name of your source image at the spot where the comment says to do so in the query, and run it. It creates an "NDVI Image" and its table, and styles that image using the USDA Crop Explorer palette. The query has two other palettes that can be used by commenting out the USDA palette and un-commenting the desired palette. I've attached an mxb with the query (no image, just the queries). Here is the query text (reformatted to better fit into the forum... use the original from the project): -- $manifold$ -- -- Create NDVI from Four Band, BGRir Image -- -- Names the result NDVI Image -- -- Uncomment one of the ADD PROPERTY lines for the palette desired in the result -- -- CREATE TABLE [NDVI] ( [X] INT32, [Y] INT32, [Tile] TILE, [mfd_id] INT64, INDEX [mfd_id_x] BTREE ([mfd_id]), INDEX [Y_X_x] BTREE ([Y], [X]), INDEX [X_Y_Tile_x] RTREE ([X], [Y], [Tile] TILESIZE (128, 128) TILETYPE FLOAT64), PROPERTY 'FieldCoordSystem.Tile' 'EPSG:26910,mfd:{ "LocalOffsetX": 552708, "LocalOffsetY": 4490226, "LocalScaleX": 0.6, "LocalScaleY": 0.6 }', PROPERTY 'FieldTileSize.Tile' '[ 128, 128 ]', PROPERTY 'FieldTileType.Tile' 'float64' ); CREATE IMAGE [NDVI Image] ( PROPERTY 'Table' '[NDVI]', PROPERTY 'FieldTile' 'Tile', PROPERTY 'FieldX' 'X', PROPERTY 'FieldY' 'Y', PROPERTY 'Rect' '[ 0, 0, 9410, 12140 ]' ); ALTER IMAGE [NDVI Image] ( -- Use USDA Crop Explorer palette ADD PROPERTY 'StylePixel' '{ "Channel": 0, "Fill": "boundaverage", "Value": 15183459, "Values": { "0": 15183459, "0.1": 16769940, "0.2": 15204269, "0.3": 10289052, "0.4": 6553443, "0.5": 3264305, "0.6": 39424, "0.7": 25856 } }' -- Use classic palette -- ADD PROPERTY 'StylePixel' '{ "Channel": 0, "Fill": "boundaverage", "Value": 14102567, "Values": { "0": 14102567, "0.1": 16018755, "0.2": 16625249, "0.3": 16703627, "0.4": 14282635, "0.5": 10934634, "0.6": 6733155, "0.7": 1742928 } }' -- Use leaf palette -- ADD PROPERTY 'StylePixel' '{ "Channel": 0, "Fill": "boundaverage", "Value": 4333842, "Values": { "-0.31": 4333842, "0.05": 10441002, "0.16": 13412885, "0.25": 16580099, "0.3": 15068672, "0.35": 13688576, "0.4": 12177152, "0.45": 10665984, "0.5": 9154560, "0.55": 7708160, "0.6": 6196736, "0.65": 4554752, "0.7": 2977792, "0.75": 1532160, "0.8": 20992 } }' ); PRAGMA ('progress.percentnext' = '100'); INSERT INTO [NDVI] ( [X], [Y], [Tile] ) SELECT [X], [Y], CASTV (((TileChannel([Tile], 3) - TileChannel([Tile], 2 )) / (TileChannel([Tile], 3) + TileChannel([Tile], 2 ))) AS FLOAT64) FROM [m_4012230_nw_10_h_20160717] -- Change the name in [ ] to the source image name. Use the image name, not the table. THREADS SystemCpuCount(); TABLE CALL TileUpdatePyramids([NDVI Image]); Enjoy! Attachments: Example NDVI query.mxb
|