Comments (9)
Shapefile e.g. hybas_lake_eu_lev01_v1c.shp DBF file contains column name ORDER which is reserved SQLite keyword, and it seems column is not properly escaped inside code during creating table.
- Download shapefiles e.g.
mkdir /tmp/shp && cd /tmp/shp && wget https://data.hydrosheds.org/file/hydrobasins/customized_with_lakes/hybas_lake_eu_lev01-12_v1c.zip
- Extract archive with
cd /tmp/shp && unzip hybas_lake_eu_lev01-12_v1c.zip
- Try import some shapefile with
v.in.ogr input=/tmp/shp/hybas_lake_eu_lev01_v1c.shp output=hybas_lake_eu_lev01_v1 project=test
- See error
GRASS nc_basic_spm_grass7/PERMANENT:~ > v.in.ogr input=/tmp/shp/hybas_lake_eu_lev01_v1c.shp output=hybas_lake_eu_lev01_v1 project=hybas
Project <hybas> created
Check if OGR layer <hybas_lake_eu_lev01_v1c> contains polygons...
100%
Creating attribute table for layer <hybas_lake_eu_lev01_v1c>...
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near "ORDER": syntax error
DBMI-SQLite driver error:
Error in sqlite3_prepare():
near "ORDER": syntax error
ERROR: Unable to create table: 'create table hybas_lake_eu_lev01_v1 (cat
integer, HYBAS_ID integer, NEXT_DOWN integer, NEXT_SINK integer,
MAIN_BAS integer, DIST_SINK double precision, DIST_MAIN double
precision, SUB_AREA double precision, UP_AREA double precision,
PFAF_ID integer, SIDE varchar ( 6 ), LAKE integer, ENDO integer,
COAST integer, ORDER integer, SORT integer)'
from grass.
My principal question is: what is the classical proper way to import .shp files to preserve linking. My LOCATION serve as a database with some rasters and vectors that are always there (they are very big). My script imports any chosen watershed file and cuts big rasters and select vectors with this polygon. So I want to cleanly import and then remove working polygon without destructing the database.
from grass.
I think there are two problems described in one post, but I trust they come from the unique root. To be honest, I can't describe exactly the moment when the database looses the link.
from grass.
I tried again:
- Deleted all vector layers from LOCATION.
- Imported HydroLAKES vector without any settings from GUI on Windows as it is (successfully)
- Imported basin.shp without any settings as it is (with column FID).
- Deleted basin from LOCATION and exited from GUI.
- Run container.
- Run my script where
v.in.ogr
for basin vector without any settings and with overwrite - Got errors:
Creating attribute table for layer <basin>...
DBMI-SQLite driver error:
Error in sqlite3_prepare():
table basin already exists
DBMI-SQLite driver error:
Error in sqlite3_prepare():
table basin already exists
ERROR: Unable to create table: 'create table basin (cat integer, FID
integer)'
LAKE_AREA=5
BUFFER=10
WARNING: Coor file of vector map <basin@PERMANENT> is larger than it should
be (18 bytes excess)
WARNING: East (7.90505033345994e-323) is not larger than West
(6.95300572703085e-310)
ERROR: Illegal latitude for North: 7.32278e+25
Although db.tables didn't show any table for basin from GUI. That means I can properly import the file from GUI, but can't import it with the same command from linux terminal.
NB: I've deleted basin previously, where the table existing comes from?
from grass.
With this fix #3605 I successfully import shapefile from my comment above.
GRASS nc_basic_spm_grass7/PERMANENT:~ > v.in.ogr input=/tmp/shp/hybas_lake_eu_lev01_v1c.shp output=hybas_lake_eu_lev01_v1 project=hybas
Project <hybas> created
Check if OGR layer <hybas_lake_eu_lev01_v1c> contains polygons...
100%
Creating attribute table for layer <hybas_lake_eu_lev01_v1c>...
Importing 1 features (OGR layer <hybas_lake_eu_lev01_v1c>)...
100%
-----------------------------------------------------
Registering primitives...
-----------------------------------------------------
Cleaning polygons
-----------------------------------------------------
Breaking polygons...
Breaking polygons (pass 1: select break points)...
100%
Breaking polygons (pass 2: break at selected points)...
100%
-----------------------------------------------------
Removing duplicates...
100%
-----------------------------------------------------
Breaking boundaries...
100%
-----------------------------------------------------
Removing duplicates...
100%
-----------------------------------------------------
Cleaning boundaries at nodes...
100%
-----------------------------------------------------
Merging boundaries...
100%
-----------------------------------------------------
Removing dangles...
100%
-----------------------------------------------------
Building areas...
-----------------------------------------------------
Removing bridges...
100%
-----------------------------------------------------
Registering primitives...
Building areas...
100%
Attaching islands...
100%
-----------------------------------------------------
Finding centroids for OGR layer <hybas_lake_eu_lev01_v1c>...
100%
-----------------------------------------------------
Writing centroids...
100%
-----------------------------------------------------
5193 input polygons
Total area: 1.8739E+13 (9466 areas)
Area without category: 4.66917E+11 (4273 areas)
-----------------------------------------------------
Copying features...
100%
Building topology for vector map <hybas_lake_eu_lev01_v1@PERMANENT>...
Registering primitives...
Building areas...
100%
Attaching islands...
100%
Attaching centroids...
100%
But it is not possible see attribute table data with GUI tool (error message is showed, because table column name is DB reserved keyword and is not escaped).
But with command db.select
module it is possible query hybas_lake_eu_lev01_v1 table successfully:
GRASS hybas/PERMANENT:~ > db.tables
hybas_lake_eu_lev01_v1
GRASS hybas/PERMANENT:~ > db.select table=hybas_lake_eu_lev01_v1
cat|HYBAS_ID|NEXT_DOWN|NEXT_SINK|MAIN_BAS|DIST_SINK|DIST_MAIN|SUB_AREA|UP_AREA|PFAF_ID|SIDE|LAKE|ENDO|COAST|ORDER|SORT
1|2010000010|0|2010000010|2010000010|0|0|18236071.2|18236071|2|M|0|0|1|0|1
from grass.
The same error I got for basin2 file which is simply exported from HydroSHEDS basins, like @tmszi proposed.
Check if OGR layer <basin2> contains polygons...
100%
Creating attribute table for layer <basin2>...
DBMI-SQLite driver error:
Error in sqlite3_prepare():
table basin already exists
DBMI-SQLite driver error:
Error in sqlite3_prepare():
table basin already exists
ERROR: Unable to create table: 'create table basin (cat integer, HYBAS_ID
integer, NEXT_DOWN integer, NEXT_SINK integer, MAIN_BAS integer,
DIST_SINK double precision, DIST_MAIN double precision, SUB_AREA
double precision, UP_AREA double precision, PFAF_ID integer, SIDE
varchar ( 6 ), LAKE integer, ENDO integer, COAST integer, ORDER
integer, SORT integer)'
LAKE_AREA=5
BUFFER=10
WARNING: Coor file of vector map <basin@PERMANENT> is larger than it should
be (18 bytes excess)
WARNING: East (7.90505033345994e-323) is not larger than West
(6.95273213512812e-310)
ERROR: Illegal latitude for North: 7.32278e+25
ERROR: Illegal latitude for North: 192
Importing basin from such a full and clean file is preferrable.
from grass.
I haven't managed to load the table of HydroLAKES layer still.
The error with basin file seem to be corrected, but after basin had been loaded, the HydroLAKES table seem to loose the link again.
DBMI-SQLite driver error:
Error in sqlite3_prepare():
select * from HydroLAKES_polys_v10 where 0 = 1
no such table: HydroLAKES_polys_v10
DBMI-SQLite driver error:
Error in sqlite3_prepare():
select * from HydroLAKES_polys_v10 where 0 = 1
no such table: HydroLAKES_polys_v10
And by the way, yes, the basin shp was imported, but there is no features in the table, and the error is "Unable to open select cursor" when I try to display the attribute table.
from grass.
I haven't managed to load the table of HydroLAKES layer still. The error with basin file seem to be corrected, but after basin had been loaded, the HydroLAKES table seem to loose the link again.
DBMI-SQLite driver error: Error in sqlite3_prepare(): select * from HydroLAKES_polys_v10 where 0 = 1 no such table: HydroLAKES_polys_v10 DBMI-SQLite driver error: Error in sqlite3_prepare(): select * from HydroLAKES_polys_v10 where 0 = 1 no such table: HydroLAKES_polys_v10
And by the way, yes, the basin shp was imported, but there is no features in the table, and the error is "Unable to open select cursor" when I try to display the attribute table.
Could @geografin post exact reproducible steps, please (same as in my comment above #3604 (comment))?
from grass.
And by the way, yes, the basin shp was imported, but there is no features in the table, and the error is "Unable to open select cursor" when I try to display the attribute table.
Vector map attribute table (GUI tool) should be will open with this fix #3614 or use v.db.select or db.select inside emulator terminal. GUI tool require much more changes to work with attribute table which contains columns names with reserved DB backend keywords.
from grass.
Related Issues (20)
- [Bug] r.plus.example addon not available for wingrass 8.5 used in windows tests HOT 4
- [Feat] r.mask -r: WARNING, not ERROR, on "No existing MASK to remove"
- [Bug] r.object.geometry is not in the gui menu HOT 4
- [Feat] Recreate Pylint configuration from scratch HOT 3
- r.in.pdal: range of the return numbers
- [Bug] r.fill.dir Segfault/stack overflow with larger datasets HOT 2
- [Bug] Docker builds fail to compile PDAL 2.7.2 from source, missing release assets HOT 4
- [Bug] attributes.c:14:10: fatal error: liblas/capi/liblas.h: No such file or directory
- [Bug] Details: d.barscale: error while loading shared libraries: libmkl_rt.so.2: cannot open shared object file: No such file or directory HOT 4
- Status of ruff issues and fixes HOT 3
- [Bug] r.info: format=json does not respect flags HOT 4
- [Feat] Upgrade C++ standard support to C++17 HOT 6
- [Bug] Why is `_renderCat` always True in iscatt/plots.py?
- [Feat] Ensure compatibility with NumPy 2.0 HOT 3
- [Bug] Highlighted (selected) features are not refreshed after zoom/pan in GUI HOT 1
- Allow space between r.li and manual before the colon in PR titles
- Also extract translatable strings in header files
- [Feat] r.category: add color option
- [Feat] r.category: support JSON rules file
- [Bug] t.info: 'RasterMetadata' object has no attribute 'print_info'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grass.