[Qgis-user] Share Python Script for Point Analyses Tool

Leo Kris Palao lk.palao at gmail.com
Wed Jun 4 19:50:49 PDT 2014


Hi Saber,
The code does not want long shapefile filename - so I rename my shapefile.
I also modifed the argument not to take the whole directory but specific
files. Since my raster data are in ENVI format, it throws an error when the
code reads the .hdr files.

This is my new argument that I executed in OSGeo4W shell:

E:\Test_modis>python extract_values.py -c pts.shp 2013041 2013049 2013057
2013065 2013073

But it still throw an error message. When I look at the attribute table of
the pts.shp it created new fieldnames based on raster filename but all the
values are NULL.

Thanks,
-Leo

this is the error message that I got:

E:\Test_modis>python extract_values.py -c pts.shp 2013041 2013049 2013057
201306
5 2013073
Found GDAL version: 1.10.1

ERROR 4: `pts.shp' not recognised as a supported file format.

Unable to open shapefile -c

E:\Test_modis>python extract_values.py pts.shp 2013041 2013049 2013057
2013065 2
013073
Found GDAL version: 1.10.1

[                                                                   ] \
0.1%Tr
aceback (most recent call last):
  File "extract_values.py", line 411, in <module>
    inFeat.SetField( shortName, value )
  File "C:\OSGeo4W\apps\Python27\lib\site-packages\osgeo\ogr.py", line
2572, in
SetField
    return _ogr.Feature_SetField(self, *args)
NotImplementedError: Wrong number of arguments for overloaded function
'Feature_
SetField'.
  Possible C/C++ prototypes are:
    SetField(OGRFeatureShadow *,int,char const *)
    SetField(OGRFeatureShadow *,char const *,char const *)
    SetField(OGRFeatureShadow *,int,int)
    SetField(OGRFeatureShadow *,char const *,int)
    SetField(OGRFeatureShadow *,int,double)
    SetField(OGRFeatureShadow *,char const *,double)
    SetField(OGRFeatureShadow *,int,int,int,int,int,int,int,int)
    SetField(OGRFeatureShadow *,char const *,int,int,int,int,int,int,int)


On Thu, Jun 5, 2014 at 9:19 AM, Leo Kris Palao <lk.palao at gmail.com> wrote:

> Hi Saber,
>
> Have you tried to use the tool before that you suggested me
> http://gis-lab.info/qa/extract-values-rasters-eng.html . I tried to run
> it but I get an error message - I think I got the input-output argument
> right. Can you help me debug it?
>
> I am running it in five MODIS-EVI dataset first for testing. I am using
> QGIS 2.2 with GDAL and GDAL-Python installed using OSGeo4W installer. and I
> am using Windows 7 64 bit professional OS. I have the extract_values.py
> script, rasters, and shapefile in one folder.
>
> Thanks,
> -Leo
>
> GDAL 1.10.1, released 2013/08/26
>
> C:\>cd F:\MODIS_Historical\First_season\yr2012\h27v07\Test
>
> C:\>F:
>
> F:\MODIS_Historical\First_season\yr2012\h27v07\Test>extract_values.py -c
> GT_and_
> farmsurvey_modis.shp -d F:\MODIS_Historical\First_
> season\yr2012\h27v07\Test
> Traceback (most recent call last):
>   File "F:\MODIS_Historical\First_season\yr2012\h27v07\Test\
> extract_values.py",
> line 34, in <module>
>     import gdal, ogr, osr
>   File "C:\OSGeo4W\apps\Python27\lib\site-packages\gdal.py", line 2, in
> <module>
>
>     from osgeo.gdal import deprecation_warn
>   File "C:\OSGeo4W\apps\Python27\lib\site-packages\osgeo\__init__.py",
> line 21,
> in <module>
>     _gdal = swig_import_helper()
>   File "C:\OSGeo4W\apps\Python27\lib\site-packages\osgeo\__init__.py",
> line 17,
> in swig_import_helper
>     _mod = imp.load_module('_gdal', fp, pathname, description)
> ImportError: DLL load failed: %1 is not a valid Win32 application.
>
> F:\MODIS_Historical\First_season\yr2012\h27v07\Test>
>
>
> On Wed, Jun 4, 2014 at 3:32 PM, Saber Razmjooei <
> saber.razmjooei at lutraconsulting.co.uk> wrote:
>
>> Have you tried this:
>>
>> http://gis-lab.info/qa/extract-values-rasters-eng.html
>>
>>
>>
>> Cheers,
>>
>> Saber
>>
>>
>>
>>
>>
>> *From:* qgis-user-bounces at lists.osgeo.org [mailto:
>> qgis-user-bounces at lists.osgeo.org] *On Behalf Of *Leo Kris Palao
>> *Sent:* 04 June 2014 06:50
>> *To:* QGIS Mailing List
>> *Subject:* [Qgis-user] Share Python Script for Point Analyses Tool
>>
>>
>>
>> Hi QGIS Users,
>>
>> I am processing multi-temporal EVI data derived from MODIS, and the
>> number of datasets could be around 70 images. I have points and want to
>> extract pixel values from those points. I know that the Point Analyses Tool
>> can do it. However, it is cumbersome to load all the MODIS data because it
>> takes too long. Is there a way to extract the pixel values from points
>> without actually loading the datasets? Maybe a script (GDAL or Python) can
>> do this. Can somebody help me or point me to the right blog or website
>> where I can use as reference.
>>
>> Thanks in advance for the help.
>>
>> -Leo
>>
>>
>> ------------------------------
>>
>> This email and any files transmitted with it are confidential and
>> intended solely for the use of the individual or entity to whom they are
>> addressed. If you have received this email in error please notify the
>> system manager. This message contains confidential information and is
>> intended only for the individual named. If you are not the named addressee
>> you should not disseminate, distribute or copy this e-mail. Please notify
>> the sender immediately by e-mail if you have received this e-mail by
>> mistake and delete this e-mail from your system. If you are not the
>> intended recipient you are notified that disclosing, copying, distributing
>> or taking any action in reliance on the contents of this information is
>> strictly prohibited.
>>
>> Whilst reasonable care has been taken to avoid virus transmission, no
>> responsibility for viruses is taken and it is your responsibility to carry
>> out such checks as you feel appropriate.
>>
>> If this email contains a quote or offer to sell products, carry out work
>> or perform services then our standard terms and conditions
>> <http://www.lutraconsulting.co.uk/downloads/Lutra%20Consulting%20Standard%20Terms%20and%20Conditions.pdf>
>> shall apply unless explicitly stated otherwise.
>>
>> Saber Razmjooei and Peter Wells trading as Lutra Consulting.
>>
>>
>>
>
>
> --
> *LEO KRIS MARIANO PALAO*
> Social Sciences Division
> International Rice Research Institute
> Website: www.irri.org
> Mobile #: 0932-847-6644
>



-- 
*LEO KRIS MARIANO PALAO*
Social Sciences Division
International Rice Research Institute
Website: www.irri.org
Mobile #: 0932-847-6644
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20140605/f5676407/attachment.html>


More information about the Qgis-user mailing list