Import geopandas geodataframe into spatialite

325 views
Skip to first unread message

Alessandro Sarretta

unread,
Jan 5, 2017, 4:32:22 AM1/5/17
to SpatiaLite Users
Dear all,
I'd like to importa geodataframe (geopandas) into a spatialite database.
From this issue (https://github.com/geopandas/geopandas/issues/189) it seems that the pandas to_sql() method doesn't support spatial databases.
Is there a way to do it?
I found this (http://gis.stackexchange.com/questions/141818/insert-geopandas-geodataframe-into-spatialite-database#141854) but, if I understand well, it is for Windows systems (I'm using Linux-Ubuntu).
Thank you for any hint,
Ale

a.fu...@lqt.it

unread,
Jan 5, 2017, 5:15:13 AM1/5/17
to spatiali...@googlegroups.com
On Thu, 5 Jan 2017 01:32:22 -0800 (PST), Alessandro Sarretta wrote:
> Dear all,
> I'd like to importa geodataframe (geopandas) into a spatialite
> database.
> From this issue (https://github.com/geopandas/geopandas/issues/189)
> it
> seems that the pandas to_sql() [1]method doesn't support spatial
> databases.
> Is there a way to do it?
> I found this
>
> (http://gis.stackexchange.com/questions/141818/insert-geopandas-geodataframe-into-spatialite-database#141854)
> but, if I understand well, it is for Windows systems (I'm using
> Linux-Ubuntu).
>

Carissimo Ale,

I have absolutely no idea about geopandas (never heard before
this morning), but after a quick web search it seems that it
should be able to export data into the standard ESRI Shapefile
format [1]

[1]
http://gis.stackexchange.com/questions/147156/making-shapefile-from-pandas-dataframe

if confirmed, it seems to be a really simple and straightforward
way to trasfer data from panda to spatialite.

bye Sandro

David Anderson

unread,
Jan 6, 2017, 7:05:29 PM1/6/17
to SpatiaLite Users
Ale,
I had the same question.  Besides this way you found there is also this method:

I have used both methods successfully on a Windows platform.  In reviewing the link that you posted the only thing that looks windows specific is the dll call, which would translate into the method used in Linux to load extensions into SQLite.

I keep thinking that since geopandas is calling the GDAL/OGR library through a few layers and since OGR can read/write Spatialite databases, that there should be an easier way.

Also the method that you referenced works with casting as WKT also.

Hope this helps.

David
Reply all
Reply to author
Forward
0 new messages