Search code examples
androidshapefile

Android lib to read or parse shapefile


is there any library that is able to read parse a .shp file, preferably on where I don't need to use NDK. I was trying to use GeoTools but i can't seam to get it to work on Android.


Solution

  • I've been using two lightweight shapefile parsers with good results in Android: diewald_shapeFileReader and Java ESRI Shape File Reader.

    GeoTools relies heavily on AWT and Java Service Provider Interface (SPI) both not supported by Android. So it´s not a viable option.

    EDIT 2021

    Osmdroid library as of Mar 24st, 2019, Release: 6.1.0,

    supports overlaying shapefiles using the Java ESRI Shape File Reader I mentioned previously.

    Syntax:

    List<Overlay>  folder = ShapeConverter.convert(mMapView, new File(myshape));
    mMapView.getOverlayManager().addAll(folder);
    mMapView.invalidate();
    

    Where

    myshape is a .shp file somewhere on the drive. If other metadata files are found, they will be used and injected into the converted shapes.