Shapefile read and write API for android (to be used in mapsforge_0.5.0)

1,151 views
Skip to first unread message

Ams Sol

unread,
Sep 30, 2014, 7:48:45 AM9/30/14
to mapsfo...@googlegroups.com
Hi everyone

Does anyone know a good API to read/write shapefiles in an android app?
I am using mapsforge and I have been able to import an .shp file using some API. I apparently collect the polygon point coordinates and draw them on my map by creating new Polygon class from those points, and add it as a layer.
However, that API does not support writing ESRI Shp files.
I have found far too many Java APIs for shapefiles but they all come up with NoClassDefFoundError and are not supported for android build. Jars are not compatible with Dalvik because they are for Java in general.
many thanks in advance

Ludwig

unread,
Oct 2, 2014, 1:32:46 PM10/2/14
to mapsfo...@googlegroups.com
Do you actually need to write shapefiles? Or even read them? 
There are plenty of utilities out there that convert shapefiles into more modern formats that are easier to read and write, so you could perform your conversion on a server and not on Android itself.

If you really need to read/write shapefiles, IIRC they are actually in a very old Microsoft DB4 format (or something like that), so if you find code that reads/writes that format it would also help you. 
I personally think that spatialite files are much better for this as everything is in one single file (so no chance of losing the projection info any more, which is common with shapefiles).

Ludwig


--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapsforge-dev/92d17e09-cd73-46ad-bc10-5fac8e6b5958%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andy Greaves

unread,
Oct 6, 2014, 12:14:12 PM10/6/14
to mapsfo...@googlegroups.com
I agree with Ludwig. Using spatialite on Android would be a better option.

I currently use Mapsforge to render the map data and the spatiallite implementation on Android to query the database and display the resulting polygons on the Mapsforge map. The following resources below helped me:


QGIS includes a spatialite plugin which is great tool to write and check your queries.

Andy

Emux

unread,
Oct 6, 2014, 1:01:32 PM10/6/14
to mapsfo...@googlegroups.com
I use SpatiaLite too, even from the old days where we had to build it ourselves.
It's a very versatile library which is worth to invest in it.

I also suggest to check GeoJSON for cases when there is not need for indexing or queries but just for storing / exchanging data.

--
Emux
Cruiser - Atlas
Reply all
Reply to author
Forward
0 new messages