On Thu, Jul 1, 2010 at 12:16 PM, Giovanni Manghi
<[email protected]> wrote:
>
>> > yes, the difference I see is gdal 1.7.x instead of 1.6.x
>> >
>> > could be?
>>
>> Could be..
>>
>> Can you test this code snippet in R?
>>
>> #################################
>> require(rgdal)
>> cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
>> # cities can be any Spatial*DataFrame.
>> writeOGR(cities, "/tmp", "cities_full", driver="ESRI Shapefile")
>> writeOGR(cities[cities$NAME == "Veracruz",], "/tmp", "cities_one",
>> driver="ESRI Shapefile")
>> #################################
>>
>> if it works with these example data I will dig out another snippet
>> closer to plugin's code.
>
>
> This is the result
>
> Loading required package: rgdal
> Loading required package: sp
> Geospatial Data Abstraction Library extensions to R successfully loaded
> Loaded GDAL runtime: GDAL 1.7.2, released 2010/04/23
> Path to GDAL shared files: /usr/share/gdal17
> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
> Path to PROJ.4 shared files: (autodetected)
> OGR data source with driver: ESRI Shapefile
> Source: "/home/gio/R/i486-pc-linux-gnu-library/2.10/rgdal/vectors",
> layer: "cities"
> with 606 features and 4 fields
> Feature type: wkbPoint with 2 dimensions
So GDAL 1.7 works fine with R.
Actually I would avoid patching the code as most of it will be soon
useless: the new adehabitat package provides functions to convert from
adehabitat classes to sp, and manageR code can become a library, or at
least be accessed by other plugins.
I'm fixing the tests that are in HomeRange_plugin/tests
You can run them using this command (using python2.6):
python test_plugin.py
Still, i've got issues with SVN repo - i attach the file here. Let me
know if there are any problems.
Thanks again so much!
cheers
Anne
## Test suite for python-r code.
## Run it as:
## python2.6 test_plugin.py
import unittest
import os,sys
import inspect
#import sets
from tempfile import gettempdir
sys.path.append('/home/anne/src/HomeRange_plugin')
from HRplugin_dialog import Rwrapper
import rpy2.robjects as robjects
#import rpy2.rpy_classic as rpy
# test case
class RcallTestCase(unittest.TestCase):
idDict = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] # 20 times
xDict = [1560677,1560708,1560631,1560657,1560670,1560688,1560671,1560644,1560595,1560637,1560625,1560513,1560623,1560484,1560535,1560561,1560597,1560593,1560636,1560592]
yDict = [5109720,5109611,5109599,5109632,5109634,5109560,5109610,5109466,5109632,5109619,5109478,5109426,5109507,5109508,5109431,5109531,5109489,5109467,5109512,5109466]
geomData = {'ID': idDict, 'X': xDict, 'Y': yDict}
#
tempfolder = gettempdir()
# dictionary of methods. Add new methods here as keys, value is its full name.
mth = {"mcp":"MCP", "href":"Kernel h ref", "lscv":"Kernel h LSCV", "hadj":"Kernel with adjusted h"}
opt = {}
# input settings
opt["io"] = {}
opt["io"]["layer"] = "Arvicola_lula20090323162314383"
opt["io"]["layerpointer"] = None
opt["io"]["layername"] = "arvicola"
opt["io"]["subset"] = "TABLE"
# specific analysis settings.
# for each (visible and) checked box, do analysis. Even if user doesn't touch them, a valid analysis can be run
# using defaults.
opt["methods"] = {}
for i in mth:
opt["methods"][i] = {}
opt["methods"][i]["percent"] = 95
# output settings
opt["io"]["outputfolder"] = tempfolder
opt["io"]["overwrite"] = True
opt["io"]["outputview"] = False
def testRcallGlobal(self):
self.opt["io"]["mode"] = "global"
rwrapper = Rwrapper(self)
shapefilelist = rwrapper.Rcall(self.geomData, self.opt)
expectedshapefilelist = ['arvicola-hlscv-95', 'arvicola-hadj-95', 'arvicola-href-95', 'arvicolaMCP95all']
self.assertEquals(shapefilelist, expectedshapefilelist)
def testRcallSeparated(self):
self.opt["io"]["mode"] = "separated"
rwrapper = Rwrapper(self)
shapefilelist = rwrapper.Rcall(self.geomData, self.opt)
expectedshapefilelist = ['arvicola-hlscv-95-1', 'arvicola-hadj-95-1', 'arvicola-href-95-1']
self.assertEquals(shapefilelist, expectedshapefilelist)
def testRcallGlobalSeparated(self):
self.opt["io"]["mode"] = "global, separated"
rwrapper = Rwrapper(self)
shapefilelist = rwrapper.Rcall(self.geomData, self.opt)
expectedshapefilelist = ['arvicola-hlscv-95-1', 'arvicola-hadj-95-1', 'arvicola-href-95-1','arvicola-hlscv-95', 'arvicola-hadj-95', 'arvicola-href-95', 'arvicolaMCP95all']
self.assertEquals(shapefilelist.sort(), expectedshapefilelist.sort())
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(RcallTestCase)
return suite
# run it
if __name__ == '__main__':
unittest.main()
_______________________________________________
AniMov mailing list
[email protected]
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov