Re: [GRASS-user] Query vector type has problems

2015-09-06 Thread Anna Petrášová
Hi,

On Fri, Aug 28, 2015 at 8:54 AM, Andres Kuusk  wrote:

>
>
> Dear Anna Petrášová,
>
> Thank you for your quick response. I am sorry for being so late in testing
> your suggestions, I had my vacation.
>
>
> Vector commands v.what.vect and v.distance do not fill the attribute
>>> column of a point vector.
>>>
>>> [..]
>
>>
>>> The command
>>>
>>> v.what.vect map=vpoints column=aid query_map=varea query_column=aid
>>>
>>> returns:
>>>
>>> Finding nearest features...
>>> Update vector attributes...
>>> 191 categories - no nearest feature found
>>>
>>>
>> I tried similar example, but it seems to work for me, perhaps you could
>> send us reproducible example which uses North Carolina sample datatset?
>>
>
> I did not mention that I am using Postgres database.
> Anyway, now I tested v.what.vect so that I exported vectors 'geology' and
> 'schools' from the NC GRASS 7 subset using ESRI_Shapefile format.
> Then I created Postgres DB 'nc_basic', connected to the DB and imported
> these two vectors, added column 'geology' to the table 'schools', and
> updated the attribute 'geology'. Everything works fine.
>
> Now I exported my test vectors 'stand' (area, 1 polygon) and 'samples'
> (191 points) from my location/mapset using ESRI_Shapefile format and
> imported to the nc_basic_spm_grass7/user1 mapset.
>
> v.what.vect --verbose map=samples@user1 column=idr_id
> query_map=stand@user1 query_column=idr_id
> Finding nearest features...
> Update vector attributes...
> 191 categories - no nearest feature found
> 191 categories read from the map
> 191 categories exist in the table
> 191 categories read from the map exist in the table
> v.distance complete. 191 records updated.
>
> Attached you will find the tar-file of these vectors in the ESRI Shapefile
> format and the screenshot of these data in the nc_basic_spm_grass7/user1
> mapset.
>
> Could it be that some colum-names are too long in the attribute tables?
>

it took me a while to figure out the problem, but it's because your samples
are 3D and the stand vector is not. If you convert the samples to 2d with
v.to.3d, then it will work.

Cheers,

Anna

>
>
> With best wishes,
>
> Andres
>
>
> 
>
>
>>> The OS is OpenSUSE-13.1, 3.11.10-25-desktop, x86_64.
>>> The problem is there in:
>>>
>>> GRASS-7.0.0-2.42 from the repository
>>> http://download.opensuse.org/repositories/Application:/Geo/openSUSE_13.1
>>>
>>> GRASS-7.1 SVN r65785M
>>> (GRASS GIS 7.1.svn r65785M compilation log: No errors detected.)
>>>
>>> GRASS-7.0 SVN r58582.
>>>
>>> An old svn-version of 7.0 did the work (r51370):
>>> v.what.vect ...
>>> Finding nearest feature..
>>> Finding nearest areas...
>>> Update vector attributes...
>>> 2837 categories - no nearest feature found
>>> 23679 categories read from the map
>>> 23679 categories exist in the table
>>> 23679 categories read from the map exist in the table
>>> v.distance complete. 23679 records updated.
>>>
>>> 20842 points have got the attribute.
>>>
>>>
>>> Andres Kuusk
>>> Tartu Observatory, Estonia
>>
>>
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] Is it possible to export a vector as new table in existing spatialite database?

2015-09-06 Thread John A Stevenson

On 04/09/15 18:38, Markus Neteler wrote:

On Fri, Sep 4, 2015 at 5:49 PM, John A Stevenson
  wrote:

I would like to export a vector as new table in existing spatialite
database.

Please let us know how it goes, then we may add that to the manual as
a new example.

Markus
When I tried exporting to Spatialite from GRASS using v.out.ogr, I got 
an error, and although the table was created, the geometry didn't work.  
(Example using nc_spm_08_grass7).


v.out.ogr --overwrite input=firestations@PERMANENT output=nc.sqlite 
format=SQLite dsco=SPATIALITE=YES


Gives:

---

Exporting 71 features...
ERROR 1: sqlite3_step() failed:
  firestations.GEOMETRY violates Geometry constraint [geom-
type or SRID not allowed] (19)
ERROR 1: sqlite3_step() failed:
  firestations.GEOMETRY violates Geometry constraint [geom-
type or SRID not allowed] (19)

<... lots of these ...>

ERROR 1: sqlite3_step() failed:
  firestations.GEOMETRY violates Geometry constraint [geom-
type or SRID not allowed] (19)
ERROR 1: COMMIT transaction failed: cannot commit - no
transaction is active
v.out.ogr complete. 71 features (Point type) written to  
(SQLite format).

(Sun Sep  6 22:07:37 2015) Command finished (3 sec)

---

The database is created, including a table with a GEOMETRY column, but 
when I try to view it with the Map Preview in the spatialite_gui 
software, it says "This Column doesn't contains any Geometry: sorry...".


However, if I export to a shapefile first then use ogr2ogr, it works:

v.out.ogr --overwrite input=firestations@PERMANENT 
output=nc_firestations.shp

v.out.ogr --overwrite input=geology@PERMANENT output=nc_geology.shp
ogr2ogr -f sqlite -dsco SPATIALITE=YES nc.sqlite nc_firestations.shp
ogr2ogr -f sqlite -dsco SPATIALITE=YES nc.sqlite nc_geology.shp -append


I'm not sure what is causing the error, but a Google search brings up a 
ticket for an already existing bug:


https://trac.osgeo.org/grass/ticket/2300

If not the case of the GEOMETRY column, then perhaps it is the case of 
the geometry type e.g. GRASS passes 'Point' but Spatialite wants 'POINT'?


I'm on GRASS 7.0.1 from the UbuntuGIS unstable repository.

Cheers
John

--
Dr John A Stevenson
RSE/Scottish Government Personal Research Fellow
(co-funded by Marie Curie Actions)
School of GeoSciences
The University of Edinburgh
Grant Institute
James Hutton Road
Edinburgh EH9 3FE
Scotland
PHONE: (+44) 131 650 7526
FAX:   (+44) 131 668 3184
email:john.steven...@ed.ac.uk
twitter: @volcan01010
web:http://www.geos.ed.ac.uk/homes/jsteven5
blog:http://all-geo.org/volcan01010
**ICELAND MOBILE: (+354) 8417106**


The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user