-
Notifications
You must be signed in to change notification settings - Fork 14
Python API Loading of Data
One way of loading data, is to set a working catalog, which is the place where the data you want to load is stored. You can easily do this with help of the Engine class and its method setWorkingCatalog.
from ilwisobjects import *
Engine.setWorkingCatalog("file:///D:/<working>/<directory>/")
rc1 = RasterCoverage("subkenya.mpr")As you can see in the example you need to attach a "file://" to your systems directory path, for the method to correctly detect the folder. A detailed description of the expression and how ILWIS parses the given folder for data can be found in the Python API Tutorial.
The example above shows that, once you have set the directory, you can just create a new object like a RasterCoverage by calling its constructor with the name of the file you want it to load. This way you have easily created a new object you can use for further processing.
If you want to know to which location you have set your working catalog at the moment you can call Engine.getLocation() and it will return you a string which tells you the catalog's location.
If you want to know which items IlwisObjects recognized in your directory you can call Engine.catalogItems() and you will get an ordered tuple of all the files IlwisObjects could find your working directory.
print(Engine.getLocation())
# will print "file:///D:/<working>/<directory>/"
print(Engine.catalogItems())
# will print all files e.g. ['2003.tif', '_ANONYMOUS_4988_band_0.mpr', '_ANONYMOUS_4988_band_1.mpr', 'aa.mpr', 'aa302select.grf', 'aa302select.mpr', ...]Another way of loading the data is with the help of setInputConnection().
fc = FeatureCoverage("MyFC")
fc.setInputConnection("file:///D:/<dir>/countries.mpa", "vectormap", "ilwis3")Here you can see, that you first need to create a new FeatureCoverage which you can name however you want. After that you can use this coverage to set an input connection and specify which file you want to load(countries.mpa), what kind of data it is(vectormap) and which connector should be used(ilwis3).
Note that after setting the input connection the name of the FeatureCoverage will not longer be "MyFC" but the file's name ("countries.mpa" in this case).