Use Grid Type Extension to enable ArcGIS to support more sensor types

Source: Internet
Author: User
1 What: What is the grid type?

It has been a year since the launch of the ArcGIS massive image management solution. I believe many friends have a general understanding of how to manage massive image data in ArcGIS. ArcGIS 10.0 introduces a mosaic dataset model for massive image management. A single mosaic dataset can manage millions of scenes, images of different phases, different resolutions, different coordinate systems, and different spatial locations.

To import image data of different sources and forms into the mosaic data set, we need to specify the "raster type" for the image )". In short, the raster type is a classification of various image data, which is basically divided by satellite sensor type and aerial camera type. Is some of the built-in grid types supported by ArcGIS:

You need to distinguish between the raster type and the Raster Data Format: The raster data format is used to define how the raster pixels are stored, such as the number of rows and columns, the number of bands, and the value of pixels. The raster type defines how to identify the metadata associated with the image and the processing functions defined for the image, such as band combination and full-color fusion.

In order to better understand the grid type, we can make an example: You want to go to the cinema to watch a movie, in addition to people going in, you also need a movie ticket. If it is a 3D movie, you also need to bring 3D glasses. The storage of raster image data is equivalent to the process of going to a movie: in addition to the Raster image data, metadata information (movie tickets) is also required. If it is a multi-band image, it may also require band combination (3D glasses are required for 3D viewing ).

2 when: When do I need to expand the grid type?

So since ArcGIS already supports so many grid types by default, do we need to extend the grid type? Of course. In the following common scenarios, raster type extension is required:

1) Management of processed results images: Many organizations process image data, such as geometric correction, atmospheric correction, and image stitching. After these processed images, metadata in the custom format may be generated, so that the raster type extension is required.

2) need to manage domestic satellite images: many units have domestic satellite image data, such as Fengyun series, Beijing series, and environmental star series. The metadata formats of these satellites are also in different forms. Because they are not universal commercial satellites, they also need to be expanded to the grid type.

3) military satellite images need to be managed: the metadata format of these images may be even more mysterious. If you are lucky enough to participate in the project, you must use the raster type Extension to manage these images.

4) image management for aerial photography: aerial photography is also one of the largest sources of image data, such as drone shooting. The metadata generated varies depending on the camera, so it is necessary to expand the raster type.

Which of the following images can be imported into the database without the need to expand the raster type? Readers can refer to the introduction in ArcGIS help:

Satellite sensor raster type: http://resources.arcgis.com/en/help/#/Satellite_sensor_raster_types/009t000001z6000000/

Aerial Image raster type: http://resources.arcgis.com/en/help/#/Aerial_imagery_raster_types/009t000001zp000000/

3 How: how to expand the Grid Type

OK. Now you know what the raster type is and under what circumstances you need to extend the raster type. Now you need to learn how to extend the raster type.

Raster type extension is actually completed through ArcObjects development. Readers do not have to worry about the difficulty of development, because ArcGIS provides a perfect example, And what developers need to do is to extend the name of the grid type, parse the metadata file and define some preprocessing functions as needed.
3.1 program structure

In the ArcObjects installation directory, you can find the example program for Grid Type extension, for example, C: \ ArcGIS \ developerkit10.1 \ samples \ arcobjectsnet \ customrastertype \ CSHARP \ thumbnailbuilder, open the example program, we can see thumbnailbuilder. the CS file contains an interface and two classes, as shown in:

The ithumbnailbuilder contains only one attribute, innerrasterbuilder, which indicates the built-in constructor of The raster type.

Thumbnailfactory implements the irastertypefactory interface, which mainly includes the com registration/anti-registration function, the name of the grid type, and the process of calling the Grid Type constructor.

Thumbnailbuilder is a specific raster Type constructor, which contains specific processing algorithms for raster type extension.

3.2 case studies

In this example, we refer to the example program, but considering the actual application, we have added other functions, such as recording operation logs and parsing metadata files. Shows the program structure:

The above files are:

1) cgcimagerybuilder: A Grid Type constructor that performs a specific Grid Type constructor;

2) cgcrastertypefactory: defines the grid type name, provides the com registration function, and provides the call process of the Grid Type constructor;

3) builderhelper: some common processing functions, such as obtaining default fields, custom fields, or adding fields of the embedded dataset;

4) loghelper: records operation logs and writes log files;

Metareader: Contains metadata parsing functions. It reads the specified format of metadata files as labeled key-value pairs.

3.3 main code 3.3.1 iappendedbuilder
Interface iappendedbuilder: irasterbuilder {// <summary> // additional built-in target raster builder object // </Summary> irasterbuilder innerrasterbuilder {Get; set ;}}

3.3.2 cgcrastertypefactory
Using system; using system. collections. generic; using system. LINQ; using system. text; using system. runtime. interopservices; using ESRI. arcGIS. esrisystem; using ESRI. arcGIS. datasourcesraster; using esricd. demos. CGC. imagery. util; namespace esricd. demos. CGC. imagery. EXT {// <summary> // Chongqing Geographic Information Center Image Data Grid Type factory // </Summary> [GUID ("AE299550-610F-44B6-9069-5C6E5CDC2F80")] [classinterface (classinterfacetype. none)] [progid ("rastertypeextension. cgcrastertypefactory ")] [comvisible (true)] public class cgcrastertypefactory: irastertypefactory {# region private member public const string cgc_imagery =" Chongqing Geographic Information Center image type "; private istringarray myrastertypenames; private uid myuid; Public cgcrastertypefactory () {// specify the name of the raster type. These types can be associated with the extended raster constructor myrastertypenames = new strarrayclass (); myrastertypenames. add (cgc_imagery); myuid = new uidclass (); myuid. value = "{AE299550-610F-44B6-9069-5C6E5CDC2F80}" ;}# endregion # region irastertypefactory member public ESRI. arcGIS. esrisystem. UID clsid {get {return myuid;} public irastertype createrastertype (string rastertypename) {try {// 1-first obtain the built-in raster Dataset) irastertypename therastertypename = new rastertypenameclass (); therastertypename. name = "raster dataset"; // accepts the request. path of the art file, or the name of the built-in raster type irastertype therastertype = (irastertype) (INAME) therastertypename ). open (); If (therastertype = NULL) {loghelper. addmessage ("error: Grid Type not found" + therastertypename. name); return NULL;} // 2-attaches the custom raster constructor iappendedbuilder pappendedbuilder = new cgcimagerybuilder () to the raster constructor of the built-in raster dataset (); pappendedbuilder. innerrasterbuilder = therastertype. rasterbuilder; therastertype. rasterbuilder = pappendedbuilder as irasterbuilder; // 3-change the name of the built-in raster dataset to the name of the custom raster type, INAME thename = therastertype. fullname; (irastertypename) thename ). name = rastertypename; return therastertype;} catch (exception ex) {loghelper. addmessage ("create grid type" + rastertypename + "failed:" + ex. message); return NULL ;}} public string name {get {return "CGC raster type factory" ;}} public ESRI. arcGIS. esrisystem. istringarray rastertypenames {get {return myrastertypenames; }}# endregion # region com registration function [comregisterfunction ()] Static void Reg (string regkey) {ESRI. arcGIS. ADF. catids. rastertypefactory. register (regkey);} [comunregisterfunction ()] Static void unreg (string regkey) {ESRI. arcGIS. ADF. catids. rastertypefactory. unregister (regkey) ;}# endregion }}

3.3.3 cgcimagerybuilder
Using system; using system. collections. generic; using system. LINQ; using system. text; using system. runtime. interopservices; using ESRI. arcGIS. datasourcesraster; using ESRI. arcGIS. esrisystem; using ESRI. arcGIS. geodatabase; using esricd. demos. CGC. imagery. util; using ESRI. arcGIS. geometry; namespace esricd. demos. CGC. imagery. EXT {[GUID ("A1AE3CF4-2C9E-4A9C-9287-C8D9BF182F64")] [classinterface (classinterfacetype. no Ne)] [progid ("rastertypeextension. cgcimagerybuilder ")] [comvisible (true)] public class cgcimagerybuilder: container, ipersistvariant, irasterbuilderinit {# region private member public irasterbuilder innerrasterbuilder; // inner raster builder private uid myuid; // uid for the builder. # endregion # Add the region constructor member /// <summary> // The constructor cannot contain parameters; otherwise, a memory access error is reported. // </Summary> Public cgcimagerybuilder () {innerr Asterbuilder = NULL; myuid = new uidclass (); myuid. value = "{A1AE3CF4-2C9E-4A9C-9287-C8D9BF182F64}";} public irasterbuilder innerrasterbuilder {get {return innerrasterbuilder;} set {innerrasterbuilder = value ;}} # endregion # region irasterbuilder member // <summary> // auxiliaryfieldalias property gets and sets the auxiliary (Auxiliary and standby) fields alias // present in the raster builder /// </Summary> Public ESRI. arcGIS. esrisystem. ipropertyset auxiliaryfieldalias {get {return innerrasterbuilder. auxiliaryfieldalias;} set {innerrasterbuilder. auxiliaryfieldalias = value ;}/// <summary> // flag to specify whether the raster builder can build items in place. /// </Summary> Public bool canbuildinplace {get {return innerrasterbuilder. canbuildinplace; }}/// <summary> // prepare the raster Type for generating crawler items // </Summary> // <Param name = "pcrawler"> crawler to use to generate the crawler items </param> Public void beginconstruction (idatasourcecrawler pcrawler) {innerrasterbuilder. beginconstruction (pcrawler);} // <summary> // construct a unique resource identifier (URI) /// for each crawler item /// </Summary> /// <Param name = "crawleritem"> crawled item from which th E uri is generated </param> Public void constructuris (Object crawler item) {innerrasterbuilder. constructuris (crawleritem );} /// <summary> // finish construction of the Uri's // </Summary> /// <returns> </returns> Public iitemuriarray endconstruction () {return innerrasterbuilder. endconstruction ();} // <summary> // generate the next Uri. /// </Summary> /// <returns> the URI generated. </returns> Public iitemuri getnexturi () {return innerrasterbuilder. getnexturi ();} // <summary> // get the recommended data crawler for the raster type based on // properties provided by the user. /// </Summary> /// <Param name = "pperformanceproperties"> List of properties provided by the user </param> /// <returns> </returns> Public idatasourcecrawler getrecommendedcrawler (ipropertyset pdatasourceproperties) {Return innerrasterbuilder. getrecommendedcrawler (pperformanceproperties);} // <summary> // check if the item provided is "stale is not fresh, outdated "or not valid /// </Summary> // <Param name =" pitemuri "> URI for the item to be checked </param> // <returns> </returns> Public bool isstale (iitemuri pitemuri) {return innerrasterbuilder. isstale (pitemuri);} // <summary> // properties associated with the rast Er type // </Summary> Public ipropertyset properties {get {return innerrasterbuilder. properties;} set {innerrasterbuilder. properties = value ;}/// <summary> // Add a secondary field, all default fields of a non-embedded dataset can be considered as auxiliary fields. // </Summary> Public ifields auxiliaryfields {get {ESRI. arcGIS. datasourcesraster. irasterbuilder prasterbuilder = innerrasterbuilder; ifields myfields = prasterbuilder. auxiliaryfields; try {imosaicdat Aset pmosaicdataset = (irasterbuilderinit) innerrasterbuilder ). mosaicdataset; ifields pallfields = builderhelper. getmosaicdatasetfields (pmosaicdataset); dictionary <string, esrifieldtype> lstcustomfields = builderhelper. getmosaicdatasetcustomfields (pallfields); foreach (keyvaluepair <string, esrifieldtype> fielditem in lstcustomfields) {int COUNT = myfields. findfield (fielditem. key); If (COUNT =-1) {Builderhelper. addnewfield (myfields, fielditem. key, fielditem. value); prasterbuilder. auxiliaryfields = myfields ;}} catch (exception ex) {loghelper. addmessage ("failed to add the secondary field:" + ex. tostring ();} return innerrasterbuilder. auxiliaryfields;} set {innerrasterbuilder. auxiliaryfields = value ;}/// <summary> // creates a raster data item, where you can perform additional build operations on each item. /// </Summary> /// <Param name = "pitemuri"> </param> /// <retu RNS> </returns> Public ibuilderitem build (iitemuri pitemuri) {try {// execute the built-in build operation (the parameter is the URI of the item to be built) loghelper. addmessage ("reading raster data:" + pitemuri. key); ibuilderitem pbuilderitem = innerrasterbuilder. build (pitemuri); // obtain the Field List of the embedded dataset to extract the metadata item imosaicdataset MD = (irasterbuilderinit) innerrasterbuilder) based on the field alias ). mosaicdataset; ifields pfields = builderhelper. getmosaicdatasetfields (MD); // you can call this operation to obtain the properties of the raster data. Propertyset ppropset = pbuilderitem. dataset. properties; // read/write metadata metareader. readcgcimagerymeta (pitemuri. Key, pfields, ppropset); loghelper. addmessage ("added raster data. "); Loghelper. writetologfile (); Return pbuilderitem;} catch (exception ex) {loghelper. addmessage ("failed to build the grid data:" + ex. tostring (); loghelper. writetologfile (); return NULL ;}} # endregion # region ipersistvariant member // <summary> // uid for the object implementing the persist variant // </Summary> uid ipersistvariant. id {get {return myuid ;}} /// <summary> // load the object from the stream provided /// </Summary> // <Param name = "stream"> stream that represents the serialized raster type </param> void ipersistvariant. load (ivariantstream stream) {string name = (string) stream. read (); innerrasterbuilder = (irasterbuilder) stream. read (); // load the innerrasterbuilder from the stream .} /// <summary> /// same The raster type to the stream provided /// </Summary> /// <Param name = "stream"> stream to serialize the raster type into </param> void ipersistvariant. save (ivariantstream stream) {stream. write ("cgcimagerybuilder"); stream. write (innerrasterbuilder); // Save the innerrasterbuilder into the stream .} # endregion # region irasterbuilderinit member // <summary> // default spatial reference for the MD. /// </Summary> ispatialreference irasterbuilderinit. defaultspatialreference {get {return (irasterbuilderinit) innerrasterbuilder ). defaultspatialreference;} set {(irasterbuilderinit) innerrasterbuilder ). defaultspatialreference = value ;}/// <summary> // parent mosaic dataset for the raster builder. /// </Summary> imosaicdataset irasterbuilderinit. mosaicdataset {get {return (irasterbuilderinit) innerrasterbuilder ). mosaicdataset;} set {(irasterbuilderinit) innerrasterbuilder ). mosaicdataset = value ;}/// <summary> // The raster type operation helper object associated with this raster type. /// </Summary> irastertypeoperation irasterbuilderinit. rastertypeoperation {get {return (irasterbuilderinit) innerrasterbuilder ). rastertypeoperation;} set {(irasterbuilderinit) innerrasterbuilder ). rastertypeoperation = value ;}/// <summary> // tracker for when cancel is pressed. /// </Summary> itrackcancel irasterbuilderinit. trackcancel {get {return (irasterbuilderinit) innerrasterbuilder ). trackcancel;} set {(irasterbuilderinit) innerrasterbuilder ). trackcancel = value ;}# endregion }}

After the extension development is completed and registered, you can see the custom grid type in the grid type, such as the last one:

In this way, when importing image data to an embedded dataset, you can select an extended raster type to ensure that the metadata information is correctly stored in the database for management, laying a solid foundation for image management and application.

This article only introduces the technical route and key code of raster type extension. log records and other auxiliary functions are not uploaded. If you need the complete code, leave the email address in the comment. If you have any questions, please leave a comment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.