shape2georaster

From DavinciWiki
Jump to: navigation, search

Description

Overlay a GeoShape-Struct on a Geo-Struct. The GeoShape-Struct will be transformed into the Geo-Struct projection

This function relies on GDAL > 1.8.

Arguments and Return Values

Arguments: A davinci GeoShape-Struct and a Geo-Struct

Return Value: A rasterized shape in the Geo-Struct

Usage

Syntax: proj_geoshape(GeoShape-Struct, Geo-Struct [,s_srs_shape=STRING][,s_srs_image=STRING][,inverse=BOOL][,value=STRING][,ignore=VAL][,color=VAL][,gradient=VAL][,in_low=VAL][,in_high=VAL][,hsv=BOOL])

GeoShape-Struct = davinci GeoShape-Struct (in assumed latlong coordinates)

Geo-Struct = davinci Geo-Struct (in any projection)

a_srs_shape=projection of the shapefile (Default='+proj=latlong units=deg')

a_srs_image=projection of the image (Default=Geo-Struct projection)

inverse=leave everything but the shape (Useful for masking, Default=0)

value=GeoShape-Struct element to map to each shape (Default="")

ignore=override Geo-Struct .ignore value, if outside the data type then min(data) will be used

color=translate the shape overlay into a color (Default=255/255/255)

gradient=turn the value data into a gradient, maps to colors option in colorize() (Default=0)

in_low=low data input value for gradient mapping (Default=min value w/ignore)

in_high=high data input value for gradient mapping (Default=max value)

hsv=HSV composite overlay the output shape on the input (byte, single band) data (Default=0)

Examples

dv> shape=read_geoshape($DV_EX+"/test_shape.csv")
Downloading.done.
struct, 5 elements
   feature_string: Text Buffer with 2 lines of text
       1: polygon
       2: polygon
   mola_elevation_double: 1x2x1 array of float, bsq format [8 bytes]
   line_color_color: Text Buffer with 2 lines of text
       1: 0 255 255
       2: 204 0 0
   fill_color_color: Text Buffer with 2 lines of text
       1: 153 0 153
       2: 0 0 255
   wkt: Text Buffer with 2 lines of text
       1: POLYGON ((5.59375 9.4375, 3.1875 8.15625, 3.1875 6.15625, 3.9375 4.03125,\
        5.65625 3.90625, 6.28125 5.125, 6.21875 7.0625, 6.09375 9, 5.59375 9.4375))
       2: POLYGON ((12.375 11.5625, 10.15625 11.96875, 8.8125 10.71875, 8.0625 9.1875,\
        8.1875 8, 9.34375 7.3125, 10.28125 8.125, 10.625 8.9375, 11.6875 9.21875, 12.25 8.875,\
        12.875 8.9375, 13.09375 9.59375, 13.09375 10.34375, 12.375 11.5625))

dv> geostruct=read_geo($DV_EX+"/test_geo.tiff")
Downloading.........done.
struct, 14 elements
   anc: struct, 10 elements
       wkt: Text Buffer with 14 lines of text
           1: PROJCS["unnamed",
           2:     GEOGCS["unnamed ellipse",
           3:         DATUM["unknown",
           4:             SPHEROID["unnamed",3396190,0]],
           5:         PRIMEM["Greenwich",0],
           6:         UNIT["degree",0.0174532925199433]],
           7:     PROJECTION["Equirectangular"],
           8:     PARAMETER["latitude_of_origin",0],
           9:     PARAMETER["central_meridian",0],
           10:     PARAMETER["standard_parallel_1",0],
       metadata: struct, 1 elements...
       proj4: "'+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs '"
       origin: 1x2x1 array of double, bsq format [16 bytes]
       pixel_size: 1x2x1 array of double, bsq format [16 bytes]
       lat: 1x5x1 array of float, bsq format [20 bytes]
       lon: 1x5x1 array of float, bsq format [20 bytes]
       lpo: 1x5x1 array of float, bsq format [20 bytes]
       spo: 1x5x1 array of float, bsq format [20 bytes]
       center: 2x1x1 array of float, bsq format [8 bytes]
   ignore: -32768.00000
   projection: "Equirectangular"
   spheroid: struct, 3 elements
       name: "unnamed"
       radius: "3396190"
       iflattening: "0"
   resolution: 1852.334351
   x: 0.000000000
   y: 640.0000000
   ul: 2x1x1 array of float, bsq format [8 bytes]
   ur: 2x1x1 array of float, bsq format [8 bytes]
   ll: 2x1x1 array of float, bsq format [8 bytes]
   lr: 2x1x1 array of float, bsq format [8 bytes]
   w: 640
   h: 640
   data: 640x640x1 array of float, bsq format [1,638,400 bytes]

dv> geostruct.data=sstretch(geostruct.data)
640x640x1 array of byte, bip format [409,600 bytes]

Usage 1: set the shapes to a color

dv> color=shape2georaster(shape,geostruct,ignore=0,color=255//255//0)
Writing /tmp/dv_24039/gdal_raster.proj.tif.tmp.tiff: 640x640x1 TIFF file.
Attaching Ancellary Data to /tmp/dv_24039/raster/gdal_raster.proj.tif: 640x640x1 GeoTIFF File....Done.
struct, 14 elements
   anc: struct, 10 elements
       wkt: Text Buffer with 14 lines of text
           1: PROJCS["unnamed",
           2:     GEOGCS["unnamed ellipse",
           3:         DATUM["unknown",
           4:             SPHEROID["unnamed",3396190,0]],
           5:         PRIMEM["Greenwich",0],
           6:         UNIT["degree",0.0174532925199433]],
           7:     PROJECTION["Equirectangular"],
           8:     PARAMETER["latitude_of_origin",0],
           9:     PARAMETER["central_meridian",0],
           10:     PARAMETER["standard_parallel_1",0],
       metadata: struct, 1 elements...
       proj4: "'+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs '"
       origin: 1x2x1 array of double, bsq format [16 bytes]
       pixel_size: 1x2x1 array of double, bsq format [16 bytes]
       lat: 1x5x1 array of float, bsq format [20 bytes]
       lon: 1x5x1 array of float, bsq format [20 bytes]
       lpo: 1x5x1 array of float, bsq format [20 bytes]
       spo: 1x5x1 array of float, bsq format [20 bytes]
       center: 2x1x1 array of float, bsq format [8 bytes]
   ignore: 0.000000000
   projection: "Equirectangular"
   spheroid: struct, 3 elements
       name: "unnamed"
       radius: "3396190"
       iflattening: "0"
   resolution: 1852.334351
   x: 0.000000000
   y: 640.0000000
   ul: 2x1x1 array of float, bsq format [8 bytes]
   ur: 2x1x1 array of float, bsq format [8 bytes]
   ll: 2x1x1 array of float, bsq format [8 bytes]
   lr: 2x1x1 array of float, bsq format [8 bytes]
   w: 640
   h: 640
   data: 640x640x3 array of byte, bsq format [1,228,800 bytes]

dv> display(color.data)
Writing /tmp/dv_24039/hrh6lW: 640x640x3 PNG file.

Usage 2: Overlay the colorized shape on the original data (must be byte data)

dv> hsv=shape2georaster(shape,geostruct,ignore=0,color=255//255//0,hsv=1)
Writing /tmp/dv_24039/gdal_raster.proj.tif.tmp.tiff: 640x640x1 TIFF file.
Attaching Ancellary Data to /tmp/dv_24039/raster/gdal_raster.proj.tif: 640x640x1 GeoTIFF File....Done.
struct, 14 elements
   anc: struct, 10 elements
       wkt: Text Buffer with 14 lines of text
           1: PROJCS["unnamed",
           2:     GEOGCS["unnamed ellipse",
           3:         DATUM["unknown",
           4:             SPHEROID["unnamed",3396190,0]],
           5:         PRIMEM["Greenwich",0],
           6:         UNIT["degree",0.0174532925199433]],
           7:     PROJECTION["Equirectangular"],
           8:     PARAMETER["latitude_of_origin",0],
           9:     PARAMETER["central_meridian",0],
           10:     PARAMETER["standard_parallel_1",0],
       metadata: struct, 1 elements...
       proj4: "'+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs '"
       origin: 1x2x1 array of double, bsq format [16 bytes]
       pixel_size: 1x2x1 array of double, bsq format [16 bytes]
       lat: 1x5x1 array of float, bsq format [20 bytes]
       lon: 1x5x1 array of float, bsq format [20 bytes]
       lpo: 1x5x1 array of float, bsq format [20 bytes]
       spo: 1x5x1 array of float, bsq format [20 bytes]
       center: 2x1x1 array of float, bsq format [8 bytes]
   ignore: 0.000000000
   projection: "Equirectangular"
   spheroid: struct, 3 elements
       name: "unnamed"
       radius: "3396190"
       iflattening: "0"
   resolution: 1852.334351
   x: 0.000000000
   y: 640.0000000
   ul: 2x1x1 array of float, bsq format [8 bytes]
   ur: 2x1x1 array of float, bsq format [8 bytes]
   ll: 2x1x1 array of float, bsq format [8 bytes]
   lr: 2x1x1 array of float, bsq format [8 bytes]
   w: 640
   h: 640
   data: 640x640x3 array of byte, bsq format [1,228,800 bytes]

dv> display(hsv.data)
Writing /tmp/dv_24039/bXvihb: 640x640x3 PNG file.

Usage 3: Map a field in the GeoShape-Struct to the shape (e.g. fill it in with the value specified in the shapefile)

dv> val=shape2georaster(shape,geostruct,ignore=0,value="mola")
Writing /tmp/dv_24039/gdal_raster.proj.tif.tmp.tiff: 640x640x1 TIFF file.
Attaching Ancellary Data to /tmp/dv_24039/raster/gdal_raster.proj.tif: 640x640x1 GeoTIFF File....Done.
struct, 14 elements
   anc: struct, 10 elements
       wkt: Text Buffer with 14 lines of text
           1: PROJCS["unnamed",
           2:     GEOGCS["unnamed ellipse",
           3:         DATUM["unknown",
           4:             SPHEROID["unnamed",3396190,0]],
           5:         PRIMEM["Greenwich",0],
           6:         UNIT["degree",0.0174532925199433]],
           7:     PROJECTION["Equirectangular"],
           8:     PARAMETER["latitude_of_origin",0],
           9:     PARAMETER["central_meridian",0],
           10:     PARAMETER["standard_parallel_1",0],
       metadata: struct, 1 elements...
       proj4: "'+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs '"
       origin: 1x2x1 array of double, bsq format [16 bytes]
       pixel_size: 1x2x1 array of double, bsq format [16 bytes]
       lat: 1x5x1 array of float, bsq format [20 bytes]
       lon: 1x5x1 array of float, bsq format [20 bytes]
       lpo: 1x5x1 array of float, bsq format [20 bytes]
       spo: 1x5x1 array of float, bsq format [20 bytes]
       center: 2x1x1 array of float, bsq format [8 bytes]
   ignore: 0.000000000
   projection: "Equirectangular"
   spheroid: struct, 3 elements
       name: "unnamed"
       radius: "3396190"
       iflattening: "0"
   resolution: 1852.334351
   x: 0.000000000
   y: 640.0000000
   ul: 2x1x1 array of float, bsq format [8 bytes]
   ur: 2x1x1 array of float, bsq format [8 bytes]
   ll: 2x1x1 array of float, bsq format [8 bytes]
   lr: 2x1x1 array of float, bsq format [8 bytes]
   w: 640
   h: 640
   data: 640x640x1 array of float, bsq format [1,638,400 bytes]

dv> display(lstretch(val.data))

Usage 4: Map a field in the GeoShape-Struct to the shape and apply a linear colorize() scale

dv> gradient=shape2georaster(shape,geostruct,ignore=-1400,value="mola",gradient=5,hsv=1,in_low=-1600,in_high=1200)
Writing /tmp/dv_24039/gdal_raster.proj.tif.tmp.tiff: 640x640x1 TIFF file.
Attaching Ancellary Data to /tmp/dv_24039/raster/gdal_raster.proj.tif: 640x640x1 GeoTIFF File....Done.
./usr/share/davinci/library/script_files/color_tables/colormap_daily.ppm: PNM bip image: 256x1x3, 8 bits
struct, 14 elements
   anc: struct, 10 elements
       wkt: Text Buffer with 14 lines of text
           1: PROJCS["unnamed",
           2:     GEOGCS["unnamed ellipse",
           3:         DATUM["unknown",
           4:             SPHEROID["unnamed",3396190,0]],
           5:         PRIMEM["Greenwich",0],
           6:         UNIT["degree",0.0174532925199433]],
           7:     PROJECTION["Equirectangular"],
           8:     PARAMETER["latitude_of_origin",0],
           9:     PARAMETER["central_meridian",0],
           10:     PARAMETER["standard_parallel_1",0],
       metadata: struct, 1 elements...
       proj4: "'+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396190 +b=3396190 +units=m +no_defs '"
       origin: 1x2x1 array of double, bsq format [16 bytes]
       pixel_size: 1x2x1 array of double, bsq format [16 bytes]
       lat: 1x5x1 array of float, bsq format [20 bytes]
       lon: 1x5x1 array of float, bsq format [20 bytes]
       lpo: 1x5x1 array of float, bsq format [20 bytes]
       spo: 1x5x1 array of float, bsq format [20 bytes]
       center: 2x1x1 array of float, bsq format [8 bytes]
   ignore: -1400.000000
   projection: "Equirectangular"
   spheroid: struct, 3 elements
       name: "unnamed"
       radius: "3396190"
       iflattening: "0"
   resolution: 1852.334351
   x: 0.000000000
   y: 640.0000000
   ul: 2x1x1 array of float, bsq format [8 bytes]
   ur: 2x1x1 array of float, bsq format [8 bytes]
   ll: 2x1x1 array of float, bsq format [8 bytes]
   lr: 2x1x1 array of float, bsq format [8 bytes]
   w: 640
   h: 640
   data: 640x640x3 array of byte, bip format [1,228,800 bytes]

dv> display(gradient.data)
Writing /tmp/dv_24039/cghPmj: 640x640x3 PNG file.

Images

Usage1: shape color.png Usage2: shape hsv.png

Usage3: shape val.png Usage4: shape gradient.png

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Major Sub-Functions

Recent Library Changes

Created On: 05-14-2013
Modified On: 05-14-2013

Personal tools