Search code examples
javashapefilegeotools

Creating a shapefile from CSV-file


I'm trying to create a program which takes the coordinates from a csv-file and turns it into a shapefile. I downloaded the GeoTools libraries but I can't get the code to work...


Solution

  • In order to do this, you'll want to create a SimpleFeatureType and SimpleFeatures from the rows in the CSV, and then use the ShapefileDataStore to write those features out to disk.

    This tutorial [1] in the documentation does just that. Are you using that tutorial or having trouble with something else?

    1. http://docs.geotools.org/latest/userguide/tutorial/feature/csv2shp.html

    As an aside, if this is a one-time or otherwise infrequent operation which can be done manually, I'd recommend trying out QGIS. QGIS is a desktop GIS application and for turning a CSV in a shapefile, it'd require no programming.