Sunday, 9 October 2016

shapefile - Using kriging with data in GDB



I have series of data in my GDB


I am running the program under VBA and what I want to do is using the data by the tool Kriging.


This is what I thought:


First, Kriging needs data that must be a point shapefile and I am getting the data out of my GDB (one point in one table but there is a lot of data)



  1. I get the data I need and make it in a shapefile

  2. I use the Kriging tool to calculate the shapefile

  3. I use the raster to point tool to change the raster Kriging make to a point layer

  4. I get the point data I want!



Here is my question:


When I get the data from the GDB (using sSQL), how to change it to a shapefile in VBA?


I have only found the page to display XY data using VBA: http://edndoc.esri.com/arcobjects/9.0/samples/tables/create_a_layer_based_on_xy_data.htm but it's can't save as shapefile!


How to save it automatically?


Is there any wrong with my steps?


If need more information please tell me!


@artwork21


An error occurred in the line


gp.FeatureClassToShapefile_conversion "'C:\Temp\New File Geodatabase.gdb\point'", Temp__2_


says



automation error


unspecified error


how to fix it?


Call tools from ArcToolBox in VBA form


in this post about my problem I fix it like follow


gp.Kriging "C:\temp\123.shp", "F30", "C:\AA\Kriging_123", "Spherical 249.101224", "250"


but this time no matter what I try it's doesn't work...



Answer



Since all your tasks are geoprocessing tasks you could just create a model and export out the model to either a vb, python, or jscript. Below is an example of a vbs script. You can then call the script with a macro or UI Control.


Dim gp As object



' Create the Geoprocessor object
set gp = CreateObject("esriGeoprocessing.GPDispatch.1")

' Check out any necessary licenses
gp.CheckOutExtension "spatial"

' Load required toolboxes...
gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx"

gp.AddToolbox "C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx"

' Local variables...
Dim Temp As String = "C:\Temp"
Dim point As String = "C:\Temp\New File Geodatabase.gdb\point"
Dim Temp__2_ As String = "C:\Temp"
Dim Kriging_poin1 As String = "C:\Temp\Kriging_poin1"
Dim Output_variance_of_prediction_raster As String = ""
Dim points_shp As String = "C:\Temp\points.shp"
Dim RasterT_kriging1_shp As String = "C:\Temp\RasterT_kriging1.shp"

Dim kriging_poin1__2_ As String = "C:\Temp\kriging_poin1"

' Process: Feature Class To Shapefile (multiple)...
gp.FeatureClassToShapefile_conversion "'C:\Temp\New File Geodatabase.gdb\point'", Temp__2_

' Process: Kriging...
gp.Kriging_sa points_shp, "ID", Kriging_poin1, "Spherical 51.968339", "51.968339", "VARIABLE 12", Output_variance_of_prediction_raster

' Process: Raster to Point...
gp.RasterToPoint_conversion kriging_poin1__2_, RasterT_kriging1_shp, "Value"

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...